CS考试辅导 ‘name’: ‘Problem 9’,

‘name’: ‘Problem 9’,
‘points’: 3,
‘suites’: [
‘cases’: [

Copyright By PowCoder代写 加微信 powcoder

‘answer’: ‘57340058c74192e31e9088794d23e3c0’,
‘choices’: [
‘A TankAnt does damage to all Bees in its place each turn’,
‘A TankAnt has greater health than a BodyguardAnt’,
‘A TankAnt can contain multiple ants’,
‘A TankAnt increases the damage of the ant it contains’
‘hidden’: False,
‘locked’: True,
‘multiline’: False,
‘question’: r”””
Besides costing more to place, what is the only difference between a
TankAnt and a BodyguardAnt?
‘scored’: False,
‘type’: ‘concept’
‘cases’: [
‘code’: r”””
>>> # Testing TankAnt parameters
>>> TankAnt.food_cost
1417936d6fc6e9b3ac66b50e5d407ada
>>> TankAnt.damage
10d7626438082950badf2b6216f9b0a8
>>> tank = TankAnt()
>>> tank.health
1218df75a941ebc08cec539b1f16208f
‘hidden’: False,
‘locked’: True,
‘multiline’: False
‘code’: r”””
>>> # Testing TankAnt action
>>> tank = TankAnt()
>>> place = gamestate.places[‘tunnel_0_1’]
>>> other_place = gamestate.places[‘tunnel_0_2’]
>>> place.add_insect(tank)
>>> for _ in range(3):
… place.add_insect(Bee(3))
>>> other_place.add_insect(Bee(3))
>>> tank.action(gamestate)
>>> [bee.health for bee in place.bees]
>>> [bee.health for bee in other_place.bees]
‘hidden’: False,
‘locked’: False,
‘multiline’: False
‘code’: r”””
>>> # Testing TankAnt container methods
>>> tank = TankAnt()
>>> thrower = ThrowerAnt()
>>> place = gamestate.places[‘tunnel_0_1’]
>>> place.add_insect(thrower)
>>> place.add_insect(tank)
>>> place.ant is tank
>>> bee = Bee(3)
>>> place.add_insect(bee)
>>> tank.action(gamestate) # Both ants attack bee
>>> bee.health
‘hidden’: False,
‘locked’: False,
‘multiline’: False
‘scored’: True,
‘setup’: r”””
>>> from ants_plans import *
>>> from ants import *
>>> beehive, layout = Hive(make_test_assault_plan()), dry_layout
>>> dimensions = (1, 9)
>>> gamestate = GameState(None, beehive, ant_types(), layout, dimensions)
‘teardown’: ”,
‘type’: ‘doctest’
‘cases’: [
‘code’: r”””
>>> # Testing TankAnt action
>>> tank = TankAnt()
>>> place = gamestate.places[‘tunnel_0_1’]
>>> place.add_insect(tank)
>>> for _ in range(3): # Add three bees with 1 health each
… place.add_insect(Bee(1))
>>> tank.action(gamestate)
>>> len(place.bees) # Bees removed from places because of TankAnt damage
‘hidden’: False,
‘locked’: False,
‘multiline’: False
‘code’: r”””
>>> # Testing TankAnt.damage
>>> tank = TankAnt()
>>> tank.damage = 100
>>> place = gamestate.places[‘tunnel_0_1’]
>>> place.add_insect(tank)
>>> for _ in range(3):
… place.add_insect(Bee(100))
>>> tank.action(gamestate)
>>> len(place.bees)
‘hidden’: False,
‘locked’: False,
‘multiline’: False
‘code’: r”””
>>> # Placement of ants
>>> tank = TankAnt()
>>> harvester = HarvesterAnt()
>>> place = gamestate.places[‘tunnel_0_0’]
>>> # Add tank before harvester
>>> place.add_insect(tank)
>>> place.add_insect(harvester)
>>> gamestate.food = 0
>>> tank.action(gamestate)
>>> gamestate.food
… place.add_insect(TankAnt())
… except AssertionError:
… print(“error!”)
>>> place.ant is tank
>>> tank.ant_contained is harvester
… place.add_insect(HarvesterAnt())
… except AssertionError:
… print(“error!”)
>>> place.ant is tank
>>> tank.ant_contained is harvester
‘hidden’: False,
‘locked’: False,
‘multiline’: False
‘code’: r”””
>>> # Placement of ants
>>> tank = TankAnt()
>>> harvester = HarvesterAnt()
>>> place = gamestate.places[‘tunnel_0_0’]
>>> # Add harvester before tank
>>> place.add_insect(harvester)
>>> place.add_insect(tank)
>>> gamestate.food = 0
>>> tank.action(gamestate)
>>> gamestate.food
… place.add_insect(TankAnt())
… except AssertionError:
… print(“error!”)
>>> place.ant is tank
>>> tank.ant_contained is harvester
… place.add_insect(HarvesterAnt())
… except AssertionError:
… print(“error!”)
>>> place.ant is tank
>>> tank.ant_contained is harvester
‘hidden’: False,
‘locked’: False,
‘multiline’: False
‘code’: r”””
>>> # Removing ants
>>> tank = TankAnt()
>>> test_ant = Ant()
>>> place = Place(‘Test’)
>>> place.add_insect(tank)
>>> place.add_insect(test_ant)
>>> place.remove_insect(test_ant)
>>> tank.ant_contained is None
>>> test_ant.place is None
>>> place.remove_insect(tank)
>>> place.ant is None
>>> tank.place is None
‘hidden’: False,
‘locked’: False,
‘multiline’: False
‘code’: r”””
>>> tank = TankAnt()
>>> place = Place(‘Test’)
>>> place.add_insect(tank)
>>> tank.action(gamestate) # Action without ant_contained should not error
‘hidden’: False,
‘locked’: False,
‘multiline’: False
‘code’: r”””
>>> # test proper call to death callback
>>> original_death_callback = Insect.death_callback
>>> Insect.death_callback = lambda x: print(“insect died”)
>>> place = gamestate.places[“tunnel_0_0″]
>>> bee = Bee(3)
>>> tank = TankAnt()
>>> ant = ThrowerAnt()
>>> place.add_insect(bee)
>>> place.add_insect(ant)
>>> place.add_insect(tank)
>>> bee.action(gamestate)
>>> bee.action(gamestate)
insect died
>>> bee.action(gamestate) # if you fail this test you probably didn’t correctly call Ant.reduce_health or Insect.reduce_health
insect died
>>> Insect.death_callback = original_death_callback
‘hidden’: False,
‘locked’: False,
‘multiline’: False
‘scored’: True,
‘setup’: r”””
>>> from ants_plans import *
>>> from ants import *
>>> beehive, layout = Hive(make_test_assault_plan()), dry_layout
>>> dimensions = (1, 9)
>>> gamestate = GameState(None, beehive, ant_types(), layout, dimensions)
‘teardown’: ”,
‘type’: ‘doctest’
‘cases’: [
‘code’: r”””
>>> from ants import *
>>> TankAnt.implemented
‘hidden’: False,
‘locked’: False,
‘multiline’: False
‘code’: r”””
>>> from ants import *
>>> # Abstraction tests
>>> original = Ant.__init__
>>> Ant.__init__ = lambda self, health: print(“init”) #If this errors, you are not calling the parent constructor correctly.
>>> tank = TankAnt()
>>> Ant.__init__ = original
>>> tank = TankAnt()
‘hidden’: False,
‘locked’: False,
‘multiline’: False
‘scored’: True,
‘setup’: ”,
‘teardown’: ”,
‘type’: ‘doctest’

程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com