def test_DriverInitializesWithGameState(self): agents = [FakeAgent(), FakeAgent()] game_state = setup.SinglePlayerEmptyGameState()._replace( player_states=[ setup.NewPlayerState(), setup.NewPlayerState()]) self.assertIsNotNone(driver.Driver( agents, game_state=game_state, game_rules=game_rules.GAME_RULES))
def test_DriverInitializesWithGameStateWrongNumAgentsFails(self): agents = [FakeAgent(), FakeAgent(), FakeAgent()] game_state = setup.SinglePlayerEmptyGameState()._replace( player_states=[ setup.NewPlayerState(), setup.NewPlayerState()]) with self.assertRaises(IndexError): driver.Driver( agents, game_state=game_state, game_rules=game_rules.GAME_RULES)
def test_DriverWinnerButNeedToCompleteRound(self): agents = [FakeAgent(), FakeAgent()] game_state = setup.SinglePlayerEmptyGameState()._replace( player_states=[ setup.NewPlayerState(), self._GetWinningPlayerState(), ], turn=1, ) game_driver = driver.Driver( agents, game_state=game_state, game_rules=game_rules.GAME_RULES) winners = game_driver.GetWinners() self.assertEquals(winners, tuple())
def test_DriverGetWinnersTie(self): agents = [FakeAgent(), FakeAgent()] game_state = setup.SinglePlayerEmptyGameState()._replace( player_states=[ self._GetWinningPlayerState(), self._GetWinningPlayerState(), ], turn=0, ) game_driver = driver.Driver( agents, game_state=game_state, game_rules=game_rules.GAME_RULES) winners = game_driver.GetWinners() self.assertEquals(winners, (0, 1))
def test_DriverGetWinnersWithTieBreak(self): agents = [FakeAgent(), FakeAgent()] game_state = setup.SinglePlayerEmptyGameState()._replace( player_states=[ self._GetWinningPlayerState(), setup.NewPlayerState()._replace( purchased_cards=[ setup.EmptyBlueDevelopmentCard()._replace(points=15), ]), ], turn=0, ) game_driver = driver.Driver( agents, game_state=game_state, game_rules=game_rules.GAME_RULES) winners = game_driver.GetWinners() self.assertEquals(winners, (1,))
def test_DriverInitializesWithWrongAgentTypeFails(self): agents = [None, None] with self.assertRaises(TypeError): driver.Driver(agents, gamebox=gamebox.GAMEBOX)
def test_DriverInitializesWithGameboxAndSeed(self): agents = [FakeAgent(), FakeAgent()] self.assertIsNotNone( driver.Driver(agents, gamebox=gamebox.GAMEBOX, random_seed=0))
def test_DriverInitializesWithGamebox(self): agents = [FakeAgent(), FakeAgent()] self.assertIsNotNone( driver.Driver(agents, gamebox=gamebox.GAMEBOX))