rlcard.games.limitholdem

rlcard.games.limitholdem.dealer

class rlcard.games.limitholdem.dealer.LimitholdemDealer

Bases: object

deal_card()

Deal one card from the deck

Returns

The drawn card from the deck

Return type

(Card)

shuffle()

Shuffle the deck

rlcard.games.limitholdem.game

class rlcard.games.limitholdem.game.LimitholdemGame(allow_step_back=False)

Bases: object

static get_action_num()

Return the number of applicable actions

Returns

The number of actions. There are 4 actions (call, raise, check and fold)

Return type

(int)

Return the legal actions for current player

Returns

A list of legal actions

Return type

(list)

get_payoffs()

Return the payoffs of the game

Returns

Each entry corresponds to the payoff of one player

Return type

(list)

get_player_id()

Return the current player’s id

Returns

current player’s id

Return type

(int)

get_player_num()

Return the number of players in Limit Texas Hold’em

Returns

The number of players in the game

Return type

(int)

get_state(player)

Return player’s state

Parameters

player_id (int) – player id

Returns

The state of the player

Return type

(dict)

init_game()

Initialilze the game of Limit Texas Hold’em

This version supports two-player limit texas hold’em

Returns

Tuple containing:

(dict): The first state of the game (int): Current player’s id

Return type

(tuple)

is_over()

Check if the game is over

Returns

True if the game is over

Return type

(boolean)

step(action)

Get the next state

Parameters

action (str) – a specific action. (call, raise, fold, or check)

Returns

Tuple containing:

(dict): next player’s state (int): next plater’s id

Return type

(tuple)

step_back()

Return to the previous state of the game

Returns

True if the game steps back successfully

Return type

(bool)

rlcard.games.limitholdem.judger

class rlcard.games.limitholdem.judger.LimitholdemJudger

Bases: object

The Judger class for Texas Hold’em

static judge_game(players, hands)

Judge the winner of the game.

Parameters
  • players (list) – The list of players who play the game

  • hands (list) – The list of hands that from the players

Returns

Each entry of the list corresponds to one entry of the

Return type

(list)

rlcard.games.limitholdem.player

class rlcard.games.limitholdem.player.LimitholdemPlayer(player_id)

Bases: object

get_player_id()

Return the id of the player

get_state(public_cards, all_chips, legal_actions)

Encode the state for the player

Parameters
  • public_cards (list) – A list of public cards that seen by all the players

  • all_chips (int) – The chips that all players have put in

Returns

The state of the player

Return type

(dict)

rlcard.games.limitholdem.round

Implement Limit Texas Hold’em Round class

class rlcard.games.limitholdem.round.LimitholdemRound(raise_amount, allowed_raise_num, num_players)

Bases: object

Round can call other Classes’ functions to keep the game running

Obtain the legal actions for the curent player

Returns

A list of legal actions

Return type

(list)

is_over()

Check whether the round is over

Returns

True if the current round is over

Return type

(boolean)

proceed_round(players, action)

Call other Classes’s functions to keep one round running

Parameters
  • players (list) – The list of players that play the game

  • action (str) – An legal action taken by the player

Returns

The game_pointer that indicates the next player

Return type

(int)

start_new_round(game_pointer, raised=None)

Start a new bidding round

Parameters

raised (list) – Initialize the chips for each player

Note: For the first round of the game, we need to setup the big/small blind

rlcard.games.limitholdem.utils

class rlcard.games.limitholdem.utils.Hand(all_cards)

Bases: object

evaluateHand()

Evaluate all the seven cards, get the best combination catagory And pick the best five cards (for comparing in case 2 hands have the same Category) .

get_hand_five_cards()

Get the best five cards of a player :returns: the best five cards among the seven cards of a player :rtype: (list)

rlcard.games.limitholdem.utils.compare_hands(hand0, hand1)

Compare two palyer’s all seven cards :param hand0: all the seven cards of player0 :type hand0: list :param hand1: all the seven cards of player1 :type hand1: list

Returns

player1 wins [1, 0]: player0 wins [1, 1]: draw

Return type

[0, 1]

rlcard.games.limitholdem.utils.compare_ranks(position, handcard0, handcard1)

Compare cards in same position of plays’ five handcards :param position: the position of a card in a sorted handcard :type position: int :param handcard0: five best cards of player0 :type handcard0: list :param handcard1: five best cards of player1 :type handcard1: list

Returns

player1 wins [1, 0]: player0 wins [1, 1]: draw

Return type

[0, 1]

rlcard.games.limitholdem.utils.determine_winner(key_index, hand0_5_cards, hand1_5_cards)

Determine who wins :param key_index: the position of a card in a sorted handcard :type key_index: int :param hand0_5_cards: five best cards of player0 :type hand0_5_cards: list :param hand0_5_cards: five best cards of player1 :type hand0_5_cards: list

Returns

player1 wins [1, 0]: player0 wins [1, 1]: draw

Return type

[0, 1]