コード例 #1
0
    def test_step(self):
        game = Game()

        # test raise
        game.init_game()
        init_raised = game.round.have_raised
        game.step('raise')
        step_raised = game.round.have_raised
        self.assertEqual(init_raised + 1, step_raised)

        # test fold
        game.init_game()
        game.step('fold')
        self.assertTrue(game.round.player_folded)

        # test call
        game.init_game()
        game.step('raise')
        game.step('call')
        self.assertEqual(game.round_counter, 1)

        # test check
        game.init_game()
        game.step('call')
        game.step('check')
        self.assertEqual(game.round_counter, 1)
コード例 #2
0
 def test_is_over(self):
     game = Game()
     game.init_game()
     game.step('call')
     game.step('check')
     game.step('check')
     game.step('check')
     self.assertEqual(game.is_over(), True)
コード例 #3
0
 def test_step_back(self):
     game = Game(allow_step_back=True)
     state, player_id = game.init_game()
     action = state['legal_actions'][0]
     game.step(action)
     game.step_back()
     self.assertEqual(game.game_pointer, player_id)
     self.assertEqual(game.step_back(), False)
コード例 #4
0
    def test_init_game(self):

        game = Game()
        state, player_id = game.init_game()
        test_id = game.get_player_id()
        self.assertEqual(test_id, player_id)
        self.assertIn('raise', state['legal_actions'])
        self.assertIn('fold', state['legal_actions'])
        self.assertIn('call', state['legal_actions'])
コード例 #5
0
    def __init__(self, config):
        ''' Initialize the Limitholdem environment
        '''
        self.game = Game()
        super().__init__(config)
        self.actions = ['call', 'raise', 'fold', 'check']
        self.state_shape = [49]

        with open(os.path.join(rlcard.__path__[0], 'games/leducholdem/card2index.json'), 'r') as file:
            self.card2index = json.load(file)
コード例 #6
0
    def __init__(self, allow_step_back=False):
        ''' Initialize the Limitholdem environment
        '''
        super().__init__(Game(allow_step_back), allow_step_back)
        self.actions = ['call', 'raise', 'fold', 'check']
        self.state_shape = [6]

        with open(
                os.path.join(rlcard.__path__[0],
                             'games/leducholdem/card2index.json'),
                'r') as file:
            self.card2index = json.load(file)
コード例 #7
0
 def test_get_action_num(self):
     game = Game()
     action_num = game.get_action_num()
     self.assertEqual(action_num, 4)