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
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()
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)
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)
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))
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)