The goals of this assignment are to:
You need to write a program to play a variation of the game of Yahtzee. This is a game played with 5 dice. Your program will roll all the dice and your objective is to obtain the highest score you can in each of 10 categories:
Your program will determine which scoring category is the best fit for each roll. Remember that you can only record an entry in a category once. If you cannot meet the criteria of a category, then you must score zero (0) for that category. For example, if the only category left to fill is 5-of-a-kind and you don't roll 5-of-a-kind, then you must score 0 for that category. You need to devise your own strategy for determining the best way to maximize your score over the 10 turns.
Write a description of your strategy and include it in the header comment of your player class (described below).
toString()method that returns the value of the die as a
hw4<your_cunix_id>.java. For example, mine is called
Playerclass. (0.25 points)
main()method in order to implement your strategy. Note that the strategy in my Player class is very stupid and always scores 0. As above, you can create and define any additional constants, variables and methods you need to implement your strategy. (4.0 points)
System.out.println( "TOTAL = " + p.totalScore() )
Dieclass that draws the dice as they are shown on my rules page.
For fun, we'll hold a tournament between everyone's working players, to see whose strategy works best. The winner(s) will receive C++ books.
Here's a sample run, illustrating my extension of Player.java. Note that this implements a terribly simple strategy that simply cycles through each category in order and scores accordingly. I don't roll the dice more than once in a turn -- though you can roll up to three times, as described in the rules.
unix$ java hw4eis2003 you have rolled:      score = 2 category = ones you have rolled:      score = 2 category = twos you have rolled:      score = 3 category = threes you have rolled:      score = 8 category = fours you have rolled:      score = 5 category = fives you have rolled:      score = 12 category = sixes you have rolled:      score = 0 category = 3-of-a-kind you have rolled:      score = 0 category = 4-of-a-kind you have rolled:      score = 0 category = 5-of-a-kind you have rolled:      score = 0 category = full-house TOTAL = 32 unix$
Your source code (i.e., your
.java file) but be neat and
You must have a header comment at the top of each file and you should comment
the end of each block (i.e., each
You must also have a comment block at the beginning of each method.
In your extension of the Player class, you must specify if you are overloading
or overriding any methods from the base class.
Follow the submission instructions carefully!!! If you don't, human intervention will be required to fix your mistakes, and you will lose 1 point.
hw4eis2003.java. Follow instructions on the assignments page.
hw4eis2003.java. Make sure your name is on all the papers you hand in!
This assignment is worth 10 points (out of 100 for the semester). Distribution of points is: