Agent-based simulation studying how spatially segregated agents with limited lifespans balance exploration and exploitation for survival and reproduction.
How do internal states (lifespan, energy) influence agents' willingness to leave safe territory in search of food or mates, and how do these decisions affect survival and reproduction?
- Agents: Foxes (predators) and rabbits (prey), each with male/female variants
- Environment: Grid world with four corner nests connected by corridors
- Mechanics:
- Lifespan decreases each tick; death occurs at zero
- Movement speed increases as lifespan depletes (urgency-driven exploration)
- Foxes hunt rabbits to regain lifespan
- Sexual reproduction requires opposite-sex contact; probability scales with urgency
- Nests are predator-free safe zones but contain no food
Agents face a trade-off: staying in nests is safe but leads to starvation and no reproduction. Leaving exposes them to predation but enables feeding and mating. Urgency emerges naturally β as lifespan drops, agents move faster and mate more readily.
Speed as a function of remaining lifespan
As agents approach death, movement speed increases quadratically:
Lifespan recovery on feeding
When a fox eats a rabbit, it regains lifespan (capped at maximum):
Urgency function
A unified urgency score combining internal state and local opportunity:
Where
Reproduction probability
Probability of mating upon contact scales with urgency (desperation-driven reproduction):
βββ vi/ # Simulation framework ("Violet")
β βββ agent.py # Base Agent class (extend this for custom behavior)
β βββ simulation.py # Simulation engine (headless + GUI modes)
β βββ config.py # Configuration dataclasses
β βββ proximity.py # Spatial chunking for neighbor detection
β βββ metrics.py # Data collection utilities
β
βββ Assignment 0/ # Flocking (Boids)
β βββ flocking.py # Reynolds flocking with alignment/cohesion/separation
β
βββ Assignment 1/ # Aggregation
β βββ aggregation.py # Agent clustering behavior
β
βββ Assignment 2/ # Predator-Prey (main project)
β βββ baseline.py # Fox-rabbit simulation entry point
β βββ map_design.py # Grid layout with nests and corridors
β βββ images/ # Agent and environment sprites
β
βββ images/ # Shared sprite assets
βββ main.py # Alternative entry point
βββ snapshots_*.csv # Collected simulation data
# With GUI
python Assignment\ 2/baseline.py
# Headless (batch experiments)
python Assignment\ 2/baseline.py --headless- Python 3.10+
- pygame
- polars
- vi (included simulation framework)