Soci β LLM-Powered City Population Simulator
Project Overview
Simulates a diverse population of AI people living in a city using Claude as the reasoning engine. Each agent has a unique persona, memory stream, needs, and relationships. Inspired by Simile AI / Stanford Generative Agents research.
Tech Stack
- Python 3.10+ (Anaconda ml-env)
- Anthropic Claude API (Sonnet for novel situations, Haiku for routine)
- FastAPI + WebSocket (API server)
- SQLite via aiosqlite (persistence)
- Rich (terminal dashboard)
- YAML (city/persona config)
Key Commands
# Run with Anaconda ml-env:
"C:/Users/xabon/.conda/envs/ml-env/python.exe" main.py --ticks 20 --agents 5
"C:/Users/xabon/.conda/envs/ml-env/python.exe" test_simulation.py
# API server:
"C:/Users/xabon/.conda/envs/ml-env/python.exe" -m uvicorn soci.api.server:app --host 0.0.0.0 --port 8000
Architecture
src/soci/world/β City map, simulation clock, world eventssrc/soci/agents/β Agent cognition: persona, memory, needs, relationshipssrc/soci/actions/β Action types: movement, activities, conversation, socialsrc/soci/engine/β Simulation loop, scheduler, entropy management, LLM clientsrc/soci/persistence/β SQLite database, save/load snapshotssrc/soci/api/β FastAPI REST + WebSocket serverconfig/β City layout (12 locations) and personas (20 characters)
Agent Cognition Loop
Each tick per agent: OBSERVE β REFLECT β PLAN β ACT β REMEMBER
Conventions
- All async (LLM calls are I/O-bound)
- Dataclasses with
to_dict()/from_dict()for serialization - YAML config for city layout and personas
- Cost tracking built into LLM client