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. If there is no bee available to eat, it will do nothing.

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 (default is 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.

Before

Before writing any code, read the instructions and test your understanding of the problem:

python ok -q 07 -u

After

After writing code, test your implementation:

python ok -q 07