maverick.player.Player#

class maverick.player.Player(*, uid: str | None = None, name: str, state: PlayerState | dict | None = None, **kwargs)[source]#

Abstract base class for a poker player.

__init__(*, uid: str | None = None, name: str, state: PlayerState | dict | None = None, **kwargs)[source]#

Methods

__init__(*[, uid, state])

decide_action(*, game, valid_actions, ...)

Decide on an action to take during the player's turn.

get_by_uid(uid)

Get a player class by its unique identifier.

on_event(event, game)

Optional hook called when a game event occurs.

to_dict()

Serialize the player to a dictionary.

Attributes

cls_uid

id

use uid instead.

register

property id: str#

use uid instead.

Type:

Deprecated

classmethod get_by_uid(uid: str) type[Player] | None[source]#

Get a player class by its unique identifier.

Parameters:

uid (str) – The unique identifier of the player class.

Returns:

The player class with the given uid, or None if not found.

Return type:

Optional[type[Player]]

abstractmethod decide_action(*, game: Game, valid_actions: list[ActionType], min_raise_amount: int, call_amount: int, min_bet_amount: int) PlayerAction[source]#

Decide on an action to take during the player’s turn.

The function should return a valid instance of PlayerAction.

Parameters:
  • game (Game) – The game instance containing the current state.

  • valid_actions (list[ActionType]) – List of valid actions the player can take.

  • min_raise_amount (int) – Minimum extra chips this player must add right now to complete a minimum raise.

  • call_amount (int) – Amount of chips this player must add right now to call the current bet.

  • min_bet_amount (int) – Minimum chips this player must add right now to make a bet.

Returns:

An instance of PlayerAction representing the chosen action.

Return type:

PlayerAction

on_event(event: GameEvent, game: Game) None[source]#

Optional hook called when a game event occurs.

This method is called synchronously after global event handlers. Exceptions in this method are caught and logged by the engine.

Parameters:
  • event (GameEvent) – The game event that occurred.

  • game (Game) – The game instance containing the current state.

Notes

This is an optional hook. The default implementation does nothing. Subclasses can override this method to observe events.

to_dict() dict[source]#

Serialize the player to a dictionary.

Returns:

A dictionary representation of the player.

Return type:

dict