goal.
The goals of this assignment are to:
the game.
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).
program.
Die.java
that contains:
toString()
method that returns the value
of the die as a String
(0.5 points)
hw4<your_cunix_id>.java
.
For example, mine is called hw4eis2003.java
.
Player
class.
(0.25 points)
tally()
or the
totalScore()
methods.
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() )
Die
class that draws the dice as they are shown on my rules page.
fun tournament.
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.
sample run.
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: [1] [1] [5] [2] [3] score = 2 category = ones you have rolled: [1] [1] [3] [2] [3] score = 2 category = twos you have rolled: [1] [6] [2] [3] [5] score = 3 category = threes you have rolled: [1] [4] [2] [4] [5] score = 8 category = fours you have rolled: [5] [2] [1] [6] [3] score = 5 category = fives you have rolled: [6] [6] [1] [2] [5] score = 12 category = sixes you have rolled: [6] [3] [3] [1] [2] score = 0 category = 3-of-a-kind you have rolled: [5] [4] [2] [6] [5] score = 0 category = 4-of-a-kind you have rolled: [2] [6] [5] [1] [5] score = 0 category = 5-of-a-kind you have rolled: [5] [3] [2] [6] [5] score = 0 category = full-house TOTAL = 32 unix$
source code.
Your source code (i.e., your .java
file) but be neat and
clearly commented.
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.
submission.
Follow the submission instructions carefully!!!
If you don't, human intervention will be required to fix your
mistakes, and you will lose 1 point.
hw4<yourCUNIXusername>.java
hw4eis2003.java
.
Die.java
and hw4eis2003.java
.
Follow instructions on the assignments page.
Die.java
and hw4eis2003.java
.
Make sure your name is on all the papers you hand in!
points.
This assignment is worth 10 points (out of 100 for the semester).
Distribution of points is:
:-)