Bot-Man-Toe/agents/mute.py

58 lines
1.7 KiB
Python

"""
The mute agent is a proof-of-concept agent of an agent that simply doesn't
respond - it always responds with an empty object.
This is the simplest agent to implement, and it can be used as a test to
make sure that the "default" move can be picked properly each turn.
"""
from __future__ import annotations
from .agent import ActionFunction, Agent, Payload
def respond_mute(payload : Payload) -> Payload:
"""
Standard response from the mute. Returns an empty object, always.
:param payload: Incoming game state.
:type payload: dict[str, Any]
:return: The empty object.
:rtype: dict[str, Any]
"""
return {}
class MuteAgent(Agent):
"""
The mute agent class refuses to respond to any incoming game states,
and simply responds with an empty dictionary. For most games,
this means that the mute player takes the "default" option as a result
of not responding.
"""
def __init__(self) -> None:
"""
Create a new instance of the mute agent.
"""
super().__init__(
name="Mute",
author="Bram",
version="1.0.1",
profile={
"me.noordstar.peanuts.is_ai": False,
},
)
self.add_tic_tac_toe(on_move=respond_mute)
self.add_royal_game_of_ur(on_move=respond_mute)
def get_action(self, game: str, action: str | None) -> ActionFunction:
"""
Return the mute response for any game or action.
:param game: The game that the mute ignores.
:type game: str
:param action: The action that the mute ignores.
:type action: str
"""
return respond_mute