Spatial simulation of evolutionary game theory dynamics (Iterated Prisoner's Dilemma and more).
This project simulates social evolution using Game Theory on a 2D grid. Agents interact with their neighbors playing games like the Prisoner's Dilemma, Snowdrift, or Stag Hunt. Based on their success (payoff), strategies evolve over time through biological reproduction (Death-Birth) or social imitation.
- Always Cooperate / Defect: Baseline strategies.
- Tit-For-Tat (Spatial): Agents remember the last interaction with each specific neighbor (Pairwise Memory).
- Pavlov (Win-Stay, Lose-Shift): Universal implementation that adapts to any payoff matrix based on aspiration levels.
- Discriminator: Uses global reputation to decide whether to cooperate.
- Evolutionary Models: Support for Death-Birth (Selection driven by fitness) and Imitation (Fermi rule / Best Neighbor).
- Spatial Dynamics: Agents can migrate based on local success (Success-driven migration).
- Identity Persistence: Unique Agent IDs ensure memory is reset correctly when neighbors change.
- Customizable Games: Real-time editing of Payoff Matrix (R, S, T, P).
- Language: C++20
- Build System: CMake
- Graphics: SFML 3.0.1
- GUI: ImGui + ImGui-SFML
- Parallelism: OpenMP
This project uses CMake FetchContent, so you don't need to manually install SFML or ImGui. Ensure you have a C++ compiler, CMake, and Git installed.
- Windows: Visual Studio or Visual Studio Code.
- Linux: GCC/Clang with OpenMP support (
libomp-dev).
- Left Panel: Displays the simulation grid or real-time plots (History of population, Reputation).
- Right Panel (Controls):
- Start/Pause: Control the simulation flow.
- Strategies: Toggle which agents are allowed to spawn/mutate.
- Game Matrix: Choose a preset (Prisoner's Dilemma, Stag Hunt) or manually tune R/S/T/P values.
- Evolution Parameters: Adjust Mutation Rate, Selection Strength (Beta), Fermi Noise (K).