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: rlcard.games.gin_rummy.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: rlcard.core.Game

Game class. This class will interact with outer environment.

static decode_action(action_id) → rlcard.games.gin_rummy.utils.action_event.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_action_num()

Return the number of possible actions in the game

get_current_player() → rlcard.games.gin_rummy.player.GinRummyPlayer
get_last_action() → rlcard.games.gin_rummy.utils.action_event.ActionEvent
get_player_id()

Return the current player that will take actions soon

get_player_num()

Return the number of players in the game

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: rlcard.games.gin_rummy.utils.action_event.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[rlcard.core.Card], going_out_deadwood_count: int) → Tuple[List[rlcard.core.Card], List[rlcard.core.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: rlcard.core.Card)
did_populate_hand()
get_meld_clusters() → List[List[List[rlcard.core.Card]]]
get_player_id() → int

Return player’s id

static opponent_id_of(player_id: int) → int
remove_card_from_hand(card: rlcard.core.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: rlcard.games.gin_rummy.utils.action_event.DeclareDeadHandAction)
discard(action: rlcard.games.gin_rummy.utils.action_event.DiscardAction)
draw_card(action: rlcard.games.gin_rummy.utils.action_event.DrawCardAction)
get_current_player() → rlcard.games.gin_rummy.player.GinRummyPlayer
gin(action: rlcard.games.gin_rummy.utils.action_event.GinAction, going_out_deadwood_count: int)
knock(action: rlcard.games.gin_rummy.utils.action_event.KnockAction)
pick_up_discard(action: rlcard.games.gin_rummy.utils.action_event.PickUpDiscardAction)
score_player_0(action: rlcard.games.gin_rummy.utils.action_event.ScoreNorthPlayerAction)
score_player_1(action: rlcard.games.gin_rummy.utils.action_event.ScoreSouthPlayerAction)