rlcard.games.gin_rummy

rlcard.games.gin_rummy.dealer

File name: gin_rummy/dealer.py Author: William Hale Date created: 2/12/2020

class rlcard.games.gin_rummy.dealer.GinRummyDealer(np_random)

Bases: object

Initialize a GinRummy dealer class

deal_cards(player: GinRummyPlayer, num: int)

Deal some cards from stock_pile to one player

Parameters:
  • player (GinRummyPlayer) – The GinRummyPlayer object

  • num (int) – The number of cards to be dealt

rlcard.games.gin_rummy.game

File name: gin_rummy/game.py Author: William Hale Date created: 2/12/2020

class rlcard.games.gin_rummy.game.GinRummyGame(allow_step_back=False)

Bases: object

Game class. This class will interact with outer environment.

static decode_action(action_id) ActionEvent

Action id -> the action_event in the game.

Parameters:

action_id (int) – the id of the action

Returns:

the action that will be passed to the game engine.

Return type:

action (ActionEvent)

get_current_player() GinRummyPlayer
get_last_action() ActionEvent
get_num_actions()

Return the number of possible actions in the game

get_num_players()

Return the number of players in the game

get_player_id()

Return the current player that will take actions soon

get_state(player_id: int)

Get player’s state

Returns:

The information of the state

Return type:

state (dict)

init_game()

Initialize all characters in the game and start round 1

is_over()

Return whether the current game is over

step(action: ActionEvent)

Perform game action and return next player number, and the state for next player

step_back()

Takes one step backward and restore to the last state

rlcard.games.gin_rummy.judge

File name: gin_rummy/judge.py Author: William Hale Date created: 2/12/2020

class rlcard.games.gin_rummy.judge.GinRummyJudge(game: GinRummyGame)

Bases: object

Judge decides legal actions for current player

Returns:

List[ActionEvent] of legal actions

rlcard.games.gin_rummy.judge.get_going_out_cards(hand: List[Card], going_out_deadwood_count: int) Tuple[List[Card], List[Card]]
Parameters:
  • hand – List[Card] – must have 11 cards

  • going_out_deadwood_count – int

Return List[Card], List[Card:

cards in hand that be knocked, cards in hand that can be ginned

rlcard.games.gin_rummy.player

File name: gin_rummy/player.py Author: William Hale Date created: 2/12/2020

class rlcard.games.gin_rummy.player.GinRummyPlayer(player_id: int, np_random)

Bases: object

add_card_to_hand(card: Card)
did_populate_hand()
get_meld_clusters() List[List[List[Card]]]
get_player_id() int

Return player’s id

static opponent_id_of(player_id: int) int
remove_card_from_hand(card: Card)
static short_name_of(player_id: int) str

rlcard.games.gin_rummy.round

File name: gin_rummy/round.py Author: William Hale Date created: 2/12/2020

class rlcard.games.gin_rummy.round.GinRummyRound(dealer_id: int, np_random)

Bases: object

declare_dead_hand(action: DeclareDeadHandAction)
discard(action: DiscardAction)
draw_card(action: DrawCardAction)
get_current_player() GinRummyPlayer
gin(action: GinAction, going_out_deadwood_count: int)
knock(action: KnockAction)
pick_up_discard(action: PickUpDiscardAction)
score_player_0(action: ScoreNorthPlayerAction)
score_player_1(action: ScoreSouthPlayerAction)