Skip to content

Agent Engine

Bases: ABC

Abstract base class representing the engine that manages agents.

The engine is responsible for creating, managing, and terminating agents, as well as facilitating interactions between them.

create_agent(name, **kwargs) abstractmethod

Instantiate a new agent within the engine.

Parameters:

Name Type Description Default
name str

The unique name identifier for the agent.

required
**kwargs Dict[str, Any]

Additional keyword arguments for agent initialization.

{}

Returns:

Name Type Description
IAgent IAgent

The newly created agent instance.

Raises:

Type Description
ValueError

If an agent with the same name already exists.

KeyError

If start_node_id is not provided in kwargs.

create_iter() abstractmethod

Create an iterator for processing agent steps.

Returns:

Type Description
Iterable[IAgent]

Iterable[IAgent]: An iterator object over all agents.

delete_agent(name) abstractmethod

Delete an agent by its name.

Parameters:

Name Type Description Default
name str

The unique name identifier of the agent to retrieve.

required

Returns:

Type Description
None

None

Raises:

Type Description
KeyError

If no agent with the specified name exists.

get_agent(name) abstractmethod

Retrieve an agent by its name.

Parameters:

Name Type Description Default
name str

The unique name identifier of the agent to retrieve.

required

Returns:

Name Type Description
IAgent IAgent

The agent instance corresponding to the provided name.

Raises:

Type Description
KeyError

If no agent with the specified name exists.

terminate() abstractmethod

Terminate the agent engine and perform necessary cleanup operations.

This method should ensure that all resources are properly released and that agents are gracefully shut down.

Agent


Bases: ABC

Abstract base class representing an agent in the system.

current_node_id abstractmethod property

Get the current node ID of the agent.

name abstractmethod property

Get the name identifier of the agent.

orientation abstractmethod property

Get the orientation of the agent.

Returns:

Name Type Description
int Tuple[float, float]

The current orientation of the agent.

prev_node_id abstractmethod property

Get the previous node ID of the agent.

state abstractmethod property

Get the current state of the agent.

Returns:

Type Description
Dict[str, Any]

Dict[str, Any]: The current state data of the agent.

strategy abstractmethod property

Get the current strategy of the agent.

Returns:

Type Description
Optional[Callable[[Dict[str, Any]], None]]

Optional[Callable[[Dict[str, Any]], None]]: The current strategy function or None if no strategy is set.

deregister_sensor(name) abstractmethod

Deregister a sensor from the agent.

Parameters:

Name Type Description Default
name str

The unique name identifier for the sensor to be deregistered.

required

get_state() abstractmethod

Retrieve the current state of the agent.

Returns:

Type Description
Dict[str, Any]

Dict[str, Any]: The current state data of the agent, structure depends on implementation.

register_sensor(name, sensor) abstractmethod

Register a sensor with the agent.

Sensors can be used by the agent to perceive the environment or gather data.

Parameters:

Name Type Description Default
name str

The unique name identifier for the sensor.

required
sensor ISensor

The sensor instance or object to be registered.

required

register_strategy(strategy) abstractmethod

Register a strategy with the agent.

Strategies define the decision-making or action-planning mechanisms for the agent.

Parameters:

Name Type Description Default
strategy Callable[[Dict[str, Any]], None]

The strategy instance or object to be registered.

required

set_state() abstractmethod

Update the agent's state.

step() abstractmethod

Execute a single operational step of the agent.

This method should contain the logic that defines the agent's behavior during one iteration or time step in the system.