soci2 / CLAUDE.md
RayMelius's picture
Initial implementation of Soci city population simulator
59edb07

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 events
  • src/soci/agents/ β€” Agent cognition: persona, memory, needs, relationships
  • src/soci/actions/ β€” Action types: movement, activities, conversation, social
  • src/soci/engine/ β€” Simulation loop, scheduler, entropy management, LLM client
  • src/soci/persistence/ β€” SQLite database, save/load snapshots
  • src/soci/api/ β€” FastAPI REST + WebSocket server
  • config/ β€” 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