Birds behavior
Title: Simulation of Birds Behavior
Author: Denis Mišura (misd01)
Method: Agent-based model
Tool: NetLogo
Contents
Introduction and problem definition
This simulation explores the behavior of flocking agents (e.g., birds, drones, or other entities) based on simple interaction rules such as separation, alignment, and cohesion. Flocking is a common phenomenon in nature, where individual agents organize into groups or clusters without centralized control. The problem to solve is understanding how such groups (flocks) form, the factors influencing their size and dynamics, and how the number of agents in a flock changes over time. By modeling this process, we can gain insights into emergent behaviors and potentially apply these findings to robotics, crowd simulations, or ecological studies.
Model and Method
The model is based on Craig Reynolds' Boids algorithm, which uses three fundamental rules:
- Alignment - Birds align their heading to match nearby individuals.
- Separation - Birds maintain a safe distance to avoid collisions.
- Cohesion - Birds move towards the center of nearby individuals to stay within the group.
Each bird operates independently, processing local information without global knowledge of the flock. The simulation is implemented in NetLogo, a platform designed for multi-agent simulations, which enables dynamic interactions and visualization of emergent patterns.
Environment
The environment is a two-dimensional world in NetLogo with the following characteristics:
- World size: Defined by fixed boundaries.
- Visibility: Each bird can perceive its surroundings within a specified radius.
Birds are initially distributed randomly within the environment, and their movements are governed by local rules and deterministic updates.
Agents
Bird
The agents in the simulation represent birds. Each agent has the following characteristics:
- Attributes:
- Position (x, y)
- heading (direction of movement)
- vision range (distance to detect neighbors)
- current group membership (groups).
- Behaviors:
- Detect nearby agents within their vision range.
- Calculate the average heading of neighbors (alignment).
- Adjust movement to avoid collisions (separation).
- Move toward the group center (cohesion).
Variables
- User-Defined Variables:
- number_of_birds: Specifies the total number of agents (birds) in the simulation, determined by the user before the simulation starts.
- vision: Defines the distance within which an agent can detect its neighbors, set by the user to control the agents' perception range.
- distance-to-seperate: Defines the minimum distance between each bird in the flock
- Global Variables:
- num_flocks: Tracks the number of distinct flocks at each time step.
- avg_flock_size: Calculates the average number of agents in a flock.
- ticks: Keeps track of the simulation's time steps.
- Agent-Specific Variables:
- groups: A set of neighboring agents detected by an individual agent.
- neighbor: The nearest agent within the vision range.
- x, y: Position of the agent.
- heading: Direction of the agent's movement.
UI
Simulation steps
Setup Phase
- Clear the World:
- Remove any previous data or agents from the simulation.
- Reset the tick counter.
- Initialize the Environment:
- Create Agents:
- Create number_of_birds turtles (agents), each representing an individual bird.
- Place each turtle at a random position within the environment.
- Initialize the following attributes for each turtle:
- groups: Set to no-turtles (indicating no neighbors at the start).
- neighbor: Set to nobody (indicating no closest neighbor yet).
- heading: Assign a random initial heading.
- Assign user-defined variables:
- vision: The range within which the turtle can detect others.
Go Phase
- Flocking Behavior:
- Find Groups:
- Detect all turtles within its vision range and store them in the groups variable.
- Find Nearest Neighbor:
- Identify the closest turtle within the groups and assign it to the neighbor variable.
- Find Groups:
- Apply Flocking Rules:
- Separation: If the turtle is too close to its neighbor, steer away to avoid collision.
- Alignment: Adjust its heading to align with the average heading of turtles in its groups.
- Cohesion: Steer toward the center of its groups to stay with the flock.
- Move Turtles:
- Each turtle moves forward by a fixed step size, adjusting its position based on the updated heading.
- Count Flocks:
- Start with all turtles marked as unvisited.
- Group turtles into flocks based on their proximity and connections defined by groups.
- Increment num_flocks for each distinct flock identified.
- Increment Ticks:
- Advance the simulation clock by 1.
Results
The results of the simulation provide insights into the dynamics of flock formation, the number of flocks, and the average flock size under various conditions. Key findings include:
1. Flock Formation
- The simulation demonstrated that agents naturally organize into flocks over time based on the defined rules of separation, alignment, and cohesion.
- The initial distribution of agents (random) leads to smaller, scattered groups, which gradually merge into larger flocks or stabilize into multiple distinct flocks.
2. Number of Flocks (num_flocks)
- The number of flocks fluctuated throughout the simulation, depending on factors such as:
- Agent Density: A higher number of agents (number_of_birds) generally resulted in fewer but larger flocks, as agents were more likely to encounter and join neighboring groups.
- Vision Range (vision): Increasing the vision range reduced the number of flocks, as agents could detect and align with neighbors over greater distances.
- Over time, the system exhibited a trend toward stability, where the number of flocks reached an equilibrium or fluctuated minimally.
3. Average Flock Size (avg_flock_size)
- The average flock size increased as smaller groups merged into larger ones. Key observations include:
- At the start of the simulation, the average flock size was close to 1, reflecting the initial random distribution of agents.
- Over time, the average flock size stabilized, reflecting the balance between merging groups and the limited movement range of agents.
- Larger values for number_of_birds and vision resulted in a higher average flock size.
Conclusion
The simulation successfully models the behavior of flocking agents using simple rules for separation, alignment, and cohesion. By defining agents with individual attributes and enabling interactions within a specific vision range, the system demonstrates how local interactions can lead to the formation of complex, self-organizing structures such as flocks.
Key observations from the simulation include:
- Flocks form naturally as agents interact with their neighbors. The number of flocks (num_flocks) fluctuates over time, depending on the density and distribution of agents, as well as their vision range.
- The average flock size (avg_flock_size) provides a useful metric for analyzing clustering behavior. Factors such as the total number of agents (number_of_birds), vision range (vision), and initial distribution significantly influence this value.
- Despite each agent following only three simple rules, the collective behavior of the system exhibits realistic flocking dynamics, similar to those observed in nature.
NetLogo File
Sources
- Silverman, N., Sorin, A., & Levy, Y. (2023). Flocking with only two parameters. In Artificial Life and Robotics (pp. 157–169). Springer. https://doi.org/10.1007/978-3-031-37553-8_10
Boids: An Artificial Life Program
- Stanford University. (2009). Boids: An artificial life program. Retrieved from https://cs.stanford.edu/people/eroberts/courses/soco/projects/2008-09/modeling-natural-systems/boids.html
Relationship between Flock Size and Flight Initiation Distance in Birds
- Fern, C. E., & Fernández-Juricic, E. (2024). Relationship between flock size and flight initiation distance in birds. Animal Behaviour, 207, 113–121. https://doi.org/10.1016/j.anbehav.2023.09.001
Algorithms In Nature
- Ananthram, A. (2017). Algorithms in nature. Medium. https://medium.com/@adityaananthram/algorithms-in-nature-part-1-e80e80b29719
Statistical Mechanics for Natural Flocks of Birds
- Bialek, W., Cavagna, A., Giardina, I., Mora, T., Silvestri, E., Viale, M., & Walczak, A. M. (2012). Statistical mechanics for natural flocks of birds. Proceedings of the National Academy of Sciences, 109(13), 4786–4791. https://doi.org/10.1073/pnas.1118633109
A Systematic Review of Agent-Based Model for Flood Risk Management and Assessment Using the ODD Protocol
- Jafarzadegan, K., Shamsudin, S., & Wang, Y. (2022). A systematic review of agent-based model for flood risk management and assessment using the ODD protocol. Natural Hazards, 112(2), 1345–1370. https://doi.org/10.1007/s11069-022-05286-y