class GameModulesIntegrationTests(unittest.TestCase):
    def setUp(self):
        signature = GameSignature()
        players = [Player(command_line) for command_line in BOTS]
        generator = config.Generator()
        start_states = list(generator.generate_start_positions(signature,
                                                               players))
        start_state = random.choice(start_states)
        self._simulator = GameSimulator(players, start_state, signature)

    def test_that_game_is_finished(self):
        controller = self._simulator.play()
        self.assertTrue(controller.is_finished)

    def test_that_scores_exists_for_each_player(self):
        controller = self._simulator.play()
        scores = controller.get_scores()
        players = self._simulator.get_players()
        self.assertEqual(set(scores.keys()), set(players))
示例#2
0
文件: game.py 项目: dimatomp/play
 def run_engine(self):
     '''launches the engine'''
     logger.info('running game #%d', self.game_info.game_id)
     logger.info('launching engine')
     game_engine = GameSimulator(self.players, self.jury_state,
                                 self.game_info)
     logger.info('starting game')
     self.game_controller = game_engine.play()
     logger.info('writing logs')
     logger.info('game #%d finished', self.game_info.game_id)
     self._write_logs()
示例#3
0
def play(args):
    from game_simulator import GameSimulator
    from tournament_stages.game_signature import GameSignature
    from bot import ExecuteError

    players = list(create_players(args.bot_commands_file))
    signature = GameSignature(1, 1, 1, 1)
    jury_state = next(get_js(len(players)))
    copied_js = copy.deepcopy(jury_state)
    game = GameSimulator(players, copied_js, signature)
    try:
        game_controller = game.play()
        return game_controller
    except ExecuteError:
        pass