swarmsim.agent.control.BinaryController#

Binary Controller class.

class swarmsim.agent.control.BinaryController.BinaryController(a: tuple[Sequence[float] | ndarray, Sequence[float] | ndarray] | ndarray | Sequence[float], b: Sequence[float] | ndarray | None = None, agent=None, parent=None, sensor_id=0, sense_avg_time=1, **kwargs)[source]#

Controller that returns one of two constant control inputs based on a binary sensor state.

There are multiple ways to specify the control values to be output:

  1. If a and b are both 1D arrays, then:
    1. a is the output when the sensor is in state 0,

    2. b is the output when the sensor is in state 1.

  2. If only a is specified, then it should either be a 1D array or a 2D array.
    1. The first half or first column is the output when the sensor is in state 0,

    2. and the second half or second column is the output when the sensor is in state 1.

If b is specified, then it should be the same length as a.

Parameters:
  • a (Sequence[float, ...] | Sequence[tuple[float, ...], ...] | np.ndarray)

  • b (Sequence[float, ...] | np.ndarray | None, optional)

  • agent (Agent, optional)

  • parent (Agent, optional)

  • sensor_id (int, default=0) – The index in agent.sensors to use for the sensor.

  • sense_avg_time (int, default=1) – The number of timesteps to average over when calculating the sensor state. This is useful for averaging over the sensor state to smooth out noise, i.e., a low-pass filter.

Methods

get_actions(agent)

An example of a "from scratch" controller that you can code with any information contained within the agent class

as_config_dict

draw

set_agent

set_parent

as_config_dict()[source]#
get_actions(agent)[source]#

An example of a “from scratch” controller that you can code with any information contained within the agent class

Classes

BinaryController(a[, b, agent, parent, ...])

Controller that returns one of two constant control inputs based on a binary sensor state.