Skip to content

ho94949/yacht-dice

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Yacht Dice AI

AI of Yacht Dice.

This AI maximizes expected value of yacht. This AI Do not consider opponent, thus not maximizing winning probability.

Expected score value of Yacht dice game with optimal play is 191.774369, way more than average person playing.

Requirement

  • You should have C++-17 compatible compiler.
    • Tested with g++ 9.3.0 on ubuntu 20.04 WSL.
  • This program requires 300MB of memory to save all possible state of yacht dice.

Rules

Yacht dice game has many variations, and this game uses following rules.

  • One, Two, Three, Four, Five, Six
    • For any combination, score is the sum of dice with chosen number.
    • If you score 63 or higher in these categories total, you can get additional 35 scores.
  • Four Card
    • If combination includes four dice showing the same face, score is the sum of all dice.
  • Full House
    • If combination is given ans two of one number and three of another, score is the sum of all dice.
  • S. Straight
    • If combination has 4 consecutive numbers, score is 15.
  • L. Straight
    • If combination is 5 consecutive numbers, score is 30.
  • Yacht
    • If all five dices are showing same face, score is 50.

You can modify these rules in rule.hh and rule.cc

Build & Execution

  1. Build all *.cc files in src, or just execute ./compile.sh. If you execute ./compile.sh, ./main will be produced in root directory.
  2. ./main calc produces pre-calculation files, data.bin. (Total 200MB)
    1. Calculation takes 20 minutes, 1.7GB of memory on Intel(R) Core(TM) i5-10400 CPU @ 2.90GHz.
  3. ./main loads data.bin if they exists.

Win10 64bit binary and pre-computed data.bin can be downloaded in Releases tab.

Usage

This program shows tabular interface of yacht dice game. Score is your earned score, while estimation is expected value of optimal play.

  • Input your dice (? more re-rolls)
    • You should enter 5 space-separated integer, when dice rolled.
    • This program shows recommended dice to keep. (In most program, Click can be used to keep dices.)
    • You will see another Input your dice screen. You should input all of your dices, not only re-rolled dice.
      • This program only shows "recommendation"s and these are not forced.
  • Your choice:
    • You can enter any integer between 1 and 12, where score can be recorded.
    • Recommended choice are shown, and you can follow them.

Implementation

This Yacht Dice AI use bitmask dynamic programming, thus investigating all possible state of yacht dice. calc.cc includes implementation.

TODOs

If you want, you can create PR to this repository.

  • Multi-core, GPU, or AVX support could be added.
  • op variable need not to be exported with careful implementation (will need little more calculation on run-time)
  • Winning probability support. Supporting this naively will cost 660 times more calculation and memory. So multicore and file size reducing would be needed.

License

Shield: CC BY-SA 4.0

This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.

CC BY-SA 4.0