rlcard.core

Game-related and Env-related base classes

class rlcard.core.Card(suit, rank)

Bases: object

Card stores the suit and rank of a single card

Note

The suit variable in a standard card game should be one of [S, H, D, C, BJ, RJ] meaning [Spades, Hearts, Diamonds, Clubs, Black Joker, Red Joker] Similarly the rank variable should be one of [A, 2, 3, 4, 5, 6, 7, 8, 9, T, J, Q, K]

get_index()

Get index of a card.

Returns

the combination of suit and rank of a card. Eg: 1S, 2H, AD, BJ, RJ…

Return type

string

rank = None
suit = None
valid_rank = ['A', '2', '3', '4', '5', '6', '7', '8', '9', 'T', 'J', 'Q', 'K']
valid_suit = ['S', 'H', 'D', 'C', 'BJ', 'RJ']
class rlcard.core.Dealer

Bases: object

Dealer stores a deck of playing cards, remained cards holded by dealer, and can deal cards to players

Note: deck variable means all the cards in a single game, and should be a list of Card objects.

deal_cards(**kwargs)

Deal specific number of cards to a specific player

Parameters
  • player_id – the id of the player to be dealt cards

  • num – number of cards to be dealt

deck = []
remained_cards = []
shuffle()

Shuffle the cards holded by dealer(remained_cards)

class rlcard.core.Game

Bases: object

Game class. This class will interact with outer environment.

get_action_num()

Return the number of possible actions in the game

get_player_id()

Return the current player that will take actions soon

get_player_num()

Retrun the number of players in the game

init_game()

Initialize all characters in the game and start round 1

is_over()

Return whether the current game is over

step(action)

Perform one draw of the game and return next player number, and the state for next player

step_back()

Takes one step backward and restore to the last state

class rlcard.core.Judger

Bases: object

Judger decides whether the round/game ends and return the winner of the round/game

judge_game(**kwargs)

Decide whether the game ends, and return the winner of the game

Returns

return the player’s id who wins the game or -1 meaning the game has not ended

Return type

int

judge_round(**kwargs)

Decide whether the round ends, and return the winner of the round

Returns

return the player’s id who wins the round or -1 meaning the round has not ended

Return type

int

class rlcard.core.Player(player_id)

Bases: object

Player stores cards in the player’s hand, and can determine the actions can be made according to the rules

available_order()

Get the actions can be made based on the rules

Returns

a list of available orders

Return type

list

hand = []
play()

Player’s actual action in the round

player_id = None
class rlcard.core.Round

Bases: object

Round stores the id the ongoing round and can call other Classes’ functions to keep the game running

proceed_round(**kwargs)

Call other Classes’s functions to keep the game running