Autonomous Agents¶
Concepts¶
Autonomous Agents generally refers to an entity that makes its own choices about how to act in its environment without any influence from a leader or global plan. Three key components to keep in mind:
- An autonomous agent has a limited ability to perceive its environment.
- An autonomous agent processes the information from its environment and calculates an action.
- An autonomous agent has no leader.
Complex Systems¶
Complex System
A system of elements, operating in parallel, with short-range relationships that as a whole exhibit emergent behavior.
Three key principles of complex systems:
- Simple units with short-range relationships
- Simple units operate in parallel
- System as a whole exhibits emergent phenomena
Some other features of complex systems:
- Non-linearity. Often called the "butterfly" effect. A small change to the initial conditions can cause a large change in the result.
- Competition and cooperation. In a flocking system, these are alignment, cohesion, and separation.
- Feedback. The output of the system is fed back to the system as input for future simulations.
Vehicles¶
Reynolds' steering behavior has three layers:¶
- Action Selection
- Steering
- Locomotion (left foot, right foot, left foot, right foot)
Common steering behaviors:¶
\hat{V_{steering}} = \lVert \vec{V_{desired}} - \vec{V_{current}} \rVert
\vec{F_{steering}} = \hat{V_{steering}} * forceMagnitude
- Seek
- Flee
- Pursuit
- Follow a path
- Follow a flow field
- Flock with neighbors
Arriving Behavior¶
Instead of having desired velocity always be the maximum velocity, make it smaller as the vehicle approaches the target.
Wandering¶
\vec{V_{desired}} = \lVert \vec{P_{target}} - \vec{P_{vehicle}} \rVert * maxSpeed
Wandering can be implemented by finding a target wander location, drawing a circle, and moving to a point on that circle.
Flow Fields¶
\hat{V_{dir}} = flowField.lookup(position.x, position.y)
\vec{V_{desired}} = \hat{V_{dir}} * maxSpeed
Path Following¶
(\vec{P_{path}}, \hat{dir}) = path.closestPointFor(P_{vehicle})
\vec{P_{target}} = \vec{P_{path}} + \hat{dir} * lookAheadConstant
Note: the path following algorithm as introduced in the book doesn't have a "direction". Both directions are valid for the vehicle to take.
- This is starting to show some interesting emergent behavior when avoidance is turned on. Most vehicles tend to go in the clockwise direction (since I told them to start by going up), however, there are always some outliers. These outliers often switch back to clockwise when they wade through a crowd, due to avoidance forces.
Flocking¶
Reynolds uses the term "boid" (a made-up word that refers to a bird-like object) to describe the elements of a flocking system. There are 3 rules of flocking:
- Separation (or "avoidance"): steer to avoid colliding with neighbors.
- Alignment (or "copy"): steer in the same direction as neighbors.
- Cohesion (or "center"): steer towards the average position of local flockmates.
Some observations on flocking:
- Alignment makes each boid in the group steer more slowly towards the target.
-
Cohesion generates sub-groups.
-
TODO: Add formula for each flocking behavior?
References¶
- Craig Reynolds' steering behavior - boids model for flocking / swarming behavior.
- Craig Reynolds' 1999 paper Steering Behavior for Autonomous Characters