CS120
Programming Assignment #7
Due Sunday March 25th.
For this assignment you will be modifying the Generic Board Game
program. You can use the version from the previous assignment
or start over from scratch. Make the following changes to the
program:
-
Create a new "score" variable for each of the players.
This could be an actual score or another variable such as gold, health, fame,
etc.
As the game
progresses, special squares should cause each players' "score" variable
to increase and decrease. Change the victory conditions to match the new
variable. For example, the game might end when the first player reaches
the goal, but the winner is the player with the most gold (and maybe the
first player to reach the goal gets some bonus gold making it more likely
that the player will win). Alternatively the game might end when the first
player's score reaches zero (for example, if the "score" variable is health).
Make sure that the new rules are clearly presented to
the players at the beginning of the program.
To make this change to the program several related changes will have to be
made in the code and in the game file.
- The square class will need to be expanded with one additional variable
that keeps track of how much a player's "score" changes when they land on
that square.
- The action() function will need to be modified so that it correctly
changes the player's "score". Or a new function in the square class will need
to be created to change a player's "score".
- Each line in the game.txt file will need to be modified to include an
additional value that determines how much a player's score changes by.
- The read_board() and set_square() functions will need to be modified
to read the additional vlaue out of the game.txt file and correctly store
it in the game objects.
- The victory conditions will need to be modified to check the players'
scores or possibly to have a player lose if the their score (e.g. health) reaches
zero.
-
Give player a choice on their turn. For example,
they can move ahead exactly 2 or move a random distance
between 1 and 4. Or they can move a random distance,
but get pick between 1-4 and -1 to 6.
Make sure that the game's introduction,
instructions, and comments accurately explain the new version. Make sure that
each players' "score" is printed every turn. Include comments at the
beginning of the code explaining your changes.
Turn in: A copy of the program, a copy of a correct game file to
go with it, and sample output showing the program runs.
Make sure that all of your new special squares are tested in the output.