Action Generator
from dgisim import ActionGenerator
ActionGenerator is a class used to helper agents generate valid actions.
- class ActionGenerator(*, game_state: GameState, pid: Pid, action: None | PlayerAction = None, instruction: None | Instruction = None, _choices_helper: Callable[[Self], GivenChoiceType] = <function _dummy_choices_helper>, _fill_helper: Callable[[Self, DecidedChoiceType], Self] = <function _dummy_fill_helper>)
ActionGenerator is a class recording a state of choices made so far.
If both action and instruction is None, then this action generator is used to generate other ActionGenerators that may eventually generate some action.
- choices() GivenChoiceType
- Returns:
the choices to make a decision from.
If return value is a tuple, choose one value from the tuple.
If return value is ActualDice, choose some dice based on the context.
If return value is AbstractDice, choose some dice of ActualDice that can satisfy the AbstractDice.
If return value is Cards, choose some cards from it based on the context.
- choose(choice: DecidedChoiceType) ActionGenerator
- Parameters:
choice – the choice that the user makes for this stage.
- Returns:
a new ActionGenerator representing the next stage of choices.
- dice_available() ActualDice
- Returns:
the dice the player holds.
A shortcut method to quickly get the player’s dice.
- generate_action() PlayerAction
- Returns:
the final PlayerAction.
Precondition: .filled() is True.