Skip to content

Experimental multi-agent simulation framework where autonomous country agents deliberate under mechanical constraints. Includes 5 independent 30-round runs and a static viewer.

Notifications You must be signed in to change notification settings

RomanTsisyk/multi-agent-simulation-engine

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

52 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Multi-Agent Simulation Engine (WarGame)

Experimental distributed multi-agent reasoning framework for geopolitical crisis modeling.

An open-source system that orchestrates multiple AI agents to simulate complex international scenarios. Each country contains 2-4 faction agents that internally debate policy, then synthesize unified decisions. The system resolves conflicts deterministically and tracks cascading effects across military, economic, and political dimensions.

Python 3.12+ License: MIT


๐Ÿ”ฌ What This Is

A research framework for studying emergent behavior in multi-agent systems under resource constraints and incomplete information. The system:

  • Orchestrates 8 parallel agents (batched by strategic interest)
  • Enforces narrative consistency through game master arbitration
  • Applies cascading effects (oil prices โ†’ war support, casualties โ†’ morale)
  • Tracks 66 countries with asymmetric capabilities and faction diversity
  • Generates deterministic outcomes using combat formulas and public opinion gates

Primary test scenario: Suwalki Gap Crisis (Baltic escalation chain).


๐Ÿ—๏ธ Architecture

Country Agents (parallel)
    โ†“
Faction Debates (3 rounds each)
    โ†“
Game Master Resolution
    โ†“
World State Updates (cascading effects)
    โ†“
Checkpoint (JSON logs)
    โ†“
Static Web Viewer (no backend)

For detailed architecture, see ARCHITECTURE.md


โšก Quick Start

Prerequisites

  • Python 3.12+
  • Ollama (local LLM) or DeepSeek API key
  • 64GB RAM for deepseek-r1:32b

Installation

git clone https://github.com/RomanTsisyk/multi-agent-simulation-engine.git
cd multi-agent-simulation-engine

pip install -r requirements.txt
ollama pull deepseek-r1:32b  # Or use DeepSeek API
python run.py preflight

Run Simulation

# Quick (4 countries, 3 rounds)
python run.py play --preset quick

# Medium (10 countries, 5 rounds)
python run.py play --preset medium

# Full (20 countries, 10 rounds)
python run.py play --preset full

View Results

Live Demo (5 pre-recorded games):

https://roman-tsisyk.com/viewer_static_demo/production.html

Local Analytics:

python run.py view logs/game_TIMESTAMP/

๐Ÿ“Š Demo Viewer

No backend required. Static HTML/JS viewer with:

  • Real-time charts (oil prices, nuclear posture, war support, military balance)
  • Country decision logs with faction reasoning
  • Combat results and cascading effects
  • Full JSON state export

Runs on GitHub Pages via /viewer_static_demo/.


๐ŸŽฎ Game Mechanics

  • Combat formula: Strength ร— Readiness ร— Force multipliers
  • Nuclear escalation: peacetime โ†’ elevated โ†’ dispersal โ†’ launch_ready
  • Public opinion gates: War support determines military action legality
  • Cascading effects: Oil price shocks, sanctions impact, refugee flows

See GAME_MECHANICS.md for full specifications.


๐Ÿ”ง Documentation


๐Ÿ“ File Structure

engine/
  โ”œโ”€โ”€ game.py              # Round orchestration
  โ”œโ”€โ”€ world_state.py       # State management
  โ”œโ”€โ”€ game_master.py       # Combat resolution
  โ””โ”€โ”€ checkpoint.py        # Save/load
agents/
  โ”œโ”€โ”€ country.py           # Country orchestration
  โ””โ”€โ”€ faction.py           # Faction debates
backends/
  โ”œโ”€โ”€ ollama_backend.py
  โ””โ”€โ”€ deepseek_backend.py
scenarios/                 # YAML scenario definitions
countries/                 # YAML country configs (66)
viewer_static_demo/        # Web viewer + demo data
claude_runner/             # Claude Code integration
tests/                     # Unit test suite

๐Ÿš€ Development

Testing

pip install pytest pytest-asyncio pytest-cov
pytest --cov=engine,agents,backends

Code Style

ruff check .
mypy engine/ agents/ backends/

Configuration

Edit config.yaml:

game:
  scenario: "suwalki"
  num_countries: 20
  max_rounds: 10

backend:
  type: "deepseek"
  model: "deepseek-r1:32b"
  max_concurrent: 10

๐Ÿง  Agent System

Each country contains independent faction agents that debate before deciding:

  1. Initial Position - Faction states opening argument
  2. Rebuttal - Respond to other factions
  3. Synthesis - Move toward consensus

Faction Types: Hawk, Dove, Diplomat, Military Realist, Pragmatist

Weight by phase (escalation vs negotiation). See countries/*.yaml for examples.


๐ŸŽฏ Design Principles

  • Multi-agent reasoning over monolithic decisions
  • Asymmetric capabilities (not all countries equal)
  • Narrative consistency enforced by game master
  • Deterministic resolution (reproducible outcomes)
  • Cascading effects (not isolated decisions)
  • Static deployment (no backend required)

๐Ÿ“ˆ Performance

Scenario Countries Rounds LLM Calls Time
Quick 4 3 60 ~15 min
Medium 10 5 150 ~45 min
Full 20 10 600 ~3 hours

Backend comparison:

  • Ollama (local): Free, slow, privacy-preserving
  • DeepSeek API: Fast, $0.50-3/game, parallel queries

๐Ÿงช Testing & Reproducibility

Games are deterministic given same LLM and seed. All game logs saved as JSON:

logs/game_20260215_123456/
โ”œโ”€โ”€ round_001.json
โ”œโ”€โ”€ round_002.json
โ””โ”€โ”€ ...

Each round contains:

  • World state before/after
  • All country decisions
  • Combat results
  • Headlines & surprises

Fully analyzable post-hoc without re-running simulation.


๐Ÿ“– Citation

If using this framework for research:

@software{wargame2026,
  author = {Tsisyk, Roman},
  title = {Multi-Agent Simulation Engine (WarGame)},
  year = {2026},
  url = {https://github.com/RomanTsisyk/multi-agent-simulation-engine}
}

๐Ÿ“œ License

MIT License - see LICENSE file.


๐Ÿค Contributing

Priority areas:

  • New scenarios (Taiwan Strait, Arctic sovereignty)
  • Missing countries (Taiwan, Hungary, Romania configs)
  • Test coverage expansion
  • Backend optimization (inference batching)

Built with OpenAI/Anthropic APIs, Ollama, and community feedback.

About

Experimental multi-agent simulation framework where autonomous country agents deliberate under mechanical constraints. Includes 5 independent 30-round runs and a static viewer.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Contributors 2

  •  
  •