Problem 10 (250pts): Moat...
Let's add water to the colony! Currently there are only two types of places, the Hive
and a basic Place
. To make things more interesting, we're going to create a new type of Place
called Water
.
Only an ant that is watersafe can be deployed to a Water
place. In order to determine whether an Insect
is watersafe, add a new attribute to the Insect
class named is_waterproof
that is False
by default. Since bees can fly, make their is_waterproof
attribute True
, overriding the default.
Now, implement the add_insect
method for Water
. First, add the insect to the place regardless of whether it is watersafe. Then, if the insect is not watersafe, reduce the insect's health to 0. Do not repeat code from elsewhere in the program. Instead, use methods that have already been defined.
Before
Before writing any code, read the instructions and test your understanding of the problem:
python ok -q 10 -u
After
After writing code, test your implementation:
python ok -q 10
Once you've finished this problem, play a game that includes water. To access the wet_layout
which includes water, add the --water
option (or -w
for short) when you start the game.
python gui.py --water
# or
python ants_gui.py --water