Skip to content

swarmrl.agents.agent Module API Reference

Parent class for all agents

Agent

Parent class for a SwarmRL Agent.

Source code in swarmrl/agents/agent.py
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
class Agent:
    """
    Parent class for a SwarmRL Agent.
    """

    _killed = False

    @property
    def kill_switch(self):
        """
        If true, kill the simulation.
        """
        return self._killed

    @kill_switch.setter
    def kill_switch(self, value):
        """
        Set the kill switch.
        """
        self._killed = value

    def calc_action(
        self, colloids: typing.List[Colloid]
    ) -> typing.Tuple[typing.List[Action]]:
        """
        Compute the state of the system based on the current colloid position.

        Returns
        -------
        actions: typing.List[Action]
                Return the action the colloid should take.
        kill_switch : bool
                Flag capable of ending simulation.
        """
        raise NotImplementedError("Implemented in Child class.")

kill_switch property writable

If true, kill the simulation.

calc_action(colloids)

Compute the state of the system based on the current colloid position.

Returns

actions: typing.List[Action] Return the action the colloid should take. kill_switch : bool Flag capable of ending simulation.

Source code in swarmrl/agents/agent.py
32
33
34
35
36
37
38
39
40
41
42
43
44
45
def calc_action(
    self, colloids: typing.List[Colloid]
) -> typing.Tuple[typing.List[Action]]:
    """
    Compute the state of the system based on the current colloid position.

    Returns
    -------
    actions: typing.List[Action]
            Return the action the colloid should take.
    kill_switch : bool
            Flag capable of ending simulation.
    """
    raise NotImplementedError("Implemented in Child class.")