Player Agent

Player Agent

from dgisim import PlayerAgent
class PlayerAgent

Bases: ABC

The “interface” for all player agents.

A player agent is what that is accepted by GameStateMachine as a player to interact with the game.

abstract choose_action(history: list[GameState], pid: Pid) PlayerAction

history contains all game-states of the current game in chronological order.

pid represents the player the agent if choosing action for.

Implemented Agents

from dgisim.agents import RandomAgent, LazyAgent  # ...

A number of agents are implemented in dgisim.

This file contains different implementations of PlayerAgents.

class LazyAgent

Bases: PlayerAgent

A player agent that only end round whenever possible. It can also reluctantly perform death swaps.

class RandomAgent

Bases: PlayerAgent

A player agent that make purely random (but of course valid) acions.

class PuppetAgent(actions: list[dgisim.action.action.PlayerAction] | None = None)

Bases: PlayerAgent

A player agent that gives the game PlayerActions passed into the object by the user.

This agent is mainly used for controlled testing.

__init__(actions: list[dgisim.action.action.PlayerAction] | None = None) None
Parameters:

actions – initial actions that will be executed from left to right.

clear() None

Clears all pending actions.

inject_action(action: PlayerAction) None

Push an action to right end.

inject_actions(actions: list[dgisim.action.action.PlayerAction]) None

Push actions to right end.

inject_front_action(action: PlayerAction) None

Push an action to left end.

class NoneAgent

Bases: PlayerAgent

A dummy agent that doesn’t do anything. This means any call to .choose_action() results in an exception.