CS120
Programming Assignment #10
Due Monday April 21 at the beginning of lecture. This assignment
should be done individually, not as a pair programming assignment.
Begin by entering or downloading the Robot World Program from Chapter 6.
If typing,
there is a typo in the code, page 80, line 35b there's a stray \ in the
rand() command.
After the program is entered and the typo is fixed, make sure that the
program compiles and runs (the download version is spread across two .cpp
files and one .h file). Make sure you understand how the program works.
Pay particular attention to how the pointers are used and how
robots are moved in the world grid.
After you are comfortable with the program make the following changes:
- Section 6.4 Exercise 1 (World Size)
- Section 6.4 Exercise 2 (More Robots)
- Section 6.4 Exercise 3 (Robots with Different Appearance)
- Section 6.4 Exercise 5 (Different Terrain)
- Section 6.5 Problem 4 (Energy and terrain)
- Section 6.5 Problem 8 (Robot Interactions), with the wrinkle below
For Robot Interactions, extend the robot class so that each robot is
randomly determined at creation to be either Type I (hunter), Type II (bomber),
or Type III (fueler). Hunters should destroy if they move into another
hunter or fueler, but be destroyed if they move into a bomber. Bombers
should destroy themselves if they move onto another robot. Fuelers should
not move and instead grant a +100 energy to any robot whose square they
attempt to move into.
Turn in: A copy of the program and sample output showing it runs.