Skip to content

Commit

Permalink
Merge and solve conflicts with init chips
Browse files Browse the repository at this point in the history
Former-commit-id: c33cd6f
  • Loading branch information
aypee19 committed Jan 12, 2021
2 parents e6baa6e + 44bdef7 commit 166db9d
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion rlcard/envs/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def __init__(self, config):
self.action_recorder = []

# Game specific configurations
# Currently only support blackjack
# Currently only support blackjack、limit-holdem、no-limit-holdem
# TODO support game configurations for all the games
supported_envs = ['blackjack', 'limit-holdem', 'no-limit-holdem']
if self.name in supported_envs:
Expand Down
2 changes: 1 addition & 1 deletion rlcard/envs/nolimitholdem.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

DEFAULT_GAME_CONFIG = {
'game_player_num': 2,
'init_chips': 100,
'chips_for_each': [100]*2,
}

class NolimitholdemEnv(Env):
Expand Down
6 changes: 2 additions & 4 deletions rlcard/games/nolimitholdem/game.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,7 @@ def configure(self, game_config):
''' Specifiy some game specific parameters, such as player number and initial chips
'''
self.num_players = game_config['game_player_num']
self.init_chips = game_config['init_chips']
if isinstance(self.init_chips, int):
self.init_chips = [self.init_chips] * self.num_players
self.init_chips = game_config['chips_for_each']

def init_game(self):
''' Initialilze the game of Limit Texas Hold'em
Expand All @@ -59,7 +57,7 @@ def init_game(self):
# Initilize a dealer that can deal cards
self.dealer = Dealer(self.np_random)

# Initilize two players to play the game
# Initilize players to play the game
self.players = [Player(i, self.init_chips[i], self.np_random) for i in range(self.num_players)]

# Initialize a judger class which will decide who wins in the end
Expand Down
9 changes: 9 additions & 0 deletions tests/envs/test_nolimitholdem_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,5 +78,14 @@ def test_multiplayers(self):
player_num = env.game.get_player_num()
self.assertEqual(player_num, 5)

def test_config_chips(self):
env = rlcard.make('no-limit-holdem', config={'game_player_num':5, 'chips_for_each':[100, 200, 400, 600, 900]})
env.game.init_game()
players = env.game.players
chips = []
for i in range(5):
chips.append(players[i].remained_chips + players[i].in_chips)
self.assertEqual(chips, [100, 200, 400, 600, 900])

if __name__ == '__main__':
unittest.main()

0 comments on commit 166db9d

Please sign in to comment.