コード例 #1
0
def run(options):
  random.seed(options.random_seed)
  world_map = terrain.TerrainMap(terrain.read_map(options.map), options.map)
  robots = robot_module.load_robots(options.robots, world_map)
  history = play_history.PlayHistory()
  master.Master(options, robots, world_map, history).run()
  return history, world_map
コード例 #2
0
ファイル: test_terrain.py プロジェクト: mgainer/robotwar
 def test_two_plains(self):
     world = terrain.TerrainMap('  ', 'fred')
     self.assertEqual(world.width, 4)
     self.assertEqual(world.height, 3)
     self._assertWallBorder(world)
     self.assertEqual(world.get_xy(1, 1), terrain.PLAINS)
     self.assertEqual(world.get_xy(2, 1), terrain.PLAINS)
コード例 #3
0
ファイル: test_terrain.py プロジェクト: mgainer/robotwar
 def test_right_padding(self):
     world = terrain.TerrainMap('  \n' ' \n', 'fred')
     self.assertEqual(world.width, 4)
     self.assertEqual(world.height, 4)
     self._assertWallBorder(world)
     self.assertEqual(world.get_xy(1, 1), terrain.PLAINS)
     self.assertEqual(world.get_xy(2, 1), terrain.PLAINS)
     self.assertEqual(world.get_xy(1, 2), terrain.PLAINS)
     self.assertEqual(world.get_xy(2, 2), terrain.WALL)
コード例 #4
0
 def setUp(self):
     # Pre-set random seed to get robot #0 at 1,1, and #1 at 1,2.  This makes
     # it simpler to set up shot directions.
     random.seed(1)
     self._options = robotwar.parse_options([])
     self._history = play_history.PlayHistory()
     self._world_map = terrain.TerrainMap('  ', '')
     self._r0 = robot_module.Robot(0, self._world_map)
     self._game = master.Master(self._options, [self._r0], self._world_map,
                                self._history)
     self._round = self._game._prepare_round()
コード例 #5
0
 def test_two_spaces_two_robots(self):
     world_map = terrain.TerrainMap('  ', '')
     r0 = robot_module.Robot(0, world_map)
     r1 = robot_module.Robot(1, world_map)
     game = master.Master(self._options, [r0, r1], world_map, self._history)
コード例 #6
0
 def test_one_space_two_robots(self):
     world_map = terrain.TerrainMap(' ', '')
     r = robot_module.Robot(0, world_map)
     with self.assertRaises(RuntimeError):
         game = master.Master(self._options, [r, r], world_map,
                              self._history)
コード例 #7
0
 def test_one_space_one_robot(self):
     world_map = terrain.TerrainMap(' ', '')
     r = robot_module.Robot(0, world_map)
     game = master.Master(self._options, [r], world_map, self._history)
     self.assertEquals(game._robot_data[r].position,
                       position.Position(1, 1))
コード例 #8
0
 def test_impossible(self):
     world_map = terrain.TerrainMap('', '')
     r = robot_module.Robot(0, world_map)
     with self.assertRaises(ValueError):
         game = master.Master(self._options, [r], world_map, self._history)
コード例 #9
0
 def setUp(self):
     self._world_map = terrain.TerrainMap(' ', 'fred')
コード例 #10
0
ファイル: test_terrain.py プロジェクト: mgainer/robotwar
 def test_illegal_terrain(self):
     with self.assertRaises(RuntimeError):
         terrain.TerrainMap('Q', 'fred')
コード例 #11
0
ファイル: test_terrain.py プロジェクト: mgainer/robotwar
 def test_blank(self):
     world = terrain.TerrainMap('', 'fred')
     self.assertEqual(world.width, 2)
     self.assertEqual(world.height, 2)
     self._assertWallBorder(world)