Problem 7 (250pts): Hungry Ant

Implement the HungryAnt, which will select a random Bee from its place and eat it whole. After eating a Bee, it must spend 3 turns chewing before eating again. While the HungryAnt is chewing, it is not able to eat (deal damage to) any Bees. After 3 turns, if there is no bee available to eat, the HungryAnt will do nothing.

We have not provided you with a class header. Implement the HungryAnt class from scratch. Give it a class attribute name with the value 'Hungry' (so that the graphics work) and a class attribute implemented with the value True (so that you can use it in a game).

Hint: When a Bee is eaten, it should lose all its health. Is there an existing function we can call on a Bee that can reduce its health to 0?

ClassFood CostHealth
HungryAnt41

Give HungryAnt a chew_duration class attribute that holds the number of turns that it takes a HungryAnt to chew (default to 3). Also, give each HungryAnt an instance attribute chew_countdown that counts the number of turns it has left to chew (initialized to 0, since it hasn't eaten anything at the beginning).

Implement the action method of the HungryAnt to check if it is chewing; if so, decrement its chew_countdown counter. Otherwise, eat a random Bee in its place by reducing the Bee's health to 0 and restart the chew_countdown timer.

Hint: Other than the action method, make sure you implement the __init__ method too in order to define any instance variables and make sure that HungryAnt starts off with the appropriate amount of health!

Before writing any code, unlock the tests to verify your understanding of the question:

$ python ok -q 07 -u

Once you are done unlocking, begin implementing your solution. You can check your correctness with:

$ python ok -q 07

We now have some great offensive troops to help vanquish the bees, but let's make sure we're also keeping our defensive efforts up. In this phase you will implement ants that have special defensive capabilities such as increased health and the ability to protect other ants.