My main objective for this class was to apply programming to various situations in which statistical analysis could be useful to find an optimized solution through simulation. While looking at project ideas on Piazza, I came across the idea for Yahtzee simulation and thought it would be a fun, engaging project to get engrossed into.
I soon started to develop the major algorithm for making the game itself work. This took quite a long time, as I had to completely scrap the first version of the program I made and replace with a simpler, more efficient object-oriented approach. The program itself also generates a file you can open in Excel that contains data from all of the games that are simulated.
My AI is currently very very primitive, as it simply holds the dice that have the best chance of getting you a Yahtzee. This is one region where I plan on expanding in the next quarter. I will make players with different playing strategies, similar to Mr. Pethan's randomly generated players in the ultimate frisbee game, and these players will show me what strategy for Yahtzee will produce the highest, most consistent scores, which I can then analyze through means, standard deviations, and confidence intervals.
Anyway, if anyone is interested in the code, it is below in a zip file. Once it is downloaded, open the folder and copy the two files anywhere, just make sure they are both in the same folder. Once you do this, make sure you have either Python 2.7 or 3.3 installed on your computer, right-click on "simulator.py," and click "Edit with IDLE." Now scroll to the bottom of the document which should look like this:
Now, where it says playGames(1000, False), you can enter in any number for 1000 and that will be how many games of Yahtzee will be simulated by the program, and False should probably be kept false. Now, save the document and hit F5 to run the program. You will see that displayed on the shell is the average information for valuable stats, while the raw data will be stored in the newly created file game_stats, which is in the same directory as your programs.
Feel free to ask me any questions you have about the program or how it works.
Link to download >>>>Yahtzee Files<<<<