Skip to contents

This functions scans the environment and computes the utility of each possible direction. Used in update_position when the agent has to reorient itself.

Usage

best_angle(
  agent,
  state,
  background,
  agent_specifications,
  velocities,
  orientations,
  time_step = 0.5,
  step = 45,
  cpp = TRUE
)

Arguments

agent

Object of the agent-class.

state

Object of the state-class.

background

Object of the background-class.

agent_specifications

List containing the specifications of all agents in the state. Is provided here as an argument to increase computational speed, as you only have to define these specifications once (instead of multiple times) per iteration. This list is furthermore needed to make the connection with the m4ma package.

velocities

Numerical matrix that contains the change in velocity per cell that the agent might move to.

orientations

Numerical matrix that contains the change in orientation per cell that the agent might move to.

time_step

Numeric denoting the time step in seconds. Defaults to 0.5

step

Numeric denoting the change in angle for looking around in degrees. Defaults to 45, meaning that the agent looks around exhaustively in 8 different directions (360 / 45) by default.

cpp

Logical denoting whether to use the R or Rcpp version of the function. Defaults to TRUE.

Value

Numeric denoting the angle or direction that had the highest utility (in degrees).

See also

simulate, simulate.state, update, utility-agent