|Maximilian Keßler 934345e076|
This is a dynamic program written in C++ to solve Hanabi endgames. Some optimizations are performed, but it is not particularly well-written at the moment and could also use some code cleanup.
As of now, you can run the executable with an id from a hanab.live game and a turn number and the winning percentage for the corresponding game state with optimum play will be calculated.
Here, optimum play refers to the assumption that everbody knows their cards, but not the draw pile.
For example, if the output of the program is 1, then this means that even if an evil adversary is allowed to pick the next card in the deck each time a card is drawn, there is still a strategy that guarantees a win.
The build uses CMake. Additionally, you need the following libraries:
- boost: For some faster containers and JSON parsing
- cpr: For easy requests (to download games from hanab.live
- GNU readline: For the command-line interface. Refer to the corresponding pages for installation instructions. On Linux distributions, readline is probably already installed.
Note that the libraries are all FOSS software and GPL-compatible. For installation help, see below.
Now, building the project is quite easy (this assumes you have installed above libraries system-wide):
cmake -DCMAKE_BUILD_TYPE=RELEASE . // Release build recommended for performance, unless you want to develop make // Rerun this every time you change sources
Installing the libraries
I can't provide information for all distributions, but in general it should be like the following:
cmake: should be available as a system package via your package manager.
readlineshould be installed already, otherwise try your package manager as well.
cpris a bit more complicated:
- On Arch, there is a package in the AUR.
- On Fedora, there is also a package via rpm.
- There might be packages for other distributions, check out the CPR project on Github.
- If there is no package available for your distribution, see [Installing cpr as a local CMake dependency](# Installing cpr as a local CMake dependency).
- I recommend installing packages with Homebrew.
brew install boost cpr readline cmakeshould do the job.
- Currently, I have no idea regarding windows, sorry for that.
Installing cpr as a local CMake dependency
- There is also the option to install
cprdirectly as a dependency through
CMake. For this, in
CMakeLists.txt, replace the line
with the lines
You might need to replace the
include(FetchContent) FetchContent_Declare(cpr GIT_REPOSITORY https://github.com/libcpr/cpr.git GIT_TAG 2553fc41450301cd09a9271c8d2c3e0cf3546b73) FetchContent_MakeAvailable(cpr)
GIT_TAGwith the latest release tag from Github, but the above should usually work. You can find details on this installation method on the cpr github page as well.
# ./endgame-analyzer (GAME_ID | GAME_FILE) TURN
GAME_IDis a game from hanab.live.
GAME_FILEis a path to a file containing the game as JSON in the hanab.live format.
TURNspecifies the turn of the game state to analyze. Turn 1 is the state before actions have been taken.
Be cautious about specifying too low turn counts, your program will eventually run out of memory. Typically, turn counts where roughly 8 cards are still in the draw pile are reasonably fast, but running times depend heavily on the exact game state you want to analyze.
This is GPLv3-licensed. See LICENSE for details.