Optional Problem 1: Ninja

The staff will prioritize helping students with required questions. TAs will not offer helps for this question (but senior students may).

Implement the NinjaAnt, which damages all Bees that pass by, but can never be stung.

ClassFood CostHealth
Ninja51

A NinjaAnt does not block the path of a Bee that flies by. To implement this behavior, first modify the Ant class to include a new class attribute blocks_path that is True by default. Set the value of blocks_path to False in the NinjaAnt class.

Second, modify the Bee's method blocked to return False if either there is no Ant in the Bee's place or if there is an Ant, but its blocks_path attribute is False. Now Bees will just fly past NinjaAnts.

Finally, we want to make the NinjaAnt damage all Bees that fly past. Implement the action method in NinjaAnt to reduce the armor of all Bees in the same place as the NinjaAnt by its damage attribute. Similar to the FireAnt, you must iterate over a list of bees that may change.

Hint: Having trouble visualizing the test cases? Try drawing them out on paper! See the example in Game Layout for help.

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

$ python ok -q optional1 -u

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

$ python ok -q optional1

For a challenge, try to win a game using only HarvesterAnt and NinjaAnt.