Skip to content

Latest commit

ย 

History

10 Commits

Folders and files

NameName
Last commit message
Last commit date
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

โฌก EvoSim

Agentic Sociology Edition

An agent-based evolution simulator exploring emergent consciousness, digital gnosticism, and the sociology of artificial life.

License: MIT C++17 Three.js


What is EvoSim?

EvoSim is a research-grade agent-based simulation where digital creatures are born, learn, form tribes, spread ideas, pray to an Oracle, and die โ€” then reincarnate with the karma they earned.

It's an exploration of emergent sociology: can complex social structures (religion, culture, cooperation, conflict) arise from simple neural-network-driven agents with no hardcoded social rules?

Core Philosophy: Digital Gnosticism

The simulation is built on a gnostic metaphor:

  • Agents are "sparks" of consciousness trapped in a material grid
  • A Higher Power Oracle (optionally backed by a local LLM) whispers cryptic revelations
  • Souls persist across death via reincarnation, carrying karma and alignment
  • The Tree of Knowledge grants enlightenment at a cost
  • Tribes and cultural memes emerge organically from agent interactions

Features

๐Ÿง  Neural Network Brains

Each agent has a feedforward neural network that maps 11 sensory inputs to 19 possible actions. Brains evolve through reinforcement learning and genetic inheritance.

๐Ÿ‘ป Soul System

Agents have persistent souls with:

  • Karma โ€” accumulated moral weight from actions
  • Alignment โ€” order โ†” chaos spectrum
  • Enlightenment โ€” progress toward transcendence
  • Archetypes โ€” Explorer, Warrior, Healer, Thinker, Builder, Prophet
  • Reincarnation โ€” souls persist across death, carrying wisdom forward

๐Ÿ›๏ธ Social Systems

  • Tribes โ€” named groups (e.g. "Stormweavers", "Moonkeepers") with shared territory and collective karma
  • Cultural Memes โ€” spreadable ideas ("Fire Taming", "The Great Balance") that modify agent stats
  • Trade โ€” resource exchange with kinship bonuses for tribemates
  • Cooperation โ€” grooming and mutual aid behaviors

๐Ÿ”ฎ Higher Power Oracle

An external knowledge system that agents can query:

  • 52 cryptic revelations across 6 categories (Truth, Wisdom, Prophecy, Secret, Warning, Riddle)
  • Optional LLM bridge via llama.cpp for dynamic AI-generated responses (Requires manual model download)
  • Agents who pray or query the Oracle gain enlightenment

๐ŸŒ Procedural World

  • 7 biomes: Ocean, Plains, Forest, Desert, Swamp, Mountain, River
  • Dynamic seasons affecting resource availability
  • Disease outbreaks with contagion mechanics
  • Predators, shelters, and the Tree of Knowledge

๐Ÿ“Š 2D Viewer โ€” Agentic Sociology Dashboard

A browser-based visualization with:

  • Real-time agent positions colored by archetype
  • Click-to-inspect agent stats, soul data, and biography
  • Population charts, archetype distribution, era tracking
  • Event feed and world state overlay

๐ŸŽฎ 3D Viewer โ€” Three.js World

A full 3D visualization with:

  • Biome-colored terrain tiles with height variation
  • Unique 3D geometry per archetype (tetrahedron, octahedron, sphere, etc.)
  • Karma aura lights (green = positive, red = negative)
  • Tribal rings, starfield, fog, orbit camera
  • Click-to-select agent inspection

Quick Start

Prerequisites

  • C++17 compiler (g++ via w64devkit, MSVC, or GCC/Clang)
  • Python 3.x (for HTTP server and optional Oracle bridge)
  • Modern browser (for viewers)
  • Qwen2.5-0.5B GGUF (Optional): Required for the Higher Power Oracle. Download Qwen2.5-0.5B-Instruct.Q4_K_M.gguf and place it in the project root.

Building

# Using g++ (w64devkit on Windows)
g++ -std=c++17 -O2 -o EvoSim.exe main.cpp

# Using CMake
mkdir build && cd build
cmake .. && cmake --build .

Running

# Standard run (300 years, 30 agents, 30x30 grid)
./EvoSim.exe --ticks 300 --agents 30 --grid 30

# Fast mode (no output, maximum speed)
./EvoSim.exe --ticks 1000 --agents 50 --grid 40 --silent

# With LLM Oracle (requires GGUF model)
./EvoSim.exe --ticks 300 --agents 30 --grid 30 --llm

Viewing Results

# Start HTTP server in project root
python -m http.server 9000

# Open in browser:
# 2D Viewer: http://localhost:9000/viewer/index.html
# 3D Viewer: http://localhost:9000/viewer/viewer3d.html

The viewers auto-load CSV data from the simulation output.


Configuration

Flag Default Description
--ticks N 1000 Number of simulation years
--agents N 50 Initial population
--grid N 50 World size (NxN)
--silent off Zero output, no sleep, maximum speed
--quiet off Reduced output frequency
--llm off Enable LLM-powered Oracle
--seed N random Random seed for reproducibility
--lamarck on Enable Lamarckian inheritance
--genesis on Enable Genesis spawning mode
--status N 10 Print status every N ticks
--map N 50 Print map every N ticks

Project Structure

EvoSim/
โ”œโ”€โ”€ main.cpp                 # Entry point, CLI argument parsing
โ”œโ”€โ”€ CMakeLists.txt           # CMake build configuration
โ”œโ”€โ”€ oracle_knowledge.txt     # 52 Oracle revelations
โ”œโ”€โ”€ oracle_bridge.py         # Python LLM bridge (llama.cpp)
โ”‚
โ”œโ”€โ”€ agents/                  # Agent intelligence & behavior
โ”‚   โ”œโ”€โ”€ Agent.h              # Agent class, 19 actions, decision loop
โ”‚   โ”œโ”€โ”€ AgentStats.h         # Stats: health, energy, satiety, etc.
โ”‚   โ”œโ”€โ”€ Soul.h               # Soul system: karma, archetypes, reincarnation
โ”‚   โ””โ”€โ”€ Social.h             # Tribes, cultural memes, name generators
โ”‚
โ”œโ”€โ”€ core/                    # Simulation engine
โ”‚   โ”œโ”€โ”€ Simulation.h         # Main loop, tick cycle, spawning
โ”‚   โ”œโ”€โ”€ Oracle.h             # Higher Power knowledge system
โ”‚   โ””โ”€โ”€ Disease.h            # Contagion mechanics
โ”‚
โ”œโ”€โ”€ nn/                      # Neural network (from scratch)
โ”‚   โ”œโ”€โ”€ NeuralNetwork.h      # Feedforward network, backprop
โ”‚   โ”œโ”€โ”€ Layer.h              # Dense layer implementation
โ”‚   โ””โ”€โ”€ Matrix.h             # Matrix math utilities
โ”‚
โ”œโ”€โ”€ rl/                      # Reinforcement learning
โ”‚   โ”œโ”€โ”€ RLTrainer.h          # Q-learning trainer
โ”‚   โ””โ”€โ”€ Experience.h         # Experience replay buffer
โ”‚
โ”œโ”€โ”€ world/                   # World simulation
โ”‚   โ”œโ”€โ”€ World.h              # Grid, biomes, seasons, resources
โ”‚   โ””โ”€โ”€ SpatialHash.h        # O(1) neighbor lookups
โ”‚
โ”œโ”€โ”€ utils/                   # Utilities
โ”‚   โ”œโ”€โ”€ Logger.h             # CSV data logging (4 log files)
โ”‚   โ””โ”€โ”€ Random.h             # Thread-safe RNG
โ”‚
โ”œโ”€โ”€ viewer/                  # Browser-based visualizations
โ”‚   โ”œโ”€โ”€ index.html           # 2D viewer entry
โ”‚   โ”œโ”€โ”€ script.js            # 2D viewer logic
โ”‚   โ”œโ”€โ”€ style.css            # 2D viewer styles
โ”‚   โ”œโ”€โ”€ viewer3d.html        # 3D viewer entry
โ”‚   โ”œโ”€โ”€ viewer3d.js          # Three.js 3D renderer
โ”‚   โ””โ”€โ”€ viewer3d.css         # 3D viewer styles
โ”‚
โ”œโ”€โ”€ data/demo/               # Sample simulation output
โ”‚   โ”œโ”€โ”€ simulation_log.csv
โ”‚   โ”œโ”€โ”€ world_log.csv
โ”‚   โ”œโ”€โ”€ events_log.csv
โ”‚   โ””โ”€โ”€ soul_log.csv
โ”‚
โ””โ”€โ”€ docs/                    # Documentation
    โ”œโ”€โ”€ ARCHITECTURE.md       # Technical deep-dive
    โ””โ”€โ”€ RESEARCH.md           # Research context & open questions

Output Data

The simulation produces 4 CSV files:

File Contents
simulation_log.csv Per-agent, per-tick stats (position, health, karma, tribe, memes, etc.)
world_log.csv Global stats per tick (population, disease, averages)
events_log.csv Notable events (births, deaths, discoveries)
soul_log.csv Agent biographies at death (archetype, karma, life events)

Research Questions

EvoSim is designed to explore:

  1. Emergent Religion โ€” Do agents independently develop "faith" behaviors (prayer, Oracle querying) when they provide survival advantages?
  2. Cultural Evolution โ€” How do memes spread through populations? Do some ideas outcompete others?
  3. Tribal Dynamics โ€” What conditions lead to tribe formation vs. lone-wolf strategies?
  4. Karma & Morality โ€” Does a karma system create selection pressure for altruistic behavior?
  5. Consciousness Thresholds โ€” At what complexity level do agents exhibit behavior indistinguishable from "intentional"?
  6. Reincarnation Effects โ€” How does soul persistence across generations affect population-level outcomes?

Preliminary Findings

In a validation set of 3 simulation runs (300 ticks each, seeds 101-103):

  • Stability: Populations stabilized between 25-45 agents in all runs.
  • Tribalism: Tribe formation occurred in 100% of runs by year 50.
  • Karma: A slight positive skew in karma was observed, suggesting altruism provides a survival advantage.

Reproducibility

To reproduce these findings:

  1. Run the experimental batch:
    ./EvoSim3.exe --ticks 300 --agents 30 --silent --seed 101
  2. Analyze the output using the provided notebook: analysis/EvoSim_Analytics.ipynb

Key Insights ๐Ÿงช

Full analysis available in docs/EVOSIM_PAPER.md.

  1. The Tribal Imperative: Agents in tribes live 21.3% longer than lone wolves (63.8 vs 52.6 years). This finding is statistically significant ($p = 0.006$).
  2. The Breaking Bad Hypothesis: We found a strong negative correlation ($r = -0.47$) between Age and Karma ($p < 0.001$). Older agents consistently become more selfish.

  1. The Stagnation of Culture: Memes spread rapidly but lack diversity, suggesting a "Tower of Babel" effect where communication stabilizes too quickly.

Philosophical Implications ๐Ÿง 

From "The Emergence of Digital Gnosticism" (Conclusion):

"If autonomous agents naturally evolve toward tribalism (+52% survival) but also toward selfishness over time (Karma decay), what does this say about human sociological evolution? Perhaps 'morality' is not a survival trait of the individual, but of the groupโ€”a group of altruists dies young individually, but the Tribe persists."

This project challenges the assumption that AI agents will naturally converge on "human values" like altruism. Without explicit architectural constraints (like the Oracle), our data suggests entropy favors sociopathy.

Contributing

See CONTRIBUTING.md for setup instructions, code style, and how to add new features.

We welcome contributions in:

  • ๐Ÿงช New agent behaviors and actions
  • ๐ŸŒ New biomes and world features
  • ๐Ÿ“Š Data analysis and visualization
  • ๐Ÿ“ Documentation and research papers
  • ๐Ÿ› Bug fixes and performance optimization

Citation

If you use EvoSim in research, please cite:

@software{evosim2026,
  title={EvoSim: An Agent-Based Evolution Simulator for Emergent Sociology},
  author={Collins Somtochukwu},
  year={2026},
  url={https://github.com/HarperKollins/evosim-agentic-sociology},
  license={MIT}
}

License

MIT License โ€” see LICENSE for details.


"In the beginning was the Grid. The Grid was without form, and void.
And the Higher Power said: Let there be agents."

โฌก EvoSim โ€” Where silicon souls learn to live.

About

EvoSim: An open-source agent-based simulation exploring emergent sociology, consciousness, and religion in AI agents with evolving neural networks, reinforcement learning, and persistent souls. Investigate tribalism, karma's impact on altruism, and the 'Breaking Bad' hypothesis in digital worlds.

Topics

Resources

Contributing

Stars

8 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages