Пример #1
0
 def test_apply_action_collide_with_ship(self):
     ship1 = Ship('1', Location(150, 100), 0, 8, 6)
     ship2 = Ship('2', Location(155, 100), 0, 8, 6)
     environment = Environment(300, 200, [ship1, ship2])
     action = Action(ship1.uid, 0, True)
     with self.assertRaises(Exception):
         environment.apply_action(action)
Пример #2
0
 def test_apply_action(self):
     ship = Ship('uid', Location(150, 100), 90, 8, 6)
     environment = Environment(300, 200, [ship])
     action = Action(ship.uid, 0, True)
     environment.apply_action(action)
     self.assertEqual(Location(150, 94),
                      ship.location)  # moved up 6 (the ship's speed)
Пример #3
0
 def test_apply_action_collide_with_right_wall(self):
     ship = Ship('uid', Location(295, 100), 0, 8, 6)
     environment = Environment(300, 200, [ship])
     action = Action(ship.uid, 0, True)
     with self.assertRaises(Exception):
         environment.apply_action(action)