Skip to content

nayanrgarg-tech/evolution-sim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 

Repository files navigation

Evolution Simulation (VPython)

A 2D top‑down evolution sandbox where blob creatures forage, mutate, and survive in a hazard‑filled environment. The simulation is fully interactive with sliders, toggles, and keyboard shortcuts for rapid experimentation.

Requirements

  • Python 3.9+
  • vpython

Install:

  • pip install vpython

Run

  • python evolution_sim.py

What it does

  • Spawns a population of blob creatures with inheritable traits.
  • Spawns food each generation, used to replenish energy.
  • Applies hazards (rocks, mud, heat, wind, toxic zones) that shape which traits are favored.
  • Lets you step generations instantly and observe trait shifts via live stats and analytics.

Controls

Buttons

  • New Simulation: Resets the world using current sliders/toggles.
  • Run/Pause: Toggles continuous simulation.
  • Step Generation: Jumps forward by the configured generation step size.

Keyboard Shortcuts

  • N: Step generations instantly (uses Gen step size).
  • R: Restart simulation.
  • Space: Run/Pause.
  • + / -: Increase/decrease speed rate.

Tip: Click the canvas once to focus it before using shortcuts.


World Rules

  • Movement: Blobs move toward the nearest food within their vision range, otherwise wander.
  • Energy cost: Movement costs energy (higher speed costs more). Efficiency and metabolism reduce/increase cost.
  • Food: Eating food restores energy. Food is spawned per generation via the Food slider.
  • Reproduction: When energy exceeds the reproduction threshold (modified by fertility), blobs split energy and produce mutated offspring.
  • Death: Blobs die when energy drops below a resilience‑scaled threshold.

Traits (Mutations)

Each blob inherits traits with optional mutations (toggles control whether mutations are allowed):

  • Speed: Movement rate. Higher speed moves faster but costs more energy.
  • Efficiency: Reduces energy cost per step.
  • Metabolism: Energy burn multiplier (lower is better for survival).
  • Fertility: Scales the reproduction threshold (lower reproduces sooner).
  • Appetite: Multiplies energy gained from food.
  • Vision: How far a blob can detect food.
  • Resilience: How long a blob can survive below zero energy.

Mutation strength is influenced by blob color brightness (brighter = stronger mutations).


Environment & Hazards

Hazards apply selection pressure to different traits:

  • Rocks: Block movement; favors vision and resilience.
  • Mud: Slows and drains energy; favors efficiency and low metabolism.
  • Heat: Punishes low efficiency/high metabolism.
  • Wind: Pushes blobs around; favors resilience.
  • Toxic zones: Reduce food effectiveness; favors higher appetite.

All hazard zones are flat overlays on the map for clarity.


Key Sliders & Toggles

  • Mutation strengths (Speed, Efficiency, Metabolism, Fertility, Appetite, Vision, Resilience)
  • Enable mutations (toggles per trait)
  • Starting blobs
  • Food per generation
  • World size
  • Start clustering (how tightly blobs spawn near the center)
  • Gen step size (how many generations to jump with Step/N)
  • Food energy
  • Reproduction threshold
  • Wander chance
  • Speed rate
  • Hazard counts (Rocks, Mud, Heat, Wind, Toxic)

Stats & Analytics

Stats panel

  • Population: Total blobs alive.
  • Avg speed/efficiency/metabolism: Current population averages.
  • Generation: Highest generation reached.

Detailed stats panel

Shows avg, min, max, and prevalence (% at or above avg) for each trait.

Analytics panel

  • Trait diversity (spread across main traits)
  • High‑speed prevalence
  • High‑efficiency prevalence
  • Low‑metabolism prevalence
  • Food in world and Food/gen

Notes

  • Use New Simulation after changing world size or hazard counts.
  • If no food is generated per generation (Food per generation = 0), existing food will be consumed and not respawned.

About

in the name

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages