Пример #1
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)
Пример #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")
Пример #3
0
    def setUpClass(cls):
        cls.round_robin_tourney = Tournament([
            BehindAndTowards("anne"),
            DefendersAndAttackers("bob"),
            RandomWalk("charlie")
        ],
                                             game_length=1000,
                                             rounds=0)
        cls.round_robin_tourney.start()

        swiss_brains = []
        for i in range(6):
            swiss_brains.append(BehindAndTowards("BAT-" + str(i)))

        for i in range(6):
            swiss_brains.append(DefendersAndAttackers("DAA-" + str(i)))

        for i in range(6):
            swiss_brains.append(RandomWalk("RW-" + str(i)))

        cls.swiss_tourney = Tournament(swiss_brains, game_length=500, rounds=3)
        cls.swiss_tourney.start()
Пример #4
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'])
Пример #5
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)
Пример #6
0
from aisoccer.brains.BehindAndTowards import BehindAndTowards
from aisoccer.brains.DefendersAndAttackers import DefendersAndAttackers
from aisoccer.brains.RandomWalk import RandomWalk
from aisoccer.tournament import *

brains = []
for i in range(6):
    brains.append(BehindAndTowards("BAT-" + str(i)))

for i in range(6):
    brains.append(DefendersAndAttackers("DAA-" + str(i)))

for i in range(6):
    brains.append(RandomWalk("RAND-" + str(i)))

tourney = Tournament(brains, game_length=1000, rounds=9)
tourney.start()