Phys291 project by Odne Hellebø and Bjørn Greve:

Our phys 291 project has been to make a C++ program which plays yatzi, and we have done some experiments with root to plot some results concerning this program. Odne Hellebø has taken care of most of the C++ codes, while Bjørn Greve has taken care of the plotting, the rootscript, structuring the project and creating all the histograms including this homepage.

Yatzi_6_terninger.cpp is the main file. If you compile yatzi_6_terninger.cpp when running the compiled program, you will get the YatziVerdier.txt, which is a data file over 1000000 games of yatzi.

We have some tools in this program, thats the Dice, the DiceArray and the different pointclasses. The only difference with the different pointclasses is the different ways you get the points. Otherwise all the usual common variables and functions are in the motherclass PointClass. we've collected all of these different pointclasses in the YatzyBoard, that way we just call the different pointclasses on the board. The DiceArray takes care of knowing what dices to keep and which to throw again. The last important file is the main file. Here we just made one simple algorithm, that basically took what it could get, but we also added the betterThan on some functions so that we could make it look values above a certain level. These only apply for the more "advanced", like pair, alike and so on. F.ex, we could make it so that the only acceptable value would be 6, 6, so we wouldn't waste valuable time on 1, 1. The program does however take a higher value if it is able to. To make another algorithm we could use the diceArray and then send the value to the board. But to figure out how to actually make an algorithm that would choose a place to get on the board you would have to make a throw first then see where you should focus your remaining throws and what you should keep.

Basically what we have done with the root script is to create a root file, which reads all the points from YatziValues.txt which is a datafile. Then root creates histograms from these data. The histograms we have created is our result. For a webpage for the root script see: Root_script

The yatzi program is designed to play 1000000 yatzi games, and the text file displays the result for each throw. Each of the histogram files displays different distributions of points in yatzi.

Histogram 1 displays all values in the collection of 1's over 1000000 attempts.Hist.1
Histogram 2 displays all values in the collection of 2's over 1000000 attempts.Hist.2
Histogram 3 displays all values in the collection of 3's over 1000000 attempts.Hist.3
Histogram 4 displays all values in the collection of 4's over 1000000 attempts.Hist.4
Histogram 5 displays all values in the collection of 5's over 1000000 attempts.Hist.5
Histogram 6 displays all values in the collection of 6's over 1000000 attempts.Hist.6
Histogram 7 displays all values of all first six values without bonus over 1000000 attempts.Hist.7
Histogram 8 displays all values of a pair over 1000000 attempts.Hist.8
Histogram 9 displays all values of three alike over 1000000 attempts.Hist.9
Histogram 10 displays all values of four alike over 1000000 attempts.Hist.10
Histogram 11 displays all values of two pairs over 1000000 attempts.Hist.11
Histogram 12 displays all values of a full house over 1000000 attempts.Hist.12
Histogram 13 displays all values of the final score after a game of yatzi over 1000000 games.Hist.13

YatziValues.txt contains all the values over 1000000 games of yatzi. Column 1-6 displays the result when collecting dices of 1-6. Column 7 is the total value without bonus, 8 is bonus, etc. Histogram_file is a root file. If you open this file in root you will see all the different histograms. This is the compiled file of the root script yatzi_root_script.cpp.

For a full overviev of the project you can download the zipfile Final project

A special thanks to Boris Wagner for all his help during the semester.