rlcard.games.gin_rummy.utils

rlcard.games.gin_rummy.utils.action_event

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

class rlcard.games.gin_rummy.utils.action_event.ActionEvent(action_id: int)

Bases: object

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)

static get_action_num()

Return the number of possible actions in the game

class rlcard.games.gin_rummy.utils.action_event.DeclareDeadHandAction

Bases: rlcard.games.gin_rummy.utils.action_event.ActionEvent

class rlcard.games.gin_rummy.utils.action_event.DiscardAction(card: rlcard.core.Card)

Bases: rlcard.games.gin_rummy.utils.action_event.ActionEvent

class rlcard.games.gin_rummy.utils.action_event.DrawCardAction

Bases: rlcard.games.gin_rummy.utils.action_event.ActionEvent

class rlcard.games.gin_rummy.utils.action_event.GinAction

Bases: rlcard.games.gin_rummy.utils.action_event.ActionEvent

class rlcard.games.gin_rummy.utils.action_event.KnockAction(card: rlcard.core.Card)

Bases: rlcard.games.gin_rummy.utils.action_event.ActionEvent

class rlcard.games.gin_rummy.utils.action_event.PickUpDiscardAction

Bases: rlcard.games.gin_rummy.utils.action_event.ActionEvent

class rlcard.games.gin_rummy.utils.action_event.ScoreNorthPlayerAction

Bases: rlcard.games.gin_rummy.utils.action_event.ActionEvent

class rlcard.games.gin_rummy.utils.action_event.ScoreSouthPlayerAction

Bases: rlcard.games.gin_rummy.utils.action_event.ActionEvent

rlcard.games.gin_rummy.utils.gin_rummy_error

Project: Gin Rummy File name: gin_rummy/utils/gin_rummy_error.py Author: William Hale Date created: 4/29/2020

exception rlcard.games.gin_rummy.utils.gin_rummy_error.GinRummyError

Bases: Exception

exception rlcard.games.gin_rummy.utils.gin_rummy_error.GinRummyProgramError

Bases: rlcard.games.gin_rummy.utils.gin_rummy_error.GinRummyError

rlcard.games.gin_rummy.utils.melding

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

rlcard.games.gin_rummy.utils.melding.get_all_run_melds(hand: List[rlcard.core.Card]) → List[List[rlcard.core.Card]]
rlcard.games.gin_rummy.utils.melding.get_all_run_melds_for_suit(cards: List[rlcard.core.Card], suit: str) → List[List[rlcard.core.Card]]
rlcard.games.gin_rummy.utils.melding.get_all_set_melds(hand: List[rlcard.core.Card]) → List[List[rlcard.core.Card]]
rlcard.games.gin_rummy.utils.melding.get_best_meld_clusters(hand: List[rlcard.core.Card]) → List[List[List[rlcard.core.Card]]]
rlcard.games.gin_rummy.utils.melding.get_meld_clusters(hand: List[rlcard.core.Card]) → List[List[List[rlcard.core.Card]]]

rlcard.games.gin_rummy.utils.move

File name: gin_rummy/move.py Author: William Hale Date created: 2/16/2020

class rlcard.games.gin_rummy.utils.move.DealHandMove(player_dealing: rlcard.games.gin_rummy.player.GinRummyPlayer, shuffled_deck: List[rlcard.core.Card])

Bases: rlcard.games.gin_rummy.utils.move.GinRummyMove

class rlcard.games.gin_rummy.utils.move.DeclareDeadHandMove(player: rlcard.games.gin_rummy.player.GinRummyPlayer, action: rlcard.games.gin_rummy.utils.action_event.DeclareDeadHandAction)

Bases: rlcard.games.gin_rummy.utils.move.PlayerMove

class rlcard.games.gin_rummy.utils.move.DiscardMove(player: rlcard.games.gin_rummy.player.GinRummyPlayer, action: rlcard.games.gin_rummy.utils.action_event.DiscardAction)

Bases: rlcard.games.gin_rummy.utils.move.PlayerMove

class rlcard.games.gin_rummy.utils.move.DrawCardMove(player: rlcard.games.gin_rummy.player.GinRummyPlayer, action: rlcard.games.gin_rummy.utils.action_event.DrawCardAction, card: rlcard.core.Card)

Bases: rlcard.games.gin_rummy.utils.move.PlayerMove

class rlcard.games.gin_rummy.utils.move.GinMove(player: rlcard.games.gin_rummy.player.GinRummyPlayer, action: rlcard.games.gin_rummy.utils.action_event.GinAction)

Bases: rlcard.games.gin_rummy.utils.move.PlayerMove

class rlcard.games.gin_rummy.utils.move.GinRummyMove

Bases: object

class rlcard.games.gin_rummy.utils.move.KnockMove(player: rlcard.games.gin_rummy.player.GinRummyPlayer, action: rlcard.games.gin_rummy.utils.action_event.KnockAction)

Bases: rlcard.games.gin_rummy.utils.move.PlayerMove

class rlcard.games.gin_rummy.utils.move.PickupDiscardMove(player: rlcard.games.gin_rummy.player.GinRummyPlayer, action: rlcard.games.gin_rummy.utils.action_event.PickUpDiscardAction, card: rlcard.core.Card)

Bases: rlcard.games.gin_rummy.utils.move.PlayerMove

class rlcard.games.gin_rummy.utils.move.PlayerMove(player: rlcard.games.gin_rummy.player.GinRummyPlayer, action: rlcard.games.gin_rummy.utils.action_event.ActionEvent)

