RayMelius Claude Sonnet 4.6 commited on
Commit
dcb07bb
Β·
1 Parent(s): 31ab3b5

Add README with setup, LAN access, and architecture docs

Browse files

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

Files changed (1) hide show
  1. README.md +143 -0
README.md ADDED
@@ -0,0 +1,143 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Soci β€” LLM-Powered City Population Simulator
2
+
3
+ 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.
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 sentiment
14
+ - Agent cognition loop: **OBSERVE β†’ REFLECT β†’ PLAN β†’ ACT β†’ REMEMBER**
15
+ - Web UI with animated city map, zoom, pan, and agent inspector
16
+ - Romance and social dynamics
17
+ - Speed controls and real-time WebSocket updates
18
+ - Cost-efficient model routing (Haiku for routine, Sonnet for novel situations)
19
+
20
+ ---
21
+
22
+ ## Tech Stack
23
+
24
+ - Python 3.10+ (Anaconda ml-env)
25
+ - Anthropic Claude API
26
+ - FastAPI + WebSocket
27
+ - SQLite via aiosqlite
28
+ - Rich (terminal dashboard)
29
+ - YAML config
30
+
31
+ ---
32
+
33
+ ## Setup
34
+
35
+ 1. **Clone the repo**
36
+ ```bash
37
+ git clone https://github.com/Bonum/Soci.git
38
+ cd Soci
39
+ ```
40
+
41
+ 2. **Install dependencies** (inside your Python environment)
42
+ ```bash
43
+ pip install -r requirements.txt
44
+ ```
45
+
46
+ 3. **Set your Anthropic API key**
47
+ ```bash
48
+ export ANTHROPIC_API_KEY=sk-...
49
+ ```
50
+
51
+ ---
52
+
53
+ ## Running
54
+
55
+ ### Terminal simulation
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 127.0.0.1 --port 8000
63
+ ```
64
+ Then open `http://localhost:8000` in your browser.
65
+
66
+ ### Web UI (accessible from LAN)
67
+ ```bash
68
+ python -m uvicorn soci.api.server:app --host 0.0.0.0 --port 8000
69
+ ```
70
+ Then from any device on your network, open `http://<host-ip>:8000`.
71
+
72
+ ---
73
+
74
+ ## Accessing from Another Computer on LAN
75
+
76
+ 1. Start the server with `--host 0.0.0.0` (see above).
77
+
78
+ 2. Find your host machine's local IP:
79
+ ```bash
80
+ # Windows
81
+ ipconfig
82
+ # Look for IPv4 Address, e.g. 192.168.1.42
83
+ ```
84
+
85
+ 3. Allow port 8000 through Windows Firewall (if needed):
86
+ ```bash
87
+ netsh advfirewall firewall add rule name="Soci Port 8000" dir=in action=allow protocol=TCP localport=8000
88
+ ```
89
+
90
+ 4. From any device on the same network, open:
91
+ ```
92
+ http://192.168.1.42:8000
93
+ ```
94
+
95
+ ---
96
+
97
+ ## Architecture
98
+
99
+ ```
100
+ 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 management, LLM client
105
+ persistence/ β€” SQLite database, save/load snapshots
106
+ api/ β€” FastAPI REST + WebSocket server
107
+ config/
108
+ city.yaml β€” City layout (12 locations)
109
+ personas.yaml β€” Character definitions (20 agents)
110
+ ```
111
+
112
+ ---
113
+
114
+ ## Web UI Controls
115
+
116
+ | Action | How |
117
+ |---|---|
118
+ | Zoom | Scroll wheel or +/- buttons |
119
+ | Fit view | Fit button |
120
+ | Pan | Drag canvas or use sliders |
121
+ | Rectangle select | Click ⬚ button, then drag |
122
+
123
+ ---
124
+
125
+ ## Agent Cognition
126
+
127
+ Each simulation tick, every agent runs:
128
+
129
+ ```
130
+ OBSERVE β€” perceive nearby agents, objects, events
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
+
137
+ Memory entries are scored by importance (1–10) with recency decay, retrieved by relevance score.
138
+
139
+ ---
140
+
141
+ ## License
142
+
143
+ MIT