A 2D artificial-life simulation built in Unity, where a population of Keklik (chukar partridges) is born, roams, eats, drinks, ages, mates and passes on its genes — letting you watch population dynamics and a tiny bit of natural selection emerge in real time. Every run exports a CSV report that can be turned into graphs.
- Autonomous agents — every Keklik thinks for itself (roams, forages, seeks a mate) with no central controller.
- Needs-driven behaviour — hunger, thirst and age tick down over time; ignore them and the bird dies.
- Genetics & reproduction — offspring inherit the average of both parents' traits, plus random mutation and a blended colour.
- Emergent population dynamics — booms, crashes and shifting male/female ratios appear on their own.
- Live HUD & controls — pause, fast-forward (up to 100×) and choose the starting population (10–1000).
- Data export — per-cycle metrics are written to a CSV, then plotted with a Python script.
Each bird is a prefab made of cooperating components:
| Component | Responsibility |
|---|---|
Keklik |
Lifecycle controller — initialisation, mating, reproduction, death |
KeklikStats |
All stats as validated properties (clamping + warnings) |
KeklikNeeds |
Hunger, thirst, pregnancy decay and aging |
KeklikMovement |
Roaming and foraging for food/water within screen bounds |
KeklikGens |
Serialises/deserialises a bird's genome to/from a string |
Needs are evaluated every 0.5 s:
- Hunger / Thirst decay each tick (×1.5 faster while pregnant). Reaching 0 is fatal.
- Aging adds
+0.1per tick; onceAgepasses a randomMaxAge(50–100), the bird dies of old age.
A continuous RoamAround coroutine drives each bird:
- If food
< 50%→ look for the nearest Fruit within vision range and eat it. - If water
< 60%→ look for the nearest Water source and drink (refills to full). - Otherwise wander to a random point inside its vision range, clamped to the camera bounds.
Speed and vision range are capped at 10; vision range also drives the bird's detection collider.
Males continuously run a Mating coroutine. When a male is well-fed and hydrated (> 75%),
it scans its vision range for a non-pregnant female that is also > 75% fed/hydrated. On a match:
- the female becomes pregnant (gestation ≈ 10 s of simulated time),
- a baby is then spawned at her position and inherits, via
InitBabyFromParents:- averaged max-food/water, speed, vision, decay rates and max-age,
- random variation on speed/vision (±0.5) and max-age (±5),
- a blended skin colour (
Color.Lerpbetween parents), - a random gender (males grow horns).
KillKeklik removes the bird from the live registry, stops its coroutines and destroys it.
Causes of death: starvation, dehydration or old age — all logged to the console.
| Object | Tag | Role |
|---|---|---|
Keklik |
Keklik |
The simulated bird (sprite + vision collider + horns for males) |
Bush → Fruit |
Fruit |
Food. Fruit grows over time and can only be eaten when ripe, then regrows |
WaterPit |
Water |
A drinking spot that refills thirst |
| Button | Action |
|---|---|
| Keklik Count | Cycle the starting population: 10 → 50 → 100 → 200 → 500 → 1000 |
| Start | Spawn the population and begin the simulation |
| Speed | Cycle the time scale: 1× → 3× → 5× → 10× → 20× → 30× → 50× → 100× |
| Pause | Freeze / resume the simulation |
| Restart | Reload the scene for a fresh run |
A live HUD shows cycle number, population, average speed/range/max-age and the male/female split.
While running, Reporter snapshots the population every 0.5 s and appends a row to
Assets/KeklikReport.csv every 10 s:
CycleNo, AvgSpeed, AvgRange, AvgMaxAge, MaleCount, FemaleCount, KeklikCount
Assets/Scripts/csvToGraphs.py turns that CSV into a 5-panel chart (cycle_metrics.png)
using pandas and matplotlib.
Note: average values are written as
(5,097)(parenthesised, comma-decimal); the Python script normalises them to5.097before plotting.
Assets/
├─ Scenes/SampleScene.unity # the simulation scene
├─ Prefabs/ # Keklik, Bush (Fruit), WaterPit
├─ Scripts/
│ ├─ Keklik.cs # lifecycle, mating, reproduction, death
│ ├─ KeklikStats.cs # validated stat properties
│ ├─ KeklikNeeds.cs # hunger / thirst / pregnancy / aging
│ ├─ KeklikMovement.cs # roaming & foraging
│ ├─ KeklikGens.cs # genome (de)serialisation
│ ├─ Spawner.cs # spawns the initial population
│ ├─ Fruit.cs # growable, consumable food
│ ├─ Reporter.cs # per-cycle metrics + CSV export
│ ├─ EventSystem.cs # UI controls + live HUD
│ └─ csvToGraphs.py # CSV → graphs (pandas + matplotlib)
├─ KeklikReport.csv # sample run output
└─ cycle_metrics.png # sample generated chart
Requirements: Unity 2023.2.11f1 (2D), and Python 3 with pandas + matplotlib for the graphs.
git clone https://github.com/UKBey/LifeSimulator.git- Open the project in Unity Hub (Unity 2023.2.11f1 recommended).
- Open
Assets/Scenes/SampleScene. - Press Play, choose a population with Keklik Count, then hit Start.
- Watch the HUD; a
KeklikReport.csvis written to theAssets/folder.
To generate the graphs:
pip install pandas matplotlib
# edit INPUT_CSV / OUTPUT_PNG at the top of csvToGraphs.py to your paths
python Assets/Scripts/csvToGraphs.pyMIT © 2026 Ukbe Taha Şahinkaya
