Update README for v0.7.0
Browse files- Document player login, NPC chat, road routing, animations
- Add environment variables table
- Add Render deployment guide with ignore command
- Add Player Mode section with usage instructions
- Update live demo URL and feature list
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
README.md
CHANGED
|
@@ -1,31 +1,36 @@
|
|
| 1 |
# Soci β LLM-Powered City Population Simulator
|
| 2 |
|
| 3 |
-
Simulates a diverse population of AI people living in a city using
|
| 4 |
|
| 5 |
Inspired by [Stanford Generative Agents (Joon Park et al.)](https://arxiv.org/abs/2304.03442), CitySim, AgentSociety, and a16z ai-town.
|
| 6 |
|
|
|
|
|
|
|
| 7 |
---
|
| 8 |
|
| 9 |
## Features
|
| 10 |
|
| 11 |
- AI agents with unique personas, goals, and memories
|
| 12 |
- Maslow-inspired needs system (hunger, energy, social, purpose, comfort, fun)
|
| 13 |
-
- Relationship graph with familiarity, trust, and
|
| 14 |
- Agent cognition loop: **OBSERVE β REFLECT β PLAN β ACT β REMEMBER**
|
| 15 |
- Web UI with animated city map, zoom, pan, and agent inspector
|
| 16 |
-
-
|
| 17 |
-
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
- Cost-efficient model routing (Haiku for routine, Sonnet for novel situations)
|
| 19 |
|
| 20 |
---
|
| 21 |
|
| 22 |
## Tech Stack
|
| 23 |
|
| 24 |
-
- Python 3.10+
|
| 25 |
-
- Anthropic Claude API
|
| 26 |
- FastAPI + WebSocket
|
| 27 |
- SQLite via aiosqlite
|
| 28 |
-
- Rich (terminal dashboard)
|
| 29 |
- YAML config
|
| 30 |
|
| 31 |
---
|
|
@@ -38,60 +43,65 @@ Inspired by [Stanford Generative Agents (Joon Park et al.)](https://arxiv.org/ab
|
|
| 38 |
cd Soci
|
| 39 |
```
|
| 40 |
|
| 41 |
-
2. **Install dependencies**
|
| 42 |
```bash
|
| 43 |
pip install -r requirements.txt
|
| 44 |
```
|
| 45 |
|
| 46 |
-
3. **Set your
|
| 47 |
```bash
|
| 48 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 49 |
```
|
| 50 |
|
| 51 |
---
|
| 52 |
|
| 53 |
## Running
|
| 54 |
|
| 55 |
-
###
|
| 56 |
-
```bash
|
| 57 |
-
python main.py --ticks 20 --agents 5
|
| 58 |
-
```
|
| 59 |
-
|
| 60 |
-
### Web UI (local only)
|
| 61 |
```bash
|
| 62 |
-
python -m uvicorn soci.api.server:app --host
|
| 63 |
```
|
| 64 |
-
|
| 65 |
|
| 66 |
-
###
|
| 67 |
```bash
|
| 68 |
-
python
|
| 69 |
```
|
| 70 |
-
Then from any device on your network, open `http://<host-ip>:8000`.
|
| 71 |
|
| 72 |
---
|
| 73 |
|
| 74 |
-
##
|
| 75 |
|
| 76 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 77 |
|
| 78 |
-
|
| 79 |
-
```bash
|
| 80 |
-
# Windows
|
| 81 |
-
ipconfig
|
| 82 |
-
# Look for IPv4 Address, e.g. 192.168.1.42
|
| 83 |
-
```
|
| 84 |
|
| 85 |
-
|
| 86 |
-
```bash
|
| 87 |
-
netsh advfirewall firewall add rule name="Soci Port 8000" dir=in action=allow protocol=TCP localport=8000
|
| 88 |
-
```
|
| 89 |
|
| 90 |
-
|
|
|
|
|
|
|
|
|
|
| 91 |
```
|
| 92 |
-
|
| 93 |
```
|
| 94 |
|
|
|
|
|
|
|
| 95 |
---
|
| 96 |
|
| 97 |
## Architecture
|
|
@@ -101,36 +111,58 @@ src/soci/
|
|
| 101 |
world/ β City map, simulation clock, world events
|
| 102 |
agents/ β Agent cognition: persona, memory, needs, relationships
|
| 103 |
actions/ β Movement, activities, conversation, social actions
|
| 104 |
-
engine/ β Simulation loop, scheduler, entropy
|
| 105 |
persistence/ β SQLite database, save/load snapshots
|
| 106 |
api/ β FastAPI REST + WebSocket server
|
| 107 |
config/
|
| 108 |
-
city.yaml β City layout
|
| 109 |
-
personas.yaml β
|
|
|
|
|
|
|
| 110 |
```
|
| 111 |
|
| 112 |
---
|
| 113 |
|
| 114 |
-
## Web UI
|
| 115 |
|
| 116 |
| Action | How |
|
| 117 |
-
|---|---|
|
| 118 |
-
| Zoom | Scroll wheel or +/
|
| 119 |
| Fit view | Fit button |
|
| 120 |
| Pan | Drag canvas or use sliders |
|
| 121 |
-
| Rectangle
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 122 |
|
| 123 |
---
|
| 124 |
|
| 125 |
## Agent Cognition
|
| 126 |
|
| 127 |
-
Each simulation tick, every agent runs:
|
| 128 |
|
| 129 |
```
|
| 130 |
-
OBSERVE β perceive nearby agents,
|
| 131 |
REFLECT β update beliefs and emotional state
|
| 132 |
PLAN β decide what to do next
|
| 133 |
-
ACT β execute action (move, talk, work, restβ¦)
|
| 134 |
REMEMBER β store important events to memory stream
|
| 135 |
```
|
| 136 |
|
|
|
|
| 1 |
# Soci β LLM-Powered City Population Simulator
|
| 2 |
|
| 3 |
+
Simulates a diverse population of AI people living in a city using an LLM as the reasoning engine. Each agent has a unique persona, memory stream, needs, and relationships.
|
| 4 |
|
| 5 |
Inspired by [Stanford Generative Agents (Joon Park et al.)](https://arxiv.org/abs/2304.03442), CitySim, AgentSociety, and a16z ai-town.
|
| 6 |
|
| 7 |
+
**Live demo:** https://soci-tl3c.onrender.com
|
| 8 |
+
|
| 9 |
---
|
| 10 |
|
| 11 |
## Features
|
| 12 |
|
| 13 |
- AI agents with unique personas, goals, and memories
|
| 14 |
- Maslow-inspired needs system (hunger, energy, social, purpose, comfort, fun)
|
| 15 |
+
- Relationship graph with familiarity, trust, sentiment, and romance
|
| 16 |
- Agent cognition loop: **OBSERVE β REFLECT β PLAN β ACT β REMEMBER**
|
| 17 |
- Web UI with animated city map, zoom, pan, and agent inspector
|
| 18 |
+
- Road-based movement with L-shaped routing (agents walk along streets)
|
| 19 |
+
- Agent animations: walking (profile/back view), sleeping on bed
|
| 20 |
+
- Speed controls (1x β 50x) and real-time WebSocket sync across browsers
|
| 21 |
+
- **Player login** β register an account, get your own agent on the map, chat with NPCs
|
| 22 |
+
- Multi-LLM support: Groq (free tier), Anthropic Claude, Ollama (local)
|
| 23 |
+
- GitHub-based state persistence (survives server reboots and redeploys)
|
| 24 |
- Cost-efficient model routing (Haiku for routine, Sonnet for novel situations)
|
| 25 |
|
| 26 |
---
|
| 27 |
|
| 28 |
## Tech Stack
|
| 29 |
|
| 30 |
+
- Python 3.10+
|
| 31 |
+
- Anthropic Claude API / Groq / Ollama
|
| 32 |
- FastAPI + WebSocket
|
| 33 |
- SQLite via aiosqlite
|
|
|
|
| 34 |
- YAML config
|
| 35 |
|
| 36 |
---
|
|
|
|
| 43 |
cd Soci
|
| 44 |
```
|
| 45 |
|
| 46 |
+
2. **Install dependencies**
|
| 47 |
```bash
|
| 48 |
pip install -r requirements.txt
|
| 49 |
```
|
| 50 |
|
| 51 |
+
3. **Set your API key** (choose one provider)
|
| 52 |
```bash
|
| 53 |
+
# Groq (free tier β recommended for cloud)
|
| 54 |
+
export GROQ_API_KEY=gsk_...
|
| 55 |
+
|
| 56 |
+
# Anthropic Claude
|
| 57 |
+
export ANTHROPIC_API_KEY=sk-ant-...
|
| 58 |
```
|
| 59 |
|
| 60 |
---
|
| 61 |
|
| 62 |
## Running
|
| 63 |
|
| 64 |
+
### Web UI (local)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 65 |
```bash
|
| 66 |
+
python -m uvicorn soci.api.server:app --host 0.0.0.0 --port 8000
|
| 67 |
```
|
| 68 |
+
Open `http://localhost:8000` in your browser.
|
| 69 |
|
| 70 |
+
### Terminal simulation (no UI)
|
| 71 |
```bash
|
| 72 |
+
python main.py --ticks 20 --agents 5
|
| 73 |
```
|
|
|
|
| 74 |
|
| 75 |
---
|
| 76 |
|
| 77 |
+
## Environment Variables
|
| 78 |
|
| 79 |
+
| Variable | Default | Description |
|
| 80 |
+
|----------|---------|-------------|
|
| 81 |
+
| `SOCI_PROVIDER` | auto-detect | LLM provider: `groq`, `claude`, `ollama` |
|
| 82 |
+
| `GROQ_API_KEY` | β | Groq API key |
|
| 83 |
+
| `ANTHROPIC_API_KEY` | β | Anthropic API key |
|
| 84 |
+
| `SOCI_AGENTS` | `50` | Starting agent count |
|
| 85 |
+
| `SOCI_TICK_DELAY` | `0.5` | Seconds between simulation ticks |
|
| 86 |
+
| `SOCI_DATA_DIR` | `data` | Directory for SQLite DB and snapshots |
|
| 87 |
+
| `GITHUB_TOKEN` | β | GitHub PAT for state persistence across deploys |
|
| 88 |
+
| `GITHUB_REPO` | β | `owner/repo` for state persistence |
|
| 89 |
+
| `GITHUB_STATE_BRANCH` | `simulation-state` | Branch used for state (never touches main) |
|
| 90 |
|
| 91 |
+
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 92 |
|
| 93 |
+
## Deploying to Render (free tier)
|
|
|
|
|
|
|
|
|
|
| 94 |
|
| 95 |
+
1. Connect your GitHub repo in Render.
|
| 96 |
+
2. Set **Start Command**: `python -m uvicorn soci.api.server:app --host 0.0.0.0 --port $PORT`
|
| 97 |
+
3. Set env vars: `SOCI_PROVIDER`, `GROQ_API_KEY` (or `ANTHROPIC_API_KEY`), `GITHUB_TOKEN`, `GITHUB_REPO`
|
| 98 |
+
4. Add an **Ignore Command** to prevent state-file commits from triggering redeploys:
|
| 99 |
```
|
| 100 |
+
[ "$(git diff --name-only HEAD~1 HEAD | grep -v '^state/' | wc -l)" = "0" ]
|
| 101 |
```
|
| 102 |
|
| 103 |
+
Simulation state is automatically saved to a `simulation-state` branch on shutdown and restored on the next startup β no persistent disk required.
|
| 104 |
+
|
| 105 |
---
|
| 106 |
|
| 107 |
## Architecture
|
|
|
|
| 111 |
world/ β City map, simulation clock, world events
|
| 112 |
agents/ β Agent cognition: persona, memory, needs, relationships
|
| 113 |
actions/ β Movement, activities, conversation, social actions
|
| 114 |
+
engine/ β Simulation loop, scheduler, entropy, LLM client
|
| 115 |
persistence/ β SQLite database, save/load snapshots
|
| 116 |
api/ β FastAPI REST + WebSocket server
|
| 117 |
config/
|
| 118 |
+
city.yaml β City layout and building positions
|
| 119 |
+
personas.yaml β Named character definitions
|
| 120 |
+
web/
|
| 121 |
+
index.html β Single-file web UI
|
| 122 |
```
|
| 123 |
|
| 124 |
---
|
| 125 |
|
| 126 |
+
## Web UI
|
| 127 |
|
| 128 |
| Action | How |
|
| 129 |
+
|--------|-----|
|
| 130 |
+
| Zoom | Scroll wheel or +/β buttons |
|
| 131 |
| Fit view | Fit button |
|
| 132 |
| Pan | Drag canvas or use sliders |
|
| 133 |
+
| Rectangle zoom | Click β¬, then drag |
|
| 134 |
+
| Inspect agent | Click agent on map or in list |
|
| 135 |
+
| **Login / play** | Register β your agent appears on the map |
|
| 136 |
+
| **Talk to NPC** | Select any agent β "Talk to [Name]" button |
|
| 137 |
+
| **Move** | Player panel β location dropdown β Go |
|
| 138 |
+
| **Edit profile** | Player panel β Edit Profile |
|
| 139 |
+
| **Add plans** | Player panel β My Plans |
|
| 140 |
+
|
| 141 |
+
---
|
| 142 |
+
|
| 143 |
+
## Player Mode
|
| 144 |
+
|
| 145 |
+
Register an account to join the simulation as a participant:
|
| 146 |
+
|
| 147 |
+
1. Click **Register** in the login modal (or skip to observe only).
|
| 148 |
+
2. Your agent appears immediately on the map with a **gold ring** to identify you.
|
| 149 |
+
3. Click **Edit Profile** to set your name, age, occupation, background, and personality traits.
|
| 150 |
+
4. Click any NPC β **Talk to [Name]** to start a conversation β they reply in character via LLM.
|
| 151 |
+
5. Use **My Plans** to add goals (e.g. *"Go to the park and meet new people"*).
|
| 152 |
+
|
| 153 |
+
Multiple users can be logged in simultaneously β each controls their own agent.
|
| 154 |
|
| 155 |
---
|
| 156 |
|
| 157 |
## Agent Cognition
|
| 158 |
|
| 159 |
+
Each simulation tick, every NPC agent runs:
|
| 160 |
|
| 161 |
```
|
| 162 |
+
OBSERVE β perceive nearby agents, events, environment
|
| 163 |
REFLECT β update beliefs and emotional state
|
| 164 |
PLAN β decide what to do next
|
| 165 |
+
ACT β execute action (move, talk, work, rest, sleepβ¦)
|
| 166 |
REMEMBER β store important events to memory stream
|
| 167 |
```
|
| 168 |
|