Skip to content

Commit 1e1e038

Browse files
committed
README: front door for the whole repo (Micropolis, VitaMoo, Screen Angel); build details moved to DEVELOPMENT.md
1 parent f9e867d commit 1e1e038

3 files changed

Lines changed: 260 additions & 423 deletions

File tree

‎DEVELOPMENT.md‎

Lines changed: 156 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,19 @@ Or use the VS Code **Debug Micropolis SvelteKit App** launch config (`.vscode/la
7373

7474
```
7575
apps/
76-
micropolis/ SvelteKit city simulation app (WebGL tile renderer, WASM bridge)
76+
micropolis/ SvelteKit city simulation app (WebGL tile renderer, WASM bridge, CLI)
7777
vitamoospace/ SvelteKit Sims character demo (WebGPU renderer)
78+
screen-angel/ Electron overlay: selectors and recognition over other apps (source-available)
79+
yoot/ Placeholder for a tower-sim web app
7880
packages/
7981
micropolis-engine/ C++/Emscripten WASM engine (GNU make, no CMake)
8082
tile-renderer/ Canvas/WebGL/WebGPU tile renderer backends
83+
render-core/ Shared viewport, render schemas, WebGPU compositor
8184
vitamoo/ Sims animation core (TypeScript)
8285
mooshow/ GPU stage, picking, camera, hooks (TypeScript)
86+
sims-io/ Sims 1 file I/O: FAR, IFF, save data
87+
optical-codec/ Reader and test bench for Screen Angel's optical channel
88+
skills/ MOOLLM skills: micropolis, micropolis-command-bus
8389
content/
8490
micropolis/ City saves, tilesets, sounds
8591
vitamoo/ Sims demo assets (CMX/SKN/BMP/CFP)
@@ -90,6 +96,155 @@ documentation/
9096
notes/ Developer notes and CLI cheat sheets
9197
```
9298

99+
## Installing Emscripten
100+
101+
The engine build uses Emscripten/Embind. If `emcc --version` does not work, install `emsdk`:
102+
103+
```bash
104+
# Pick a parent directory for developer tools.
105+
mkdir -p ~/Developer
106+
cd ~/Developer
107+
108+
git clone https://github.com/emscripten-core/emsdk.git
109+
cd emsdk
110+
./emsdk install latest
111+
./emsdk activate latest
112+
113+
# Activate for the current shell.
114+
source ./emsdk_env.sh
115+
emcc --version
116+
```
117+
118+
To make Emscripten available in future shells, add this to your shell startup file:
119+
120+
```bash
121+
source ~/Developer/emsdk/emsdk_env.sh
122+
```
123+
124+
If you prefer not to auto-activate it in every shell, run that `source` command only before rebuilding the engine.
125+
126+
On macOS with Homebrew, this also works:
127+
128+
```bash
129+
brew install emscripten
130+
emcc --version
131+
```
132+
133+
134+
## The WASM engine
135+
136+
The engine is a **pnpm workspace package** (`@micropolis/engine-wasm` in `packages/micropolis-engine/`). It is still built with **GNU make** and **Emscripten** (no CMake). A normal **`pnpm --filter micropolis run build`** runs **`prebuild`**, which invokes **`pnpm --filter @micropolis/engine-wasm run build`** → **`make install`** in that directory.
137+
138+
To rebuild the engine only:
139+
140+
```bash
141+
cd packages/micropolis-engine
142+
make clean install
143+
```
144+
145+
Or from the repo root:
146+
147+
```bash
148+
pnpm --filter @micropolis/engine-wasm run build
149+
```
150+
151+
`make install` builds the C++ engine and copies these generated artifacts into `apps/micropolis/src/lib/`:
152+
153+
```text
154+
micropolisengine.js
155+
micropolisengine.wasm
156+
micropolisengine.data
157+
```
158+
159+
The checked-in makefile builds the engine for browser, worker, and Node environments:
160+
161+
```text
162+
-s 'ENVIRONMENT=web,worker,node'
163+
```
164+
165+
Node support is required for `pnpm --filter micropolis run micropolis -- sim ...` (or `cd apps/micropolis && pnpm run micropolis -- sim ...`).
166+
167+
168+
## The micropolis CLI
169+
170+
The `micropolis` CLI reads, analyzes, visualizes, edits, and patches `.cty` save files, runs the WASM simulator headlessly, and exposes the command bus.
171+
172+
Run from the `apps/micropolis/` package directory after `pnpm install` at the repo root (or prefix with `pnpm --filter micropolis run` from the MicropolisCore root).
173+
174+
```bash
175+
cd apps/micropolis
176+
177+
# City information and analysis (paths relative to this directory)
178+
pnpm run micropolis -- city info ../../content/micropolis/cities/scenario_tokyo.cty
179+
pnpm run micropolis -- city analyze ../../content/micropolis/cities/scenario_boston.cty
180+
pnpm run micropolis -- city analyze --format json ../../content/micropolis/cities/radial.cty
181+
182+
# Visualize as ASCII, emoji, or monospace
183+
pnpm run micropolis -- visualize ascii --row 20 --col 30 --width 30 --height 15 ../../content/micropolis/cities/scenario_tokyo.cty
184+
pnpm run micropolis -- visualize emoji ../../content/micropolis/cities/radial.cty
185+
186+
# Edit city metadata
187+
pnpm run micropolis -- city edit city.cty --funds 50000 --tax 9 --year 1960
188+
189+
# Patch scenario files with the values the engine injects at runtime
190+
pnpm run micropolis -- city patch-scenario ../../content/micropolis/cities/scenario_tokyo.cty --dry-run
191+
192+
# Export to JSON (with optional tile map data)
193+
pnpm run micropolis -- city export --format json --include-map city.cty
194+
195+
# Pipe from stdin
196+
cat city.cty | pnpm run micropolis -- city info -
197+
```
198+
199+
Full test suite and command reference: [documentation/notes/micropolis-js-tests.md](documentation/notes/micropolis-js-tests.md)
200+
201+
202+
## How the engine talks to the UI
203+
204+
The WASM engine talks to the Svelte UI through a callback chain:
205+
206+
```
207+
C++ Micropolis Core (WASM)
208+
calls callback
209+
Embind JSCallback Wrapper
210+
delegates
211+
MicropolisReactive.engineCallback
212+
updates
213+
$state / $derived Runes
214+
triggers
215+
Svelte 5 Runtime
216+
updates DOM
217+
UI Components + WebGL Renderer
218+
```
219+
220+
221+
## Working alongside MOOLLM
222+
223+
Soul City ties this repository to [MOOLLM](https://github.com/SimHacker/moollm) — the microworld skill framework where the **micropolis** skill, AI tutors, and related designs live. To work across engine code, the SvelteKit app, and MOOLLM skills in one flow:
224+
225+
1. **Check out MOOLLM and MicropolisCore in the same directory** (sibling folders under one parent, e.g. `~/Developer/` or `~/src/`):
226+
227+
```bash
228+
mkdir -p ~/Developer && cd ~/Developer
229+
git clone https://github.com/SimHacker/MicropolisCore.git
230+
git clone https://github.com/SimHacker/moollm.git
231+
```
232+
233+
Keeping them side-by-side makes paths predictable and matches how multi-root workspaces list folders.
234+
235+
2. **Add both repositories to your Cursor workspace** — and any other related checkouts you use (e.g. SimObliterator Suite for VitaMoo, design-only repos): use **File → Add Folder to Workspace…** (or your OS equivalent) and include each repo root, or open a multi-root `.code-workspace` file that lists those paths. Cursor can index and search across all of them together.
236+
237+
3. **Follow MOOLLM’s setup and install instructions first** (clone is already done if you used step 1):
238+
239+
- [MOOLLM README — Quick Start](https://github.com/SimHacker/moollm#quick-start)
240+
- [MOOLLM QUICKSTART.md](https://github.com/SimHacker/moollm/blob/main/QUICKSTART.md) — open the repo in Cursor and wait until **Settings → Cursor Settings → Indexing → Codebase Indexing** reaches **100%**, as in MOOLLM’s quickstart.
241+
242+
4. **Then** install and build MicropolisCore using the prerequisites and commands below (Emscripten, `pnpm`, WASM engine, `micropolis` app).
243+
244+
Using the same layout with **other AI coding tools** (for example **Claude Code**) is plausible so both trees stay in context, but that workflow is **not yet tested or documented** here—Cursor + MOOLLM is the supported path today.
245+
246+
MOOLLM does not replace the Node/pnpm toolchain here; it complements this repo for skills, YAML Jazz, and agent orchestration alongside the engine and web app.
247+
93248
## CI workflows
94249

95250
| Workflow | Trigger | What it does |

0 commit comments

Comments
 (0)