Exemplo n.º 1
0
    def play(self, pairing):
        blue_brain = self.brains[pairing[0]]
        red_brain = self.brains[pairing[1]]

        game = Game(blue_brain, red_brain, self.game_length, True)
        score = game.play()
        return score['blue'], score['red']
Exemplo n.º 2
0
 def test_save_recording(self):
     random.seed(1)
     game = Game(DefendersAndAttackers(),
                 BehindAndTowards(),
                 game_length=self.GAME_LENGTH,
                 record_game=True)
     score = game.play()
     game.save_game("test.csv")
Exemplo n.º 3
0
    def test_randomwalk_v_behindandtowards(self):
        random.seed(1)
        game = Game(RandomWalk(),
                    BehindAndTowards(),
                    game_length=self.GAME_LENGTH)

        while True:
            status = game.tick()
            if status == GameResult.end:
                break

        self.assertEqual(self.GAME_LENGTH, game.state.ticks)
Exemplo n.º 4
0
    def test_randomwalk_v_randomwalk(self):
        random.seed(1)
        game = Game(RandomWalk(), RandomWalk(), game_length=self.GAME_LENGTH)

        while True:
            status = game.tick()
            if status == GameResult.end:
                break

        self.assertEqual(self.GAME_LENGTH, game.state.ticks)
        self.assertEqual(0, game.score['blue'])
        self.assertEqual(0, game.score['red'])
Exemplo n.º 5
0
    def test_defendersandattackers_v_behindandtowards(self):
        random.seed(1)
        game = Game(DefendersAndAttackers(),
                    BehindAndTowards(),
                    game_length=self.GAME_LENGTH)

        while True:
            status = game.tick()
            if status == GameResult.end:
                break

        self.assertEqual(game.state.ticks, self.GAME_LENGTH)
        self.assertEqual(2, game.score['blue'])
        self.assertEqual(1, game.score['red'])
Exemplo n.º 6
0
    def test_recording_format(self):
        random.seed(1)
        game = Game(DefendersAndAttackers(),
                    BehindAndTowards(),
                    game_length=self.GAME_LENGTH,
                    record_game=True)

        score = game.play()

        self.assertTrue(game.move_df)

        expected_length = len(game.move_df["m_0_x"])

        for key in game.move_df:
            self.assertEqual(len(game.move_df[key]), expected_length,
                             "length of: " + key)
Exemplo n.º 7
0
 def test_if_recording_then_df_initialized(self):
     random.seed(1)
     game = Game(DefendersAndAttackers(),
                 BehindAndTowards(),
                 game_length=self.GAME_LENGTH,
                 record_game=True)
     self.assertTrue(game.move_df)