class TestGame(unittest.TestCase): def setUp(self): self.game = Game((BaseBot, BaseBot)) self.game.initialize_game() def test_manual_round_progress(self): for i in range(10): round = self.game.get_round() self.game.process_round() self.assertEqual(round + 1, self.game.get_round()) def test_get_current_player(self): for i in range(len(self.game.players)): self.game.turn = i self.assertEqual(self.game.players[i], self.game.get_current_player()) def test_get_other_players(self): for i in range(len(self.game.players)): self.game.turn = i self.assertNotIn(self.game.players[i], self.game.get_other_players()) def test_get_player_count(self): self.assertEqual(len(self.game.players), self.game.get_player_count())
from dominion.bots.logic import MoneyLogicBot, SmithyLogicBot, SmithyLabLogicBot, RandomLogicBot from dominion.cards import ( Market, Village, Moat, Woodcutter, Workshop, Bureaucrat, Gardens, Smithy, Festival, Laboratory, ) COMPARE_CARDS = ( Market, Village, Moat, Woodcutter, Workshop, Bureaucrat, Gardens, Smithy, Festival, Laboratory, ) #game = Game((SimpleBuyStrategy, RandomActionStrategy)) #game = Game((RandomActionStrategy, RandomActionStrategy)) #game = Game((SimpleBuyStrategy, RandomActionStrategy, MoneyLogicBot, SmithyLogicBot)) game = Game((MoneyLogicBot, SmithyLogicBot, SmithyLabLogicBot), action_cards=COMPARE_CARDS) if __name__ == '__main__': wins = defaultdict(int) game.initialize_game() assert Smithy in game.supply assert Laboratory in game.supply #game.process_game() for i in xrange(1000000): game.process_game() wins[type(game.winner).__name__] += 1 game.reset_game() if not i % 10000: pprint(wins) pprint(wins)