Bases: rlcard.games.gin_rummy.utils.move.GinRummyMove

class rlcard.games.gin_rummy.utils.move.ScoreNorthMove(player: rlcard.games.gin_rummy.player.GinRummyPlayer, action: rlcard.games.gin_rummy.utils.action_event.ScoreNorthPlayerAction, best_meld_cluster: List[List[rlcard.core.Card]], deadwood_count: int)

Bases: rlcard.games.gin_rummy.utils.move.PlayerMove

class rlcard.games.gin_rummy.utils.move.ScoreSouthMove(player: rlcard.games.gin_rummy.player.GinRummyPlayer, action: rlcard.games.gin_rummy.utils.action_event.ScoreSouthPlayerAction, best_meld_cluster: List[List[rlcard.core.Card]], deadwood_count: int)

Bases: rlcard.games.gin_rummy.utils.move.PlayerMove

rlcard.games.gin_rummy.utils.scorers

File name: gin_rummy/scorers.py Author: William Hale Date created: 2/15/2020

class rlcard.games.gin_rummy.utils.scorers.GinRummyScorer(name: str = None, get_payoff: Callable[[rlcard.games.gin_rummy.player.GinRummyPlayer, GinRummyGame], int] = None)

Bases: object

get_payoffs(game: GinRummyGame)
rlcard.games.gin_rummy.utils.scorers.get_payoff_gin_rummy_v0(player: rlcard.games.gin_rummy.player.GinRummyPlayer, game: GinRummyGame) → int

Get the payoff of player: deadwood_count of player

Returns

payoff for player (lower is better)

Return type

payoff (int or float)

rlcard.games.gin_rummy.utils.scorers.get_payoff_gin_rummy_v1(player: rlcard.games.gin_rummy.player.GinRummyPlayer, game: GinRummyGame) → float
Get the payoff of player:
  1. 1.0 if player gins

  2. 0.2 if player knocks

  3. -deadwood_count / 100 otherwise

Returns

payoff for player (higher is better)

Return type

payoff (int or float)

rlcard.games.gin_rummy.utils.settings

File name: gin_rummy/settings.py Author: William Hale Date created: 2/16/2020

class rlcard.games.gin_rummy.utils.settings.DealerForRound

Bases: enum.Enum

An enumeration.

North = 0
Random = 2
South = 1
class rlcard.games.gin_rummy.utils.settings.Setting

Bases: enum.Enum

An enumeration.

dealer_for_round = 'dealer_for_round'
default_setting = <function Setting.default_setting>
going_out_deadwood_count = 'going_out_deadwood_count'
is_allowed_gin = 'is_allowed_gin'
is_allowed_knock = 'is_allowed_knock'
is_allowed_pick_up_discard = 'is_allowed_pick_up_discard'
is_allowed_to_discard_picked_up_card = 'is_allowed_to_discard_picked_up_card'
is_always_knock = 'is_always_knock'
is_south_never_knocks = 'is_south_never_knocks'
max_drawn_card_count = 'max_drawn_card_count'
simple_gin_rummy_setting = <function Setting.simple_gin_rummy_setting>
stockpile_dead_card_count = 'stockpile_dead_card_count'
class rlcard.games.gin_rummy.utils.settings.Settings

Bases: object

change_settings(config: Dict[rlcard.games.gin_rummy.utils.settings.Setting, Any])
static get_config_with_invalid_settings_set_to_default_value(config: Dict[rlcard.games.gin_rummy.utils.settings.Setting, Any]) → Dict[rlcard.games.gin_rummy.utils.settings.Setting, Any]
print_settings()

rlcard.games.gin_rummy.utils.thinker

File name: gin_rummy/thinker.py Author: William Hale Date created: 3/28/2020

class rlcard.games.gin_rummy.utils.thinker.Thinker(hand: List[rlcard.core.Card])

Bases: object

get_meld_piles_with_discard_card(discard_card: rlcard.core.Card) → List[List[rlcard.core.Card]]

rlcard.games.gin_rummy.utils.utils

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

rlcard.games.gin_rummy.utils.utils.card_from_card_id(card_id: int) → rlcard.core.Card

Make card from its card_id

Parameters

card_id – int in range(0, 52)

rlcard.games.gin_rummy.utils.utils.card_from_text(text: str) → rlcard.core.Card
rlcard.games.gin_rummy.utils.utils.decode_cards(env_cards: numpy.ndarray) → List[rlcard.core.Card]
rlcard.games.gin_rummy.utils.utils.encode_cards(cards: List[rlcard.core.Card]) → numpy.ndarray
rlcard.games.gin_rummy.utils.utils.get_card(card_id: int)
rlcard.games.gin_rummy.utils.utils.get_card_id(card: rlcard.core.Card) → int
rlcard.games.gin_rummy.utils.utils.get_deadwood(hand: Iterable[rlcard.core.Card], meld_cluster: List[Iterable[rlcard.core.Card]]) → List[rlcard.core.Card]
rlcard.games.gin_rummy.utils.utils.get_deadwood_count(hand: List[rlcard.core.Card], meld_cluster: List[Iterable[rlcard.core.Card]]) → int
rlcard.games.gin_rummy.utils.utils.get_deadwood_value(card: rlcard.core.Card) → int
rlcard.games.gin_rummy.utils.utils.get_deck() → List[rlcard.core.Card]
rlcard.games.gin_rummy.utils.utils.get_rank_id(card: rlcard.core.Card) → int
rlcard.games.gin_rummy.utils.utils.get_suit_id(card: rlcard.core.Card) → int