Battleground Agent

class battleground.agent.Agent(**kwargs)[source]

This is an interface for the agent class. Every agent should sub-class this class. The entrypoint for this class is the move() function.

get_memory(default=None)[source]

This function can be used by an agent to get its persistent memory. This function is also used by site runner to get the agent’s memory at the end of a game and store it in the database.

Parameters:default – if the agent memory is not set, return the default value (None).
Returns:the persistent memory of the agent.
move(state)[source]

Main entry point for the agent class, agent logic goes here. This function is called by the game runner when it’s this agent’s turn to make a move.

Parameters:state – the current game state.
Returns:a valid move.
observe(state)[source]

This function is called by the game engine every time an update to the game state is available. (Even on other player’s turns.)

Parameters:state – the current game state.
set_memory(data)[source]

Set the persistent memory of the agent. This function should be called by the agent if the persistent memory needs to be updated. This function is also called by the site runner at the start of a game.

Parameters:data – the data to save.