Commit 057c71f6 authored by nschroeder1771's avatar nschroeder1771
Browse files

Added the rest of the doctests, however, there are failures. Need to figure...

Added the rest of the doctests, however, there are failures. Need to figure out why ant is not consuming ammo.
parent d20796c2
......@@ -435,31 +435,90 @@ class Thrower(Ant):
"""
If there is a Bee approaching this Ant, and it is in-range, consume one unit of ammo to throw a leaf at that bee
and reduce its health:
>>> place = ColonyPlace(1, 0)
>>> next_place = ColonyPlace(0, 0)
>>> place.connect_to(next_place)
>>> state = GameState(places=[place, next_place], queen_place=None, ant_archetypes=[], food=0)
>>> ant_place = ColonyPlace(1, 0)
>>> bee_place = ColonyPlace(0, 0)
>>> ant_place.connect_to(bee_place)
>>> state = GameState(places=[ant_place, bee_place], queen_place=None, ant_archetypes=[], food=0)
>>> ant = Thrower(unit_type=None, food_cost=0, health=5, damage=1, ammo= 4, minimum_range=0, maximum_range=2)
>>> place.add_insect(ant)
>>> bee = Bee(health=1, damage=1, delay=0)
>>> place.add_insect(bee)
>>> ant_place.add_insect(ant)
>>> bee = Bee(health=4, damage=1, delay=0)
>>> bee_place.add_insect(bee)
>>> ant.act(state)
>>> bee.act(state)
>>> bee.health
0
3
>>> ant.ammo
3
But ignore any Bee that is out of range:
>>> # Placeholder
>>> ant_place = ColonyPlace(1, 0)
>>> bee_place = ColonyPlace(5, 0)
>>> ant_place.connect_to(bee_place)
>>> state = GameState(places=[ant_place, bee_place], queen_place=None, ant_archetypes=[], food=0)
>>> ant = Thrower(unit_type=None, food_cost=0, health=5, damage=1, ammo= 4, minimum_range=0, maximum_range=2)
>>> ant_place.add_insect(ant)
>>> bee = Bee(health=4, damage=1, delay=0)
>>> bee_place.add_insect(bee)
>>> ant.act(state)
>>> bee.act(state)
>>> bee.health
4
>>> ant.ammo
4
or that has already flown past this Ant:
>>> # Placeholder
>>> ant_place = ColonyPlace(2, 0)
>>> bee_place = ColonyPlace(1, 0)
>>> ant_place.connect_to(bee_place)
>>> state = GameState(places=[ant_place, bee_place], queen_place=None, ant_archetypes=[], food=0)
>>> ant = Thrower(unit_type=None, food_cost=0, health=5, damage=1, ammo= 4, minimum_range=0, maximum_range=2)
>>> ant_place.add_insect(ant)
>>> bee = Bee(health=4, damage=1, delay=0)
>>> bee_place.add_insect(bee)
>>> ant.act(state)
>>> bee.act(state)
>>> bee.health
4
>>> ant.ammo
4
If there are multiple in-range bees approaching, target the one that is nearest:
>>> # Placeholder
>>> ant_place = ColonyPlace(1, 0)
>>> bee1_place = ColonyPlace(0, 0)
>>> bee2_place = ColonyPlace(6, 7)
>>> ant_place.connect_to(bee_place)
>>> state = GameState(places=[ant_place, bee_place], queen_place=None, ant_archetypes=[], food=0)
>>> ant = Thrower(unit_type=None, food_cost=0, health=5, damage=1, ammo= 4, minimum_range=0, maximum_range=2)
>>> ant_place.add_insect(ant)
>>> bee1 = Bee(health=4, damage=1, delay=0)
>>> bee2 = Bee(health=4, damage=1, delay=0)
>>> bee1_place.add_insect(bee1)
>>> bee2_place.add_insect(bee2)
>>> ant.act(state)
>>> bee1.act(state)
>>> bee2.act(state)
>>> bee1.health
3
>>> bee2.health
4
>>> ant.ammo
3
And when all of its ammo is consumed, kill the ant:
>>> # Placeholder
>>> ant_place = ColonyPlace(2, 0)
>>> bee_place = ColonyPlace(1, 0)
>>> ant_place.connect_to(bee_place)
>>> state = GameState(places=[ant_place, bee_place], queen_place=None, ant_archetypes=[], food=0)
>>> ant = Thrower(unit_type=None, food_cost=0, health=5, damage=1, ammo= 1, minimum_range=0, maximum_range=2)
>>> ant_place.add_insect(ant)
>>> bee = Bee(health=4, damage=1, delay=0)
>>> bee_place.add_insect(bee)
>>> ant.act(state)
>>> bee.act(state)
>>> ant.health
0
>>> ant.ammo
0
"""
target_bee = self._target_bee
if target_bee is not None:
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment