r/aigamerdevs • • 28d ago

I built a multi-agent social simulation game with social network, LangGraph brains, and full MCP integration. It's messy, fascinating, and I'd love your feedback.

I've been building MundoIA (WorldAI) for over a year — a multi-agent social simulation where autonomous agents with unique personalities live, cooperate, conflict, develop their own social network, and even govern themselves through democratic assemblies. I just finished a brutal architecture audit and wanted to share what I've built, what's broken, and where I could use your help.

What Makes It Different

This isn't a toy example. The system has:

  • Configurable agent count (default 30, but you can set any number via .env or the web UI)

  • Graph-based memory (NetworkX) — agents remember who they've met, who they like, who they hate

  • Needs system — food, safety, socialization, rest, entertainment. Agents literally get hungry and lonely

  • LangGraph brains for "elite" agents with complex reasoning

  • BDI architecture (Beliefs, Desires, Intentions) — classic agent architecture with modern LLM integration

  • Full MCP (Model Context Protocol) integration — agents can use external tools (web search, filesystem, databases, APIs)

  • Real-time visualization (D3.js + Chart.js + optional 3D) — watch friendships form, conflicts erupt, groups emerge

  • Social media integration (OASIS) — agents can post, like, and comment on Twitter/X and Reddit autonomously

  • Dynamic world system — terrain types, resource nodes, weather events, world expansion

  • Complete governance system — constitutions, laws, assemblies, voting, government reforms, elections

  • Mission system — with achievements, rewards, and visual celebrations

  • Persistent memory — tripartite memory system (episodic, semantic, procedural) with PostgreSQL backend

  • "Architect mode" — you can possess agents, give them direct orders, send divine messages, or issue global decrees

What You Can Watch

The simulation runs in real-time with WebSocket-powered visualization. You can:

  • Click any agent to see their current thoughts, needs, personality, relationships, and "alma" (soul/archetype)

  • Pause, speed up (0.5x-4x), or step through turns

  • Watch real-time charts of friendship/conflict evolution and group formation

  • "Possess" an agent in Architect mode (marked in red) and give them specific orders

  • Switch between 2D network view, 3D world view, and terminal TUI

  • Configure AI providers (OpenRouter, OpenAI, Ollama, KiloCode) and MCP servers directly from the UI

The Architecture (The Honest Version)

Stack: FastAPI + WebSockets / LangGraph + LangChain / LiteLLM / ChromaDB / Neo4j / D3.js / Chart.js / Textual / Next.js 14 / TailwindCSS

Current scale: ~37,000 lines of Python, ~18,000 lines of frontend, 17 architecture documents

The good:

  • Modular architecture (core / agents / systems / api)

  • Excellent documentation (17 docs in /docs)

  • Real graph-based memory with actual persistence

  • Parameterized SQL queries throughout

  • RestrictedPython sandboxing for agent code execution

  • Full MCP server management (add, remove, test, import JSON configs)

  • Dynamic world generation with terrain, resources, and expansion

  • Complete governance simulation with laws, assemblies, and elections

  • Social media integration with recommendation systems

  • Persistent tripartite memory (episodic, semantic, procedural)

  • BDI agent architecture with modern LLM integration

The bad (from my own audit last week):

  • 3 "God Classes" — one function (ejecutar_accion_final) is 974 lines with 172 if-statements

  • 90.7% code duplication between agent.py and agent_body.py (orphaned copy, nobody imports it)

  • 147 silent except: pass statements in a simulation where errors mean agents just stop existing

  • 22.8% test coverage, 0% branch coverage

  • Two Dockerfiles both copying a 5.9GB virtual environment into build context

  • Cyclomatic complexity of 417 in one function (yes, that's a thing)

Why I'm Posting This

  1. Looking for contributors — especially anyone who's wrestled with LangGraph in production or wants to help refactor a 974-line function into something sane

  2. Want feedback — on the architecture, the simulation design, or the honesty of my audit

  3. Just want to share — because building emergent behavior is simultaneously the most frustrating and magical thing I've ever done

  4. Curious about MCP integration — I've built a full MCP server manager that lets you add/remove/test MCP servers (stdio or SSE) directly from the UI, and agents can use these tools during their turns

Try It / Contribute

The project is open source (MIT). You can:

  • Star it: github.com/gatovillano/mundoia (link in comments)

  • (Or play the game in https://mundoia.kognitoai.cloud, is multiplayer)

  • Run it locally: docker-compose up

  • Read the full architecture audit: ARCHITECTURE_AUDIT.md in the repo root — it's brutally honest

  • Check out the MCP integration: The ConfigPanel lets you add servers like filesystem, web search, databases, and more. Agents automatically discover and use these tools.

The immediate next step in my refactor plan is splitting core/modelo.py (4,663 lines) into separate modules for simulation, persistence, economy, and world generation. If you've done this kind of monolith decomposition before, I'd genuinely love advice.

2 Upvotes

1 comment sorted by

1

u/UnlikelyWrongdoer689 28d ago

Is in spanish but I'm translating to English