Design and implement the following strategies as
MoveFirstPawn: This player tries to move
the frontmost pawn with each die roll. If the frontmost
pawn cannot move, this player considers the one behind
MoveLastPawn: This player tries to move the
rearmost pawn with each die roll. If the rearmost pawn
cannot move, this player considers the one in front of it,
etc. (Note that once the rearmost pawn moves, it may no
longer be the rearmost pawn.)
Some hints on testing:
Separate out pieces of the player's functionality as
library routines and test these individually.
Build your tests as you build your players. That is, find
some small piece of the player that you can
implement. Implement and test that one piece (or, if you
prefer, write test cases and then implement them) before
moving on to the next one. Of course, that means that you
have to have some idea of the overall shape before you
Keep in mind that you are only testing your player -- if you
find mistakes in your board or move checking logic, add a
test case there.
- To build a test case, construct a board and a die roll
that you know should make the player behave in a certain
manner. Then, call the players doMove method and
see if the moves produced matched what it should have
done in that situation.
Build many such test cases, starting with very simple ones and
building up to more and more complex ones, with the goal of
covering every different logical aspect of the player’s
Automatically test if the player fails. Only use printouts
for debugging -- remove them when the tests pass! (In
general, don't leave junk like commented out code or
printouts in your code; that does not make it
easier to read.)
Run a tournament to find out how these strategies perform.
Which one is better?