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: sts.Statuses, combat_statuses: sts.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, initial_deck: Deck)

A class that holds all immutable data of a player.

__init__(phase: Act, consec_action: bool, characters: Characters, hidden_statuses: sts.Statuses, combat_statuses: sts.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, initial_deck: Deck)
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.

property card_redraw_chances: int
Returns:

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

property characters: Characters
Returns:

the characters the player have.

property combat_statuses: Statuses
Returns:

the combat statuses of the player.

property deck_cards: Cards
Returns:

the deck cards that will be drawn in the future.

defeated() bool
Returns:

True if the player is defeated.

property dice: ActualDice
Returns:

the dice of the player.

property dice_reroll_chances: int
Returns:

the number of chances to reroll dices.

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.

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_consec_action() bool
Returns:

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

property hand_cards: Cards
Returns:

the hand cards of the player.

property hidden_statuses: Statuses
Returns:

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

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.

property initial_deck: FrozenDeck
Returns:

the initial deck of the player.

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.

property phase: Act
Returns:

the (player) phase the player is in.

property publicly_gained_cards: Cards
Returns:

the cards publicly gained by the player.

property publicly_used_cards: Cards
Returns:

the cards publicly used by the player.

property summons: Summons
Returns:

the summons of the player.

property supports: Supports
Returns:

the supports of the player.