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.
- encoding(encoding_plan: EncodingPlan) list[int]
Encode the player state into a list of integers.
- 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_consec_action() bool
- Returns:
if the player can make consecutive actions before the opponent makes a move.
- get_dice() ActualDice
- Returns:
the dice of the player.
- 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_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)