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: OrderedCards, 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: OrderedCards, 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 deck_cards: OrderedCards
- Returns:
the deck cards that will be drawn in the future.
- property dice: ActualDice
- Returns:
the dice of the player.
- encoding(encoding_plan: EncodingPlan) list[int]
Encode the player state into a list of integers.
- classmethod from_chars_cards(mode: Mode, characters: Characters, cards: OrderedCards) 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.
- 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)
- property initial_deck: FrozenDeck
- Returns:
the initial deck of 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 summons: Summons
- Returns:
the summons of the player.
- property supports: Supports
- Returns:
the supports of the player.