Coder Social home page Coder Social logo

python-rummy's Introduction

Command Line Rummy in Python 3

This is a one to four player command line version of the card game Rummy.

Play against friends or AI

Installation

pip install rummy

Demo

Python Rummy Demo

Usage

Run rummy in terminal

Select number of players then the number of AI opponents

Rules

Players must make melds of three or more cards eg A♠ 2♠ 3♠ or 4♠ 4♥ 4♣

Unmelded cards score points as follows: A = 1, J = 11, Q = 12, K = 13, number cards = face value

Players may knock once their hand is worth less than 10 points

Each other player then has one last turn before the round ends

At the end of each round players add their scores to their game total

The game ends once a player reaches 100 or more

The winner is the player with the lowest score

This project was created for EDx CS50 Final Project 2016

Final CS50 project video:

Python 3 Rummy AI battle

python-rummy's People

Contributors

alxwrd avatar orderandch4os avatar rhythmize avatar zbendas avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

python-rummy's Issues

Extract useful analytics from games

I'd like to be able to analyse games of Rummy. To that end, the program needs to extract and store data.

The data can be saved out to JSON or a CSV file.

A file should contain the following information:

  • Datetime
  • Number of Players
  • Whether players are human or bot
  • End game score
  • Total hands played
  • Number of turns of each hand played
  • The end score of each hand played
  • A log of all player turns
  • A players turn consists of their hand, top card current discard
  • The score of each player for every turn of the game

Below is some other useful information that will be needed. This will be more involved and can be added later after an initial data collection system has been implemented:

  • The number of melds a hand has with its lowest-scoring combination of melds
  • There could be several ways to meld a hand, this needs to be tracked to somehow
  • Ideally, it will also track groups of cards that could be melded with the addition of a single card

Plus any other useful information that could be useful later.

Write more tests

The coverage so far is for the scoring system. It'd be great to get some more test coverage in other areas.

If anyone is interested in writing some tests, please do.

Design a way to separate the presentation layer.

The main views have already been moved to methods in classes, but they are still mixed up with data crunching classes, they should be moved somewhere appropriate.

There are also input functions scattered throughout the project, these need to be decoupled so that an API can be created.

Implement Curses views

I wondered if it'd be possible to implement Curses views for the game turns.

If anyone knows Curses and wants to help out, that'd be much appreciated.

command_line.py file no longer required

There is no longer any need for the command_line.py it's contents can be moved to the __main__.py which currently imports it.

The setup.py file will need to be updated to use the __main__.py file afterwards.

Improve Rummy AI opponent decision making

Currently, the AI opponent checks to see if picking up the discard will result in a lower score or not, if it does it will pick up the discard. A lower score isn't the only determining factor of whether or not to pick up a discard; a player could also pick up the discard if it increases their chances of making melds later on. The AI could see if picking the card up will improve its odds of making melds.

The odds could be determined by past discards and the cards other players pick up.

How the AI chooses a discard is currently not optimal. At the moment the AI will throw away whichever card gives it the lowest scoring hand. It will throw away cards that form partial melds. The AI should check whether the card it's throwing away belongs to a partial meld and throw away a card that is less useful.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.