Player State

from dgisim import PlayerState

__eq__ and __hash__ are implemented so that any two player states with the equivalent content are equal to each other and have the same hash.

class PlayerState(phase: Act, consec_action: bool, characters: Characters, hidden_statuses: Statuses, combat_statuses: Statuses, summons: Summons, supports: Supports, card_redraw_chances: int, dice_reroll_chances: int, dice: ActualDice, hand_cards: Cards, deck_cards: Cards, publicly_used_cards: Cards, publicly_gained_cards: Cards)

A class that holds all immutable data of a player.

__init__(phase: Act, consec_action: bool, characters: Characters, hidden_statuses: Statuses, combat_statuses: Statuses, summons: Summons, supports: Supports, card_redraw_chances: int, dice_reroll_chances: int, dice: ActualDice, hand_cards: Cards, deck_cards: Cards, publicly_used_cards: Cards, publicly_gained_cards: Cards)
Parameters:
  • phase – the phase the player is in.

  • consec_action – whether the player should act consecutively.

  • characters – the characters.

  • hidden_stateses – the hidden statuses.

  • combet_statuses – the combat statuses.

  • summons – the summons.

  • supports – the supports.

  • card_redraw_chances – the number of times a player can redraw cards.

  • dice_reroll_chances – the number of time a player can reroll dice.

  • dice – current dice in hand.

  • hand_cards – current hand cards.

  • deck_cards – cards in deck to be drawn.

  • publicly_used_cards – cards the player has used that the opponent knows for sure.

  • publicly_gained_cards – cards the player has gained that the opponent knows for sure.

factory() PlayerStateFactory
Returns:

a factory for the current player state.

The factory allows modifications to the existing a copy of the origial player state to produce a new one.

You may call .<attribute-name>(new_val) to replace the current value.

Or call .f_<attribute-name>(<function>) to make modifications based on the current value.

e.g. player_state.factory().dice(ActualDice({})).f_hand_cards(lambda hcs: hcs.add(Paimon)).build() returns a new player state with no dice but one additional Paimon card.

defeated() bool
Returns:

True if the player is defeated.

encoding(encoding_plan: EncodingPlan) list[int]

Encode the player state into a list of integers.

classmethod example_player(mode: Mode) Self
Returns:

a random initial player state under the mode.

extract_deck() Deck
Returns:

the best estimation of the deck of the player.

classmethod from_chars_cards(mode: Mode, characters: Characters, cards: Cards) Self
Returns:

the initial state of a player under mode with characters and cards.

classmethod from_deck(mode: Mode, deck: Deck) Self
Returns:

the initial state of a player under mode with deck.

get_active_character() None | Character
Returns:

the active character. None is returned if there isn’t one.

get_card_redraw_chances() int
Returns:

if the player can make consecutive actions before the opponent makes a move.

get_characters() Characters
Returns:

the characters the player have.

get_combat_statuses() Statuses
Returns:

the combat statuses of the player.

get_consec_action() bool
Returns:

if the player can make consecutive actions before the opponent makes a move.

get_deck_cards() Cards
Returns:

the deck cards that will be drawn in the future.

get_dice() ActualDice
Returns:

the dice of the player.

get_dice_reroll_chances() int
Returns:

the number of chances to reroll dices.

get_hand_cards() Cards
Returns:

the hand cards of the player.

get_hidden_statuses() Statuses
Returns:

the hidden statuses of the player. Typically holds information that are invisible but useful in the game.

get_phase() Act
Returns:

the (player) phase the player is in.

get_publicly_gained_cards() Cards
Returns:

the cards publicly gained by the player.

get_publicly_used_cards() Cards
Returns:

the cards publicly used by the player.

get_summons() Summons
Returns:

the summons of the player.

get_supports() Supports
Returns:

the supports of the player.

hide_secrets() PlayerState
Returns:

the same player but hides cards and dice. So opponent agent cannot cheat with extra information.

Cards are hidden by replacing them all with OmniCard.

Dices are hidden by replacing them all with ANY. (Note this makes the new ActualDice invalid)

in_action_phase() bool
Returns:

True if the player is in Action Phase.

in_active_wait_phase() bool
Returns:

True if the player is in Active Wait Phase.

in_end_phase() bool
Returns:

True if the player is in End Phase.

in_passive_wait_phase() bool
Returns:

True if the player is in Passive Wait Phase.

is_mine(object: Character | Support) bool
Returns:

True if the object belongs to the player.

just_get_active_character() Character
Returns:

the active character. Exception is thrown if there isn’t one.