Problem 1 (150pts): Ants Need Food
Part A:
Currently, there is no cost for placing any type of Ant
, and so there is no challenge to the game.
The base class Ant
has a food_cost
of zero.
Override this class attribute for HarvesterAnt
and ThrowerAnt
according to the "Food Cost" column in the table below.
Class | Food Cost | Health | |
---|---|---|---|
![]() | HarvesterAnt | 2 | 1 |
![]() | ThrowerAnt | 3 | 1 |
Part B:
Now that deploying cost food of Ant
, we need to be able to gather more food!
To fix this issue, implement the HarvesterAnt
class.
A HarvesterAnt
is a subclass of Ant
that adds one food to the gamestate.food
total in its action
.
Before writing any code, unlock the tests to verify your understanding of the question:
$ python ok -q 01 -u
Once you are done unlocking, begin implementing your solution. You can check your correctness with:
$ python ok -q 01
Try playing the game by running python gui.py
.
Once you have placed a HarvesterAnt
, you should accumulate food each turn.
You can also place ThrowerAnt
s, but you'll see that they can only attack bees that are in their Place
, making it a little difficult to win.