Beispiel #1
0
 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))
Beispiel #2
0
 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)
Beispiel #3
0
 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())
Beispiel #4
0
 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))
Beispiel #5
0
 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,))
Beispiel #6
0
 def test_DriverInitializesWithWrongAgentTypeFails(self):
   agents = [None, None]
   with self.assertRaises(TypeError):
     driver.Driver(agents, gamebox=gamebox.GAMEBOX)
Beispiel #7
0
 def test_DriverInitializesWithGameboxAndSeed(self):
   agents = [FakeAgent(), FakeAgent()]
   self.assertIsNotNone(
     driver.Driver(agents, gamebox=gamebox.GAMEBOX,
             random_seed=0))
Beispiel #8
0
 def test_DriverInitializesWithGamebox(self):
   agents = [FakeAgent(), FakeAgent()]
   self.assertIsNotNone(
     driver.Driver(agents, gamebox=gamebox.GAMEBOX))