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
Before writing any code, read the instructions and test your understanding of the problem:
python ok -q 01 -u
After
After writing code, test your implementation:
python ok -q 01
Try playing the game by running python3 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.