Thanks to visit codestin.com
Credit goes to github.com

Skip to content

A genetic algorithm-based life simulation where organisms navigate a digital ecosystem, compete for resources, and evolve through genetic inheritance.

License

Notifications You must be signed in to change notification settings

vistoriel/microworld

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MicroWorld

A genetic algorithm-based life simulation where organisms navigate a digital ecosystem, compete for resources, and evolve through genetic inheritance. Watch as digital entities develop behaviors through genome-driven decision-making.

Real-time statistics

MicroWorld is a real-time simulation of artificial organisms controlled by genetic algorithms. Each entity is a small creature with a 64-byte genome that encodes behaviors such as movement, energy consumption, reproduction, and predation. The simulation demonstrates how environmental pressures and genetic traits influence population dynamics.

Features

🧬 Genetic-Driven Behavior

Each organism is controlled by a 64-byte genome that dictates its behavioral decisions:

  • Rotation & Movement - Navigate through the environment based on genetic instructions
  • Sensing - Look ahead to detect obstacles, food, and other entities
  • Photosynthesis - Passively generate energy from the environment
  • Predation - Hunt and consume other organisms for energy
  • Reproduction - Create offspring when sufficient energy is accumulated

🌍 Dynamic Environment

  • Grid-based World - entity cells in a 1280×720 pixel environment
  • Energy Systems:
    • Light Energy - Available through photosynthesis
    • Organic Energy - Obtained by consuming other entities
    • Division Energy - Required to reproduce
  • Entity Relationships - Track friends (relatives), enemies, and empty spaces
  • Collision Detection - Environmental boundaries and entity interactions

👁️ Sensory System

Organisms can:

  • Look ahead at adjacent positions to sense their surroundings
  • Identify empty cells, walls, relatives, and enemies
  • React to detected entities based on genetic programming

🔄 Population Dynamics

  • Multiple Phenotypes - Pre-configured genome patterns create different organism types (herbivores, hunters, standard)
  • Random Mutations - Each organism starts with a randomized genome
  • Heredity - Offspring inherit genetic traits from their parent
  • Population Tracking - Monitor alive, dead, and total entity counts in real-time
  • Natural Selection - Organisms that fail to adapt die, pruning unsuccessful strategies

🎯 Behavioral Genetics

The simulation includes several starter genotypes:

  • Passive Organism - Relies on photosynthesis
  • Hunter - Aggressive predatory behavior
  • Left-turning, Top-turning, Right-turning, Bottom-turning - Directional movement patterns

Visuals

Simulation in action

Population growth

Organism interactions

Ecosystem development

Advanced lifeforms

How It Works

  1. Initialization - The simulation starts with 3 randomly-generated organisms
  2. Genome Execution - Each step, active organisms execute genetic instructions (up to 10 steps per cycle)
  3. Energy Management - Actions consume energy; reproduction and death manage population
  4. Real-time Feedback - Console displays live counts: Alive, Dead, and Total entities
  5. Game Over Condition - Simulation ends when all organisms die or only one type remains

Behaviors Available to Organisms

Each behavior in the genome can be triggered by instruction codes:

  • Rotate - Change facing direction (up, down, left, right)
  • Move - Advance in current direction
  • Look - Sense adjacent cells for resources and entities
  • Photosynthesis - Gain light energy passively
  • Division - Reproduce when energy threshold is met
  • Eat - Consume encountered organisms

Build Requirements

  • C++ compiler (Visual Studio recommended for .vcxproj)
  • SFML graphics library
  • Standard C++ library

About

A genetic algorithm-based life simulation where organisms navigate a digital ecosystem, compete for resources, and evolve through genetic inheritance.

Topics

Resources

License

Stars

Watchers

Forks