This is a program that plays Hanabi.
The main AI is contained in the directory alphahanabi. It is optimized for 5-player games, but it also plays well 4-player games.
A sample (stupid) AI is provided in the directory dummy.
An additional stronger AI is contained in the directory deltahanabi.
Here are the average scores and win rates for the standard 50-card deck (5 colors) and for the "black" 55-card variant (6 colors, where the 6th color has 1 copy of each card).
Average scores
| AI | standard 4 players | standard 5 players | black 4 players | black 5 players |
|---|---|---|---|---|
| alphahanabi (moderate) | 22.40 | 23.25 | 24.87 | 26.56 |
| alphahanabi (hard) | - | 24.26 | - | 27.67 |
| alphahanabi (hardest) | 24.67 | 24.75 | 28.47 | 28.82 |
| deltahanabi | 24.57 | 24.95 | 28.36 | 29.39 |
Win rates
| AI | standard 4 players | standard 5 players | black 4 players | black 5 players |
|---|---|---|---|---|
| alphahanabi (moderate) | 6.3 % | 12.4 % | 0.2 % | 1.2 % |
| alphahanabi (hard) | - | 54.4 % | - | 16.2 % |
| alphahanabi (hardest) | 76.4 % | 80.5 % | 32.0 % | 40.7 % |
| deltahanabi | 72.9 % | 95.9 % | 38.2 % | 65.7 % |
- Python 2.7
- The
termcolorPython module (install command:pip install termcolor) - The
blessingsPython module (install command:pip install blessings)
python run_game.py
Command line options
-n NUM_PLAYERSset number of players (default is 5)-a AI_DIRECTORYchoose AI (default isalphahanabi)-p DIFFICULTYchoose difficulty level foralphahanabi(possible values:moderate,hard,hardest; default ishardest)-crun the game without pausing (otherwise, by default, each new turn is played by pressing ENTER)-sactivate the strategy log-tprint a shorter log of turns and status-l FILE_NAMEload the initial deck from the given file (otherwise, by default, the initial deck is shuffled randomly)-d FILE_NAMEdump the initial deck to the given file (default isdeck.txt)-r SCORErun many games, until a score <= to the given score is reached-irun in interactive mode-qquit immediately after showing the initial cards (not in interactive mode)
python test.py
or (much faster)pypy test.py
Command line options
-n NUM_PLAYERSset number of players (default is 5)-m NUM_GAMESset number of games (default is 1000)-a AI_DIRECTORYchoose AI (default isalphahanabi)-p DIFFICULTYchoose difficulty level foralphahanabi(possible values:moderate,hard,hardest; default ishardest)-d DECK_TYPEchoose deck type (possible values:standardfor the standard 50-card deck,blackfor the 55-card deck)
First run, saving the deck and seeing the cards:
python run_game.py -d FILE_NAME -q
Second run, loading the deck and running the game without showing cards:
python run_game.py -l FILE_NAME -p DIFFICULTY -t -i