예제 #1
0
 def test_get_state(self):
     game = Game()
     game.configure(DEFAULT_GAME_CONFIG)
     game.init_game()
     self.assertEqual(len(game.get_state(0)['state'][1]), 1)
     game.step('stand')
     self.assertGreater(len(game.get_state(0)['state'][1]), 1)
예제 #2
0
 def test_step_back(self):
     game = Game()
     state, _ = game.init_game()
     init_hand = state['state'][0]
     game.step('hit')
     game.step_back()
     test_hand = game.get_state(0)['state'][0]
     self.assertEqual(init_hand, test_hand)
     self.assertEqual(len(game.history), 0)
예제 #3
0
 def test_step_back(self):
     game = Game(allow_step_back=True)
     game.configure(DEFAULT_GAME_CONFIG)
     state, _ = game.init_game()
     init_hand = state['state'][0]
     game.step('hit')
     game.step_back()
     test_hand = game.get_state(0)['state'][0]
     self.assertEqual(init_hand, test_hand)
     self.assertEqual(len(game.history), 0)
     success = game.step_back()
     self.assertEqual(success, False)
예제 #4
0
 def test_step(self):
     game = Game()
     game.configure(DEFAULT_GAME_CONFIG)
     game.init_game()
     next_state, next_player = game.step('hit')
     self.assertEqual(next_player, 0)
     if game.players[0].status != 'bust':
         self.assertEqual(len(game.dealer.hand), len(next_state['state'][1])+1)
     else:
         self.assertEqual(len(game.dealer.hand), len(next_state['state'][1]))
     next_state, _ = game.step('stand')
     self.assertEqual(len(next_state['state'][0]), len(game.players[0].hand))
예제 #5
0
 def test_proceed_game(self):
     game = Game()
     game.init_game()
     while not game.is_over():
         action = np.random.choice(['hit', 'action'])
         state, _ = game.step(action)
     self.assertEqual(len(state['state'][1]), len(game.dealer.hand))
예제 #6
0
 def test_get_state(self):
     game = Game()
     game.init_game()
     self.assertEqual(len(game.get_state(0)['state'][1]), 1)
     game.step('stand')
     self.assertGreater(len(game.get_state(0)['state'][1]), 1)