Exemplo n.º 1
0
 def test_step_back(self):
     game = Game(allow_step_back=True)
     _, player_id = game.init_game()
     action = np.random.choice(game.get_legal_actions())
     game.step(action)
     game.step_back()
     self.assertEqual(game.round.current_player, player_id)
     self.assertEqual(len(game.history), 0)
     success = game.step_back()
     self.assertEqual(success, False)
Exemplo n.º 2
0
 def test_step(self):
     game = Game()
     game.init_game()
     action = np.random.choice(game.get_legal_actions())
     state, next_player_id = game.step(action)
     current = game.round.current_player
     self.assertLessEqual(len(state['played_cards']), 2)
     self.assertEqual(next_player_id, current)
Exemplo n.º 3
0
 def test_get_payoffs(self):
     game = Game()
     game.init_game()
     while not game.is_over():
         actions = game.get_legal_actions()
         action = np.random.choice(actions)
         state, _ = game.step(action)
     payoffs = game.get_payoffs()
     total = 0
     for payoff in payoffs:
         total += payoff
     self.assertEqual(total, 0)
Exemplo n.º 4
0
 def test_get_payoffs(self):
     game = Game()
     game.init_game()
     while not game.is_over():
         actions = game.get_legal_actions()
         action = np.random.choice(actions)
         state, _ = game.step(action)
         total_cards = len(state['hand']) + len(state['others_hand']) + len(
             state['played_cards']) + len(game.round.dealer.deck)
         self.assertEqual(total_cards, 108)
     payoffs = game.get_payoffs()
     total = 0
     for payoff in payoffs:
         total += payoff
     self.assertEqual(total, 0)