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 writing any code, unlock the tests to verify your understanding of the question:
$ python ok -q 10 -u
Once you are done unlocking, begin implementing your solution. You can check your correctness with:
$ 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