python3 -m venv yahtzee-venv
source yahtzee-venv/bin/activate
pip install -r requirements.txt
./test.sh
You should see outputs for each strategy, in ascending order by goodness
python3 yahtzee.py --strategy <strategy> --runs <runs> [--interactive] [--show-plot]
Where strategy
is one of:
random
- just keep the dice you're given, and pick a random categoryrandom_greedy
- just keep the dice you're given, and pick the category that gives the highest scoreall_yahtzee
- Do everything possible to get a Yahtzee every turnprob
- Use probability tables to maximize the fraction of points you earnprob_with_difficulty
- Use probability tables to maximize the fraction of points you earn, considering the difficulty of each category
--runs
is the number of games to simulate
--interactive
will show you the dice and ask you to pick a category for each turn
--show-plot
will show you a plot of the score distribution
build_prob_db.py
generates a sqlite database with a few tables:
all_rolls
- All rolls of 5 dice, with dice sorted in ascending orderroll_transitions
- The probability of transitioning from one roll to another, while keeping some subset of the first rolllevel0
- For each roll, its score in each category, reprersented as a fraction of the maximum possible score in that category, and the raw scorelevel1
- For each roll, the expected value of each roll/keep/strategy combination, based on the sum of the expected values of each possible next roll from the level1 table
random
- 84.5random_greedy
- 86.5all_yahtzee
- 87.5prob
- 88.5prob_with_difficulty
- 89.5