Skip to content

A town simulation in pale isometric line art, implemented with Ritmo ECS and PixiJs 3D

Move sources into game, view, ui, render, platform, app and labs layers

SandroMaglione45d9f103c56f
diff --git a/.oxlintrc.json b/.oxlintrc.json
index 89c60bd..f35a61f 100644
--- a/.oxlintrc.json
+++ b/.oxlintrc.json
@@ -13,18 +13,7 @@
},
"overrides": [
{
- "files": [
- "src/sim/**",
- "src/rules/**",
- "src/grid.ts",
- "src/mapgen.ts",
- "src/places.ts",
- "src/appeal.ts",
- "src/content.ts",
- "src/schema.ts",
- "src/archetypes.ts",
- "src/iso.ts"
- ],
+ "files": ["src/game/**"],
"rules": {
"ritmo/use-clock-for-time": "error",
"ritmo/use-random-for-randomness": "error",
diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md
index cc4ac06..310b4bf 100644
--- a/DEVELOPMENT.md
+++ b/DEVELOPMENT.md
@@ -39,11 +39,11 @@ it, and two fingers move the camera under it. With any pointer, a stroke let
go off the map (over the tool bar, say) is dropped and shows red while it
would be, as are a right click or Esc mid-drag. On touch the tooltip shows
only for what is about to be built, never while panning or picking, in a
-thin full-width strip under the top line. This lives entirely in `src/render3d/input.ts`
+thin full-width strip under the top line. This lives entirely in `src/render/three/input.ts`
(and the bar in `host.ts`); the game still sees one ordinary press and
release.
-Phones get their layout from `src/phone.css`, loaded after `factory.css`. On
+Phones get their layout from `src/ui/dom/styles/phone.css`, loaded after `factory.css`. On
a narrow or short screen the HUD folds away: one top line (clock, treasury,
people, and a chip of planks, stone and tools), one tool bar along the bottom
(town, the tools, pause (a switch: play while paused), a speed button that cycles, and a ⋯ menu holding
@@ -54,7 +54,7 @@ folds it, a pan or pinch does not. Once the town has a minute of goods
(`body.flow-ready`), the goods chip opens the made/used table straight away,
each good by its icon. The guide's step stays above the tool bar until tucked away
(its ✕); tucked, the bulb pulses, and a new step (or the same one under way)
-comes out again. Guide texts in `src/rules/guide.ts` name tools,
+comes out again. Guide texts in `src/game/rules/guide.ts` name tools,
panels and map views as `[homes]`, `[town]` or `[view:fire]` and verbs as
`{tap|click}`, never keys, so they read right on either screen;
`test/guide.test.ts` checks it. Sheets
@@ -64,7 +64,7 @@ to the bottom. The camera bar is hidden: pinch zooms and turns. New UI needs
nothing there unless it has to move on a phone; check it at 390×844, 360×640
and 762×330, and run `pnpm check:phone`.
-`src/render3d/scene.ts` owns the orthographic camera, ground projection and
+`src/render/three/scene.ts` owns the orthographic camera, ground projection and
frame source. `views.ts` follows live construction, upgrades, resources,
production, problem markers and the simulation's walkers and cargo. Flags,
mill sails and smoke animate in 3D. `pool.ts` instances repeated geometry,
@@ -133,7 +133,7 @@ Material effects render in the viewers and live game. Ordinary GLB viewers
show the underlying mesh; effect parameters are preserved as GLB extras and
in the editable geometry descriptions, rather than baked into duplicate meshes.
-- `src/asset-lab/primitives.ts`: renderer-independent polygon/stroke schema
+- `src/render/three/assets/primitives.ts`: renderer-independent polygon/stroke schema
and reusable modelling operations in the game's cell units and pixel heights.
- `buildings.ts`, `land.ts`, `people.ts`, `construction.ts`: procedural
models; `assets.ts` collects them and retains the approved house/prop models.
@@ -199,31 +199,31 @@ The README shows the film as an animated AVIF, because GitHub plays no
## Code
-- `src/iso.ts`: the grid and the unit everything is measured in (1/16 cell = 2×1 px).
-- `src/content.ts`: goods, building kinds, home tiers, costs, upkeep, taxes: plain data.
-- `src/archetypes.ts`: content to components.
-- `src/mapgen.ts`: the land of a new town, from its charter.
-- `src/schema.ts`: the ECS world: components, relations, resources, services.
-- `src/appeal.ts`: desirability: what buildings and the land do to the cells around them, the whole grid, and one cell explained.
-- `src/places.ts`: street names for the news ("Mill Lane"), from the nearest landmark.
-- `src/grid.ts`: occupancy, entrances, reach, and road paths.
+- `src/game/world/iso.ts`: the grid and the unit everything is measured in (1/16 cell = 2×1 px).
+- `src/game/content/index.ts`: goods, building kinds, home tiers, costs, upkeep, taxes: plain data.
+- `src/game/world/archetypes.ts`: content to components.
+- `src/game/world/mapgen.ts`: the land of a new town, from its charter.
+- `src/game/schema.ts`: the ECS world: components, relations, resources, services.
+- `src/game/world/appeal.ts`: desirability: what buildings and the land do to the cells around them, the whole grid, and one cell explained.
+- `src/game/world/places.ts`: street names for the news ("Mill Lane"), from the nearest landmark.
+- `src/game/world/grid.ts`: occupancy, entrances, reach, and road paths.
- `src/sim/`: the fixed-step simulation (no renderer access): edits, work (staffing by crew and commute, tools,
pace), logistics, walkers (services, mending), town (households and tiers), hazards (desirability, risk
meters, fire and firefighters, sickness, theft), decay (wear, collapse, spoilage, the pantry), and the term
(seasons and the almanac, the crown, approval, the end of the term, history); orphans drops a walker or field
whose building went before it could join it.
-- `src/present.ts`: per-frame interaction, panel, and view sync.
-- `src/art.ts`: all drawing: buildings and their yards, homes, the land, roads, carts, and figures.
+- `src/view/present.ts`: per-frame interaction, panel, and view sync.
+- `src/render/art.ts`: all drawing: buildings and their yards, homes, the land, roads, carts, and figures.
- `src/render3d/`: live world renderer, model instances, camera and map input,
overlays, ruins, surface shaders and roof particle emitters.
-- `src/asset-lab/town-props.ts`: parks (ground and furnishings, drawn cell by cell), stone paving and ruins.
-- `src/asset-lab/services.ts`: grain hoist, fish racks, watch tower, herbs,
+- `src/render/three/assets/town-props.ts`: parks (ground and furnishings, drawn cell by cell), stone paving and ruins.
+- `src/render/three/assets/services.ts`: grain hoist, fish racks, watch tower, herbs,
medical signs, street noticeboard and builder's equipment.
- `src/share/`: sharing a town: the card it is shared as (`card.ts`), the format and limits the page and the
server agree on (`format.ts`), and the page's side: uploading, fetching, and the device's share sheet (`client.ts`).
- `src/server/`: the only server code: the routes behind shared towns (`handler.ts`), the Cloudflare Worker that
runs them (`worker.ts`), and the same routes under `pnpm dev`, over a bucket in memory (`dev.ts`).
-- `src/asset-lab/appearance.ts`: material state metadata for catalogue presets.
+- `src/render/three/assets/appearance.ts`: material state metadata for catalogue presets.
Wear, neighbourhood, hazards and winter are per-instance attributes in the
live renderer. A state change does not change the geometry cache key.
@@ -231,20 +231,20 @@ The README shows the film as an animated AVIF, because GitHub plays no
[`/model-review.html?collection=town`](http://localhost:5232/model-review.html?collection=town)
shows all 23 building kinds plus the market hall and church upgrades. The final
-nine refinements are grouped at `?collection=rural`. `src/asset-lab/rural.ts`
+nine refinements are grouped at `?collection=rural`. `src/render/three/assets/rural.ts`
owns timber entrances, nursery and farm fittings, chapel porches, granary louvres
and the supported fire-watch access route. The same geometry is used in the game,
catalogue, model sheets and GLB exports.
[`/model-review.html?collection=trades`](http://localhost:5232/model-review.html?collection=trades)
groups the mill, warehouse, fishery, bakery, weaver and watch house revisions.
-`src/asset-lab/trades.ts` owns their equipment, loading doors, open yards and the
+`src/render/three/assets/trades.ts` owns their equipment, loading doors, open yards and the
bakery smoke origin. The mill keeps its animated sails. Cargo sits on the ground
or loading apron, and the four new yard layouts turn towards connected roads.
[`/model-review.html?collection=workshops`](http://localhost:5232/model-review.html?collection=workshops)
groups the revised mine, smithy, sawmill and town hall. The three workshops have
-open yards and road-facing layouts. `src/asset-lab/workshops.ts` owns their
+open yards and road-facing layouts. `src/render/three/assets/workshops.ts` owns their
geometry, construction frames and smoke origins. The live renderer and catalogue
use the same models; simulation footprints and building costs are unchanged.
@@ -310,13 +310,13 @@ the actual basin. Park rendering in the game, catalogue, map and preview shares
the same emitter metadata and water renderer. `pnpm check:park` verifies the
rendered animation, pause, camera controls and phone layout, and captures stills
and a five-second MP4 in `output/inkline-3d/park-review/`.
-- `src/townsfolk.ts`: residents out walking, for looking at only: not simulated, not saved.
-- `src/icons.ts`: the page's line-drawn icons.
-- `src/gallery.ts`: the dev-only art gallery (see above).
-- `src/sim/headless.ts`: a town with no page, stepped from code: what the tests, `check`, and `balance` play.
-- `src/save.ts`: saving and loading as [Effect](https://effect.website) programs: a versioned file in a slot
+- `src/render/three/townsfolk.ts`: residents out walking, for looking at only: not simulated, not saved.
+- `src/ui/dom/kit/icons.ts`: the page's line-drawn icons.
+- `src/labs/gallery/main.ts`: the dev-only art gallery (see above).
+- `src/game/headless.ts`: a town with no page, stepped from code: what the tests, `check`, and `balance` play.
+- `src/platform/save.ts`: saving and loading as [Effect](https://effect.website) programs: a versioned file in a slot
(the mayor's own, or the autosave), typed errors for each way a load can fail.
-- `src/ui.ts`, `src/host.ts`, `src/main.ts`: the page bridge, camera, input, panels, and start-up.
+- `src/view/contracts.ts`, `src/ui/dom/host.ts`, `src/app/browser.ts`: the page bridge, camera, input, panels, and start-up.
The simulation runs on Ritmo's `FixedLoop` at 60 steps a second (times the
chosen speed), with integer state and a seeded random resource: `Town/Rng`,
@@ -403,7 +403,7 @@ share sheet instead. **Make a link** uploads the town (its save file, gzipped,
with the camera) and a JPEG of the card; `/t/<id>` then opens the game on that
town, running, with the building tools put away until the visitor chooses
**Play from here** (the town becomes theirs and autosaves) or founds their own.
-A shared town loads through `loadText` in `src/save.ts`, so it is checked and
+A shared town loads through `loadText` in `src/platform/save.ts`, so it is checked and
carried forward between save versions exactly as a save is.
The server (`src/server/handler.ts`) keeps each share as two files in an R2
@@ -429,11 +429,11 @@ works locally and `pnpm check:browser` checks it end to end.
## Testing
-The simulation has no renderer in it: it runs headless (`src/sim/headless.ts`),
+The simulation has no renderer in it: it runs headless (`src/game/headless.ts`),
about 60 to 80 times faster than real time, so the tests play real towns.
`pnpm test` also runs `test/legibility.test.ts`: when a home is stuck, the
-panel's reasons (`src/rules/explain.ts`) must name the cause in words,
+panel's reasons (`src/game/rules/explain.ts`) must name the cause in words,
checked against the usual dead ends and a real town with cottages beside a
quarry. The bots know the thresholds; the player only has the panel.
diff --git a/asset-lab.html b/asset-lab.html
index e01f607..7b02903 100644
--- a/asset-lab.html
+++ b/asset-lab.html
@@ -8,6 +8,6 @@
</head>
<body>
<main id="lab"></main>
- <script type="module" src="/src/asset-lab/main.ts"></script>
+ <script type="module" src="/src/labs/asset-lab/main.ts"></script>
</body>
</html>
diff --git a/effects-lab.html b/effects-lab.html
index 7a9074e..59dbd2c 100644
--- a/effects-lab.html
+++ b/effects-lab.html
@@ -1 +1 @@
-<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><link rel="icon" href="/favicon.svg"><title>Inkline Town · Effects on the house</title></head><body><main id="effects-lab"></main><script type="module" src="/src/effects-lab/main.ts"></script></body></html>
+<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><link rel="icon" href="/favicon.svg"><title>Inkline Town · Effects on the house</title></head><body><main id="effects-lab"></main><script type="module" src="/src/labs/effects-lab/main.ts"></script></body></html>
diff --git a/gallery.html b/gallery.html
index f64b583..41d5f64 100644
--- a/gallery.html
+++ b/gallery.html
@@ -6,6 +6,6 @@
<style>html, body { margin: 0; background: #e2e9e6; } canvas { display: block; }</style>
</head>
<body>
- <script type="module" src="/src/gallery.ts"></script>
+ <script type="module" src="/src/labs/gallery/main.ts"></script>
</body>
</html>
diff --git a/index.html b/index.html
index 1cf79e1..3dbaf29 100644
--- a/index.html
+++ b/index.html
@@ -6,8 +6,8 @@
<meta name="theme-color" content="#f0f2ec" />
<title>Inkline Town</title>
<link rel="icon" href="/favicon.svg" type="image/svg+xml" />
- <link rel="stylesheet" href="/src/factory.css" />
- <link rel="stylesheet" href="/src/phone.css" />
+ <link rel="stylesheet" href="/src/ui/dom/styles/factory.css" />
+ <link rel="stylesheet" href="/src/ui/dom/styles/phone.css" />
<!-- The loading card is styled here, not in the game's CSS, so it shows before anything else arrives. -->
<style>
#loading { position: fixed; inset: 0; z-index: 100; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; background: #f0f2ec; color: #3d4943; font: 13px ui-monospace, "SF Mono", Menlo, monospace; transition: opacity 0.35s; }
@@ -22,6 +22,6 @@
<body>
<div id="app"></div>
<div id="loading" role="status"><b>Inkline Town</b><div class="ink"></div><span>drawing the town…</span></div>
- <script type="module" src="/src/main.ts"></script>
+ <script type="module" src="/src/app/browser.ts"></script>
</body>
</html>
diff --git a/map-lab.html b/map-lab.html
index 45ff3bc..a270fd5 100644
--- a/map-lab.html
+++ b/map-lab.html
@@ -7,6 +7,6 @@
</head>
<body>
<main id="map-lab"></main>
- <script type="module" src="/src/map-lab/main.ts"></script>
+ <script type="module" src="/src/labs/map-lab/main.ts"></script>
</body>
</html>
diff --git a/model-review.html b/model-review.html
index 90dd2a5..ac04718 100644
--- a/model-review.html
+++ b/model-review.html
@@ -1,2 +1,2 @@
<!doctype html>
-<html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1"><link rel="icon" href="/favicon.svg" type="image/svg+xml"><title>Inkline Town · Town model review</title></head><body><main id="review"></main><script type="module" src="/src/model-review/main.ts"></script></body></html>
+<html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1"><link rel="icon" href="/favicon.svg" type="image/svg+xml"><title>Inkline Town · Town model review</title></head><body><main id="review"></main><script type="module" src="/src/labs/model-review/main.ts"></script></body></html>
diff --git a/package.json b/package.json
index 962b6b1..c982217 100644
--- a/package.json
+++ b/package.json
@@ -13,7 +13,7 @@
"balance:worth": "node scripts/worth.ts",
"balance:furniture": "node scripts/furniture.ts",
"balance:model:check": "node --test test/balance-model.test.ts",
- "lint:game": "ritmo-devtools lint src/sim/headless.ts",
+ "lint:game": "ritmo-devtools lint src/game/headless.ts",
"replay": "node scripts/replay.ts",
"check": "pnpm lint && pnpm lint:game && node scripts/check.ts",
"check:browser": "node scripts/check-browser.ts",
diff --git a/park-lab.html b/park-lab.html
index 38e7d5b..b5a41f3 100644
--- a/park-lab.html
+++ b/park-lab.html
@@ -1 +1 @@
-<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><link rel="icon" href="/favicon.svg"><title>Inkline Town · Park review</title></head><body><main id="park-lab"></main><script type="module" src="/src/park-lab/main.ts"></script></body></html>
+<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><link rel="icon" href="/favicon.svg"><title>Inkline Town · Park review</title></head><body><main id="park-lab"></main><script type="module" src="/src/labs/park-lab/main.ts"></script></body></html>
diff --git a/proportion-review.html b/proportion-review.html
index 877520c..1782b1f 100644
--- a/proportion-review.html
+++ b/proportion-review.html
@@ -1,2 +1,2 @@
<!doctype html>
-<html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1"><link rel="icon" href="/favicon.svg" type="image/svg+xml"><title>Inkline Town · Proportion review</title></head><body><main id="proportions"></main><script type="module" src="/src/model-review/proportions.ts"></script></body></html>
+<html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1"><link rel="icon" href="/favicon.svg" type="image/svg+xml"><title>Inkline Town · Proportion review</title></head><body><main id="proportions"></main><script type="module" src="/src/labs/model-review/proportions.ts"></script></body></html>
diff --git a/scripts/balance.ts b/scripts/balance.ts
index 93da3c9..580991f 100644
--- a/scripts/balance.ts
+++ b/scripts/balance.ts
@@ -1,4 +1,4 @@
-import { resolveRules } from "../src/rules/config.ts"
+import { resolveRules } from "../src/game/rules/config.ts"
/**
* Balance runs: a bot plays the real simulation headless on several seeds,
* the way a kind of mayor would, and reports how each term ended and how
@@ -46,20 +46,20 @@ import { resolveRules } from "../src/rules/config.ts"
* wants at each decision, and `DEBUG=1` every edit it pushes. The bot only does what a player
* could: it reads the world, then pushes the same edits the page does.
*/
-import { goodIds, home, kinds, landIds, ROAD_COST, sizeIds, type Amounts, type CharterValue, type GoodId, type GroundId, type Kind, type KindId, type PropId } from "../src/content.ts"
-import * as content from "../src/content.ts"
-import { around, canPlace, DIRS, entrances, GridBuilder, isRoad, key, doors, nearest, reach, roadPrint, useAt, type Use } from "../src/grid.ts"
-import { parksOf, ringOf, effectAt } from "../src/appeal.ts"
-import { GRID, inside, type Point } from "../src/iso.ts"
-import type { GridValue } from "../src/schema.ts"
-import { headless, type Snapshot } from "../src/sim/headless.ts"
-import { goalsOf, larder, seasonAt } from "../src/sim/index.ts"
-import type { Edit } from "../src/ui.ts"
-import { SAVE_FORMAT, SAVE_VERSION } from "../src/save.ts"
+import { goodIds, home, kinds, landIds, ROAD_COST, sizeIds, type Amounts, type CharterValue, type GoodId, type GroundId, type Kind, type KindId, type PropId } from "../src/game/content/index.ts"
+import * as content from "../src/game/content/index.ts"
+import { around, canPlace, DIRS, entrances, GridBuilder, isRoad, key, doors, nearest, reach, roadPrint, useAt, type Use } from "../src/game/world/grid.ts"
+import { parksOf, ringOf, effectAt } from "../src/game/world/appeal.ts"
+import { GRID, inside, type Point } from "../src/game/world/iso.ts"
+import type { GridValue } from "../src/game/schema.ts"
+import { headless, type Snapshot } from "../src/game/headless.ts"
+import { goalsOf, larder, seasonAt } from "../src/game/schedule.ts"
+import type { Edit } from "../src/view/contracts.ts"
+import { SAVE_FORMAT, SAVE_VERSION } from "../src/platform/save.ts"
import { mkdirSync, writeFileSync } from "node:fs"
import { dirname } from "node:path"
import { fingerprint } from "../tools/balance/provenance.ts"
-import { capacity, mealsOf, moreAdmin, taxOf } from "../src/rules/households.ts"
+import { capacity, mealsOf, moreAdmin, taxOf } from "../src/game/rules/households.ts"
// ── Options ───────────────────────────────────────────────────────────────
diff --git a/scripts/check-browser.ts b/scripts/check-browser.ts
index beb062b..6af959f 100644
--- a/scripts/check-browser.ts
+++ b/scripts/check-browser.ts
@@ -7,9 +7,9 @@ import { existsSync } from "node:fs"
import { mkdir,readFile,writeFile } from "node:fs/promises"
import { execFileSync } from "node:child_process"
import { chromium } from "playwright"
-import type { UiValue } from "../src/ui.ts"
-import type { GameScene } from "../src/render3d/scene.ts"
-import type { Snapshot } from "../src/sim/headless.ts"
+import type { UiValue } from "../src/view/contracts.ts"
+import type { GameScene } from "../src/render/three/scene.ts"
+import type { Snapshot } from "../src/game/headless.ts"
declare global {
interface Window {
diff --git a/scripts/check-model-revisions.ts b/scripts/check-model-revisions.ts
index 61e11d9..9d741aa 100644
--- a/scripts/check-model-revisions.ts
+++ b/scripts/check-model-revisions.ts
@@ -2,7 +2,7 @@ import assert from "node:assert/strict"
import { existsSync } from "node:fs"
import { mkdir, writeFile } from "node:fs/promises"
import { chromium } from "playwright"
-import { inkAssets } from "../src/asset-lab/assets.ts"
+import { inkAssets } from "../src/render/three/assets/assets.ts"
const executablePath=process.env.BROWSER_EXECUTABLE_PATH??["/Applications/Brave Browser.app/Contents/MacOS/Brave Browser","/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"].find(existsSync)
const browser=await chromium.launch({headless:true,...(executablePath?{executablePath}:{})})
diff --git a/scripts/check-town-models.ts b/scripts/check-town-models.ts
index 4eecd82..c837b7c 100644
--- a/scripts/check-town-models.ts
+++ b/scripts/check-town-models.ts
@@ -4,7 +4,7 @@ import assert from "node:assert/strict"
import { existsSync } from "node:fs"
import { mkdir, writeFile } from "node:fs/promises"
import { chromium } from "playwright"
-import { kindIds } from "../src/content.ts"
+import { kindIds } from "../src/game/content/index.ts"
const executablePath = process.env.BROWSER_EXECUTABLE_PATH ?? ["/Applications/Brave Browser.app/Contents/MacOS/Brave Browser", "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"].find(existsSync)
const browser = await chromium.launch({ headless: true, ...(executablePath ? { executablePath } : {}) })
diff --git a/scripts/check.ts b/scripts/check.ts
index 113a777..6d886c9 100644
--- a/scripts/check.ts
+++ b/scripts/check.ts
@@ -25,11 +25,11 @@
* - citizens will not take settlers' work, and settlers stand in for citizens as apprentices;
* - and homes with every need met become citizens on a street with a park behind it, not packed beside industry.
*/
-import { amounts, CONDITION_MAX, goodIds, kinds, RISK_MAX, stepsOf, type CharterValue, type GroundId, type KindId, type PropId } from "../src/content.ts"
-import { canPlace, DIRS, entrances, GridBuilder, isRoad, key, type Use } from "../src/grid.ts"
-import { inside } from "../src/iso.ts"
-import { parkValue, ringOf, type ParkCell } from "../src/appeal.ts"
-import { headless, type Snapshot } from "../src/sim/headless.ts"
+import { amounts, CONDITION_MAX, goodIds, kinds, RISK_MAX, stepsOf, type CharterValue, type GroundId, type KindId, type PropId } from "../src/game/content/index.ts"
+import { canPlace, DIRS, entrances, GridBuilder, isRoad, key, type Use } from "../src/game/world/grid.ts"
+import { inside } from "../src/game/world/iso.ts"
+import { parkValue, ringOf, type ParkCell } from "../src/game/world/appeal.ts"
+import { headless, type Snapshot } from "../src/game/headless.ts"
const town = (charter: CharterValue = { size: "small", term: 45, land: "fair", seed: 7 }) => {
const t = headless(charter)
diff --git a/scripts/furniture.ts b/scripts/furniture.ts
index cd6819d..50e0b48 100644
--- a/scripts/furniture.ts
+++ b/scripts/furniture.ts
@@ -9,9 +9,9 @@
*
* node scripts/furniture.ts [minutes]
*/
-import { kinds } from "../src/content.ts"
-import { resolveRules } from "../src/rules/config.ts"
-import { headless, type Snapshot } from "../src/sim/headless.ts"
+import { kinds } from "../src/game/content/index.ts"
+import { resolveRules } from "../src/game/rules/config.ts"
+import { headless, type Snapshot } from "../src/game/headless.ts"
const minutes = Number(process.argv[2] ?? 30)
const FOREVER = 1e9
diff --git a/scripts/ink-assets.ts b/scripts/ink-assets.ts
index fa54c55..deebb4b 100644
--- a/scripts/ink-assets.ts
+++ b/scripts/ink-assets.ts
@@ -1,10 +1,10 @@
import { mkdir, readFile, writeFile } from "node:fs/promises"
import path from "node:path"
import { build } from "vite"
-import { inkAssets } from "../src/asset-lab/assets.ts"
+import { inkAssets } from "../src/render/three/assets/assets.ts"
import * as THREE from "three"
import { GLTFLoader } from "three/addons/loaders/GLTFLoader.js"
-import { exportAsset } from "../src/asset-lab/renderer.ts"
+import { exportAsset } from "../src/render/three/assets/renderer.ts"
// GLTFExporter uses the browser's FileReader to assemble binary buffers.
// There are no textures here; only readAsArrayBuffer is needed in Node.
diff --git a/scripts/replay.ts b/scripts/replay.ts
index 9361758..a9d060e 100644
--- a/scripts/replay.ts
+++ b/scripts/replay.ts
@@ -13,7 +13,7 @@ import { readFileSync, writeFileSync } from "node:fs"
import { Replay } from "@typeonce/ritmo-devtools"
-import { replayTarget } from "../src/sim/headless.ts"
+import { replayTarget } from "../src/game/headless.ts"
const [path, flag, range, out] = process.argv.slice(2)
if (path === undefined) {
diff --git a/scripts/snapshot-parks.ts b/scripts/snapshot-parks.ts
index 05ff4dd..e946411 100644
--- a/scripts/snapshot-parks.ts
+++ b/scripts/snapshot-parks.ts
@@ -2,8 +2,8 @@
import { gzipSync } from "node:zlib"
import { mkdir, writeFile } from "node:fs/promises"
import { execFileSync } from "node:child_process"
-import { parkReviewModels } from "../src/model-review/park-models.ts"
-import { assetById } from "../src/asset-lab/assets.ts"
+import { parkReviewModels } from "../src/labs/model-review/park-models.ts"
+import { assetById } from "../src/render/three/assets/assets.ts"
const revision=execFileSync("git",["rev-parse","HEAD"],{encoding:"utf8"}).trim()
if(revision!=="f4df9d5f9e1ff74552e5a29a3366ec9f541bb3bd")throw new Error("Capture parks from the approved proportion revision")
diff --git a/scripts/snapshot-proportions.ts b/scripts/snapshot-proportions.ts
index a256765..828f19c 100644
--- a/scripts/snapshot-proportions.ts
+++ b/scripts/snapshot-proportions.ts
@@ -3,8 +3,8 @@
import { gzipSync } from "node:zlib"
import { mkdir, writeFile } from "node:fs/promises"
import { execFileSync } from "node:child_process"
-import { proportionModels } from "../src/model-review/proportion-models.ts"
-import { assetById } from "../src/asset-lab/assets.ts"
+import { proportionModels } from "../src/labs/model-review/proportion-models.ts"
+import { assetById } from "../src/render/three/assets/assets.ts"
const revision = execFileSync("git", ["rev-parse", "HEAD"], {encoding: "utf8"}).trim()
if (revision !== "a2845b4f537dcb2998a58b7fae26783d7de4a1ec") throw new Error("Baseline must be captured from the approved a2845b4 revision")
diff --git a/scripts/worth.ts b/scripts/worth.ts
index 3a99314..aa7099d 100644
--- a/scripts/worth.ts
+++ b/scripts/worth.ts
@@ -1,14 +1,14 @@
/**
* The economy's ledger, as tables: what every producer, food, home,
- * service, and the opening cost and give back (see `src/rules/worth.ts`),
+ * service, and the opening cost and give back (see `src/game/rules/worth.ts`),
* and what answering the crown with bought goods leaves the town.
*
* node scripts/worth.ts
* node scripts/worth.ts --set kinds.fishery.upkeep=5 with candidate rules
*/
-import { resolveRules, type RulePatch } from "../src/rules/config.ts"
-import { chainWorth, crownMargin, homes, median, openingKit, producers, services } from "../src/rules/worth.ts"
-import type { GoodId } from "../src/content.ts"
+import { resolveRules, type RulePatch } from "../src/game/rules/config.ts"
+import { chainWorth, crownMargin, homes, median, openingKit, producers, services } from "../src/game/rules/worth.ts"
+import type { GoodId } from "../src/game/content/index.ts"
const patches: Array<RulePatch> = []
for (let i = 2; i < process.argv.length; i++)
diff --git a/service-upgrades.html b/service-upgrades.html
index d5c06d0..5fc4a09 100644
--- a/service-upgrades.html
+++ b/service-upgrades.html
@@ -7,6 +7,6 @@
</head>
<body>
<main id="service-study"></main>
- <script type="module" src="/src/asset-lab/service-study.ts"></script>
+ <script type="module" src="/src/labs/service-study/main.ts"></script>
</body>
</html>
diff --git a/src/main.ts b/src/app/browser.ts
similarity index 93%
rename from src/main.ts
rename to src/app/browser.ts
index 68e1773..23c9d87 100644
--- a/src/main.ts
+++ b/src/app/browser.ts
@@ -1,4 +1,4 @@
-import { resolveRules } from "./rules/config.ts"
+import { resolveRules } from "../game/rules/config.ts"
/**
* A town simulation of line-drawn buildings, homes, roads, and land, on the
* Ritmo ECS with a 3D view. The simulation runs on a fixed step;
@@ -8,16 +8,16 @@ import { FixedLoop, HostClock, Result } from "@typeonce/ritmo"
import { Effect } from "effect"
import { BrowserHostClock } from "@typeonce/ritmo-browser"
-import type { BuildingView, FieldView, HouseView, RockView, RuinView, TreeView, WalkerView } from "./render3d/views.ts"
-import { lands, sizes, step } from "./content.ts"
-import { createHost, type Persistence } from "./host.ts"
-import { present } from "./present.ts"
-import { browserStorage, describe, fileOf, latest, loadLatest, loadText, save, Storage, World } from "./save.ts"
-import type { CameraView } from "./render3d/scene.ts"
-import { download, sharedId } from "./share/client.ts"
-import { BuildingNodes, Clock, Edits, FieldNodes, Game, Rules, HouseNodes, RockNodes, RuinNodes, StageService, TreeNodes, Ui, WalkerNodes } from "./schema.ts"
-import { editsOf } from "./sim/headless.ts"
-import { blankResources, simulate } from "./sim/index.ts"
+import type { BuildingView, FieldView, HouseView, RockView, RuinView, TreeView, WalkerView } from "../render/three/views.ts"
+import { lands, sizes, step } from "../game/content/index.ts"
+import { createHost, type Persistence } from "../ui/dom/host.ts"
+import { present } from "../view/present.ts"
+import { browserStorage, describe, fileOf, latest, loadLatest, loadText, save, Storage, World } from "../platform/save.ts"
+import type { CameraView } from "../render/three/scene.ts"
+import { download, sharedId } from "../platform/share/client.ts"
+import { BuildingNodes, Clock, Edits, FieldNodes, Game, Rules, HouseNodes, RockNodes, RuinNodes, StageService, TreeNodes, Ui, WalkerNodes } from "../game/schema.ts"
+import { editsOf } from "../game/headless.ts"
+import { blankResources, simulate } from "../game/schedule.ts"
/** Minutes of game time between autosaves. */
const AUTOSAVE_MINUTES = 2
@@ -98,7 +98,7 @@ const start = async () => {
Object.assign(window, { town: { ui, runtime, advance, view: stage } })
if (runtime.debug !== undefined) {
// Loaded in dev only: the production bundle never includes devtools.
- const { attachDevtools } = await import("./dev/devtools.ts")
+ const { attachDevtools } = await import("./devtools.ts")
attachDevtools({ runtime: { ...runtime, debug: runtime.debug }, mount: document.body, fetch: (url, init) => fetch(url, init), wallClock: HostClock.standard, host: window, demo: new URLSearchParams(location.search).has("replay-demo") })
}
}
diff --git a/src/dev/devtools.ts b/src/app/devtools.ts
similarity index 93%
rename from src/dev/devtools.ts
rename to src/app/devtools.ts
index 6f08d65..d94d1c9 100644
--- a/src/dev/devtools.ts
+++ b/src/app/devtools.ts
@@ -9,10 +9,10 @@ import type { HostClock } from "@typeonce/ritmo"
import { Invariant, Monitor, Replay } from "@typeonce/ritmo-devtools"
import * as ReplayViteSink from "@typeonce/ritmo-devtools/ReplayViteSink"
-import { step } from "../content.ts"
-import { present } from "../present.ts"
-import { Building, Game, Root, Treasury } from "../schema.ts"
-import { simulate } from "../sim/index.ts"
+import { step } from "../game/content/index.ts"
+import { present } from "../view/present.ts"
+import { Building, Game, Root, Treasury } from "../game/schema.ts"
+import { simulate } from "../game/schedule.ts"
/** The treasury holds a whole number of coins: a NaN or a fraction means some sum went wrong. */
export const CoinsAreWhole = Invariant.fromInspector(Game.Inspector("coins are whole", {
diff --git a/src/content.ts b/src/game/content/index.ts
similarity index 100%
rename from src/content.ts
rename to src/game/content/index.ts
diff --git a/src/sim/headless.ts b/src/game/headless.ts
similarity index 91%
rename from src/sim/headless.ts
rename to src/game/headless.ts
index 00592a0..8e9aedb 100644
--- a/src/sim/headless.ts
+++ b/src/game/headless.ts
@@ -7,11 +7,11 @@
import { HostClock } from "@typeonce/ritmo"
import type * as Replay from "@typeonce/ritmo-devtools/Replay"
-import { step as simulationStep, type CharterValue } from "../content.ts"
-import { resolveRules, type Rules as RuleInputs } from "../rules/config.ts"
-import { Edits, Game, Rules, Toast } from "../schema.ts"
-import { emptyPreview, type Edit, type UiValue } from "../ui.ts"
-import { blankResources, simulate } from "./index.ts"
+import { step as simulationStep, type CharterValue } from "./content/index.ts"
+import { resolveRules, type Rules as RuleInputs } from "./rules/config.ts"
+import { Edits, Game, Rules, Toast } from "./schema.ts"
+import { emptyPreview, type Edit, type UiValue } from "../view/contracts.ts"
+import { blankResources, simulate } from "./schedule.ts"
/** A saved world, as plain data. */
export interface Snapshot {
@@ -57,13 +57,13 @@ export const replayTarget = (playback: Replay.Playback) => {
}
/**
- * What `ritmo-devtools lint src/sim/headless.ts` checks (`pnpm lint:game`,
+ * What `ritmo-devtools lint src/game/headless.ts` checks (`pnpm lint:game`,
* part of `pnpm check`): the simulation on a debug runtime, and the page's
* `present` schedule described without running (it needs the renderer).
*/
export const lintTarget = async () => {
// Loaded here only: tests and bots that use `headless` never load the renderer.
- const { present } = await import("../present.ts")
+ const { present } = await import("../view/present.ts")
const made = Game.Runtime.make({
services: Game.Runtime.services(Game.Runtime.service(Edits, editsOf(blankUi(lintCharter, () => {}))), Game.Runtime.service(Rules, resolveRules())),
resources: blankResources(),
diff --git a/src/rules/approval.ts b/src/game/rules/approval.ts
similarity index 100%
rename from src/rules/approval.ts
rename to src/game/rules/approval.ts
diff --git a/src/rules/config.ts b/src/game/rules/config.ts
similarity index 98%
rename from src/rules/config.ts
rename to src/game/rules/config.ts
index e127dad..538d20b 100644
--- a/src/rules/config.ts
+++ b/src/game/rules/config.ts
@@ -1,5 +1,5 @@
/** Immutable inputs shared by the game and offline analysis. No tuning values live in the analyzer. */
-import * as content from "../content.ts"
+import * as content from "../content/index.ts"
/** Formerly private execution constants, moved here without changing their values. */
export const transport = {
diff --git a/src/rules/decay.ts b/src/game/rules/decay.ts
similarity index 88%
rename from src/rules/decay.ts
rename to src/game/rules/decay.ts
index b556492..fcce115 100644
--- a/src/rules/decay.ts
+++ b/src/game/rules/decay.ts
@@ -1,4 +1,4 @@
-import type { GoodId } from "../content.ts"
+import type { GoodId } from "../content/index.ts"
import { shippedRules, type Rules } from "./config.ts"
/** Expected loss before the runtime's seeded stochastic rounding. */
diff --git a/src/rules/explain.ts b/src/game/rules/explain.ts
similarity index 99%
rename from src/rules/explain.ts
rename to src/game/rules/explain.ts
index 523c3b8..b0880c9 100644
--- a/src/rules/explain.ts
+++ b/src/game/rules/explain.ts
@@ -5,7 +5,7 @@
* market in reach, nothing in store) are each told plainly. Plain
* functions over plain facts: nothing here knows the ECS.
*/
-import type { KindId, Need, Tier } from "../content.ts"
+import type { KindId, Need, Tier } from "../content/index.ts"
import { shippedRules, type Rules } from "./config.ts"
import { kept as keptBy, met, wantsBurgherGoods, wantsCitizenGoods, type Needs } from "./households.ts"
diff --git a/src/rules/goals.ts b/src/game/rules/goals.ts
similarity index 98%
rename from src/rules/goals.ts
rename to src/game/rules/goals.ts
index 7c41f32..7c92f51 100644
--- a/src/rules/goals.ts
+++ b/src/game/rules/goals.ts
@@ -1,4 +1,4 @@
-import { upgradeAt } from "../content.ts"
+import { upgradeAt } from "../content/index.ts"
import { shippedRules, type Rules } from "./config.ts"
/** Food in storage: what would carry the town through a winter. */
diff --git a/src/rules/guide.ts b/src/game/rules/guide.ts
similarity index 99%
rename from src/rules/guide.ts
rename to src/game/rules/guide.ts
index c003c08..2c623e0 100644
--- a/src/rules/guide.ts
+++ b/src/game/rules/guide.ts
@@ -43,7 +43,7 @@
* tool, open that panel, or show that view; on a keyboard they carry the key;
* - `{tap|click}` reads "tap" on a touch screen and "click" with a mouse.
*/
-import { kinds, type Amounts, type KindId } from "../content.ts"
+import { kinds, type Amounts, type KindId } from "../content/index.ts"
/** What the guide reads of the town. */
export interface GuideFacts {
diff --git a/src/rules/households.ts b/src/game/rules/households.ts
similarity index 99%
rename from src/rules/households.ts
rename to src/game/rules/households.ts
index fc3020b..5182369 100644
--- a/src/rules/households.ts
+++ b/src/game/rules/households.ts
@@ -1,4 +1,4 @@
-import type { GoodId, Need, Tier } from "../content.ts"
+import type { GoodId, Need, Tier } from "../content/index.ts"
import { shippedRules, type Rules } from "./config.ts"
export interface Needs {
diff --git a/src/rules/land.ts b/src/game/rules/land.ts
similarity index 83%
rename from src/rules/land.ts
rename to src/game/rules/land.ts
index 904e35a..5c8b4fe 100644
--- a/src/rules/land.ts
+++ b/src/game/rules/land.ts
@@ -1,6 +1,6 @@
-import { DIRS, useAt } from "../grid.ts"
+import { DIRS, useAt } from "../world/grid.ts"
import type { GridValue } from "../schema.ts"
-import type { Point } from "../iso.ts"
+import type { Point } from "../world/iso.ts"
/** Keep unsuccessful candidates: the game picks first and checks fertility afterward. */
export const wildTreeSpots = (grid: GridValue, parent: Point): ReadonlyArray<Point> =>
diff --git a/src/rules/patrol.ts b/src/game/rules/patrol.ts
similarity index 96%
rename from src/rules/patrol.ts
rename to src/game/rules/patrol.ts
index c378926..d73ecbc 100644
--- a/src/rules/patrol.ts
+++ b/src/game/rules/patrol.ts
@@ -1,6 +1,6 @@
-import { around, doors, isRoad, key, nearest, pathTo, reach, roadPrint, type TileLike } from "../grid.ts"
+import { around, doors, isRoad, key, nearest, pathTo, reach, roadPrint, type TileLike } from "../world/grid.ts"
import type { GridValue } from "../schema.ts"
-import type { Point } from "../iso.ts"
+import type { Point } from "../world/iso.ts"
export interface PatrolTarget { readonly id: number; readonly tile: TileLike }
export interface PatrolPlan {
diff --git a/src/rules/production.ts b/src/game/rules/production.ts
similarity index 98%
rename from src/rules/production.ts
rename to src/game/rules/production.ts
index 5d591b7..f56dc62 100644
--- a/src/rules/production.ts
+++ b/src/game/rules/production.ts
@@ -1,5 +1,5 @@
import { shippedRules, type Rules } from "./config.ts"
-import type { Kind } from "../content.ts"
+import type { Kind } from "../content/index.ts"
/** Tick alignment is significant: keep effort and equipment cadence on the same clock. */
export const paced = (pace: number, tick: number): boolean => pace >= 1 || Math.floor((tick + 1) * pace) > Math.floor(tick * pace)
diff --git a/src/rules/risks.ts b/src/game/rules/risks.ts
similarity index 95%
rename from src/rules/risks.ts
rename to src/game/rules/risks.ts
index 8bf01dd..cfbf940 100644
--- a/src/rules/risks.ts
+++ b/src/game/rules/risks.ts
@@ -1,5 +1,5 @@
-import type { KindId, Tier } from "../content.ts"
-import type { TileLike } from "../grid.ts"
+import type { KindId, Tier } from "../content/index.ts"
+import type { TileLike } from "../world/grid.ts"
import { shippedRules, type Rules } from "./config.ts"
export const near = (a: TileLike, b: TileLike, r: number) =>
diff --git a/src/rules/salvage.ts b/src/game/rules/salvage.ts
similarity index 96%
rename from src/rules/salvage.ts
rename to src/game/rules/salvage.ts
index e95edad..e011cf6 100644
--- a/src/rules/salvage.ts
+++ b/src/game/rules/salvage.ts
@@ -1,4 +1,4 @@
-import { upgradeAt, type GoodId, type Kind } from "../content.ts"
+import { upgradeAt, type GoodId, type Kind } from "../content/index.ts"
import { shippedRules, type Rules } from "./config.ts"
/** What pulling something down costs, and what comes back into storage. */
diff --git a/src/rules/seasons.ts b/src/game/rules/seasons.ts
similarity index 98%
rename from src/rules/seasons.ts
rename to src/game/rules/seasons.ts
index 09755d1..7079150 100644
--- a/src/rules/seasons.ts
+++ b/src/game/rules/seasons.ts
@@ -1,4 +1,4 @@
-import type { WinterId } from "../content.ts"
+import type { WinterId } from "../content/index.ts"
import { ruleTicks, shippedRules, type Rules } from "./config.ts"
// ── Time ──────────────────────────────────────────────────────────────────
diff --git a/src/rules/trade.ts b/src/game/rules/trade.ts
similarity index 97%
rename from src/rules/trade.ts
rename to src/game/rules/trade.ts
index 845e445..216354a 100644
--- a/src/rules/trade.ts
+++ b/src/game/rules/trade.ts
@@ -1,4 +1,4 @@
-import { goodIds, type Amounts, type GoodId } from "../content.ts"
+import { goodIds, type Amounts, type GoodId } from "../content/index.ts"
import { askOf, priceOf } from "./households.ts"
import { shippedRules, type Rules } from "./config.ts"
diff --git a/src/rules/transport.ts b/src/game/rules/transport.ts
similarity index 91%
rename from src/rules/transport.ts
rename to src/game/rules/transport.ts
index 7dbb639..b467fde 100644
--- a/src/rules/transport.ts
+++ b/src/game/rules/transport.ts
@@ -1,6 +1,6 @@
-import { DIRS, isRoad } from "../grid.ts"
+import { DIRS, isRoad } from "../world/grid.ts"
import type { GridValue } from "../schema.ts"
-import type { Point } from "../iso.ts"
+import type { Point } from "../world/iso.ts"
/** Shared candidate enumeration; Random.pick selects uniformly from this list in the runtime. */
export const onwardRoads = (grid: GridValue, cell: Point, previous: Point | null): ReadonlyArray<Point> =>
diff --git a/src/rules/upgrades.ts b/src/game/rules/upgrades.ts
similarity index 98%
rename from src/rules/upgrades.ts
rename to src/game/rules/upgrades.ts
index f13d9db..e2b848f 100644
--- a/src/rules/upgrades.ts
+++ b/src/game/rules/upgrades.ts
@@ -5,7 +5,7 @@
* build menu, the upgrade tool's tooltip, and the building's panel all read
* these, so the mayor is told the same thing wherever they look.
*/
-import { asUpgraded, costText, nextUpgrade, upgradeAt, type Kind, type Upgrade } from "../content.ts"
+import { asUpgraded, costText, nextUpgrade, upgradeAt, type Kind, type Upgrade } from "../content/index.ts"
import { shippedRules, type Rules } from "./config.ts"
const signed = (n: number) => `${n > 0 ? "+" : n < 0 ? "−" : ""}${Math.abs(n)}`
diff --git a/src/rules/worth.ts b/src/game/rules/worth.ts
similarity index 99%
rename from src/rules/worth.ts
rename to src/game/rules/worth.ts
index f5700d2..f53e9a7 100644
--- a/src/rules/worth.ts
+++ b/src/game/rules/worth.ts
@@ -8,7 +8,7 @@
* rules (or any candidate rules) to the bands these figures should keep.
* Plain functions over the rules: nothing here knows the ECS.
*/
-import { amounts, asUpgraded, foods, goodIds, upgradeAt, type GoodId, type Kind, type KindId, type Need, type Tier } from "../content.ts"
+import { amounts, asUpgraded, foods, goodIds, upgradeAt, type GoodId, type Kind, type KindId, type Need, type Tier } from "../content/index.ts"
import { shippedRules, type Rules } from "./config.ts"
import { adminOf, mealsOf, moreAdmin, taxOf } from "./households.ts"
import { tradeCollection } from "./trade.ts"
diff --git a/src/sim/index.ts b/src/game/schedule.ts
similarity index 76%
rename from src/sim/index.ts
rename to src/game/schedule.ts
index b674599..f611bd9 100644
--- a/src/sim/index.ts
+++ b/src/game/schedule.ts
@@ -4,17 +4,17 @@
*/
import { Clock } from "@typeonce/ritmo"
import * as Random from "@typeonce/ritmo-math/Random"
-import { amounts, defaultCharter, goodIds, step, TRADE_LOAD } from "../content.ts"
-import { Game, Time } from "../schema.ts"
-import { ApplyEdits } from "./edits.ts"
-import { Deliver, Dispatch } from "./logistics.ts"
-import { Decay } from "./decay.ts"
-import { Appraise, Douse, Hazards } from "./hazards.ts"
-import { DropOrphans } from "./orphans.ts"
-import { Approve, foundedFate, Judge, Record, Requests, Seasons } from "./term.ts"
-import { Collect, Households, TakeCensus } from "./town.ts"
-import { SendWalkers, Walk, Wander } from "./walkers.ts"
-import { AssignStaff, CountStock, Grow, IndexGrid, Plant, Raise, Spread, Work } from "./work.ts"
+import { amounts, defaultCharter, goodIds, step, TRADE_LOAD } from "./content/index.ts"
+import { Game, Time } from "./schema.ts"
+import { ApplyEdits } from "./systems/edits/index.ts"
+import { Deliver, Dispatch } from "./systems/logistics/index.ts"
+import { Decay } from "./systems/decay/index.ts"
+import { Appraise, Douse, Hazards } from "./systems/hazards/index.ts"
+import { DropOrphans } from "./systems/orphans/index.ts"
+import { Approve, foundedFate, Judge, Record, Requests, Seasons } from "./systems/term/index.ts"
+import { Collect, Households, TakeCensus } from "./systems/town/index.ts"
+import { SendWalkers, Walk, Wander } from "./systems/walkers/index.ts"
+import { AssignStaff, CountStock, Grow, IndexGrid, Plant, Raise, Spread, Work } from "./systems/work/index.ts"
export const AdvanceTime = Clock.system(Game, { name: "Town/AdvanceTime", resource: Time })
@@ -82,8 +82,8 @@ export const blankResources = () => ({
Flow: { town: "", since: 0, start: null, made: amounts({}), traded: amounts({}), held: amounts({}), coins: { start: 0, made: 0, traded: 0, seen: 0, booked: 0 }, slices: [], last: null }
})
-export { CELL_STEPS, elapsed, seasonAt, termTicks, winterOf } from "./shared.ts"
-export { SITE_SHARE } from "./work.ts"
-export { lockReason, unlocked, upgradeBlock } from "./edits.ts"
-export { adminOf, askOf, capacity, kept, met, priceOf, satisfaction, taxOf, tierFor } from "./town.ts"
-export { crownGap, goalsOf, larder, steadyNet } from "./term.ts"
+export { CELL_STEPS, elapsed, seasonAt, termTicks, winterOf } from "./systems/shared.ts"
+export { SITE_SHARE } from "./systems/work/index.ts"
+export { lockReason, unlocked, upgradeBlock } from "./systems/edits/index.ts"
+export { adminOf, askOf, capacity, kept, met, priceOf, satisfaction, taxOf, tierFor } from "./systems/town/index.ts"
+export { crownGap, goalsOf, larder, steadyNet } from "./systems/term/index.ts"
diff --git a/src/schema.ts b/src/game/schema.ts
similarity index 98%
rename from src/schema.ts
rename to src/game/schema.ts
index 08bfe96..82b5bc1 100644
--- a/src/schema.ts
+++ b/src/game/schema.ts
@@ -14,13 +14,13 @@
import { Clock as SimulationClock, Decode, Descriptor, Schema } from "@typeonce/ritmo"
import * as Random from "@typeonce/ritmo-math/Random"
import type { NodeRegistry } from "@typeonce/ritmo-render"
-import { step } from "./content.ts"
+import { step } from "./content/index.ts"
-import type { BuildingView, FieldView, HouseView, RockView, RuinView, TreeView, WalkerView } from "./render3d/views.ts"
-import type { GameScene } from "./render3d/scene.ts"
-import { goodIds, groundIds, kindIds, landIds, propIds, serviceIds, sizeIds, type Amounts, type GoodId } from "./content.ts"
+import type { BuildingView, FieldView, HouseView, RockView, RuinView, TreeView, WalkerView } from "../render/three/views.ts"
+import type { GameScene } from "../render/three/scene.ts"
+import { goodIds, groundIds, kindIds, landIds, propIds, serviceIds, sizeIds, type Amounts, type GoodId } from "./content/index.ts"
import type { Rules as RuleInputs } from "./rules/config.ts"
-import type { Edit, UiValue } from "./ui.ts"
+import type { Edit, UiValue } from "../view/contracts.ts"
export const Root = Schema.defineRoot("Town")
diff --git a/src/sim/decay.ts b/src/game/systems/decay/index.ts
similarity index 93%
rename from src/sim/decay.ts
rename to src/game/systems/decay/index.ts
index 52b2345..98ef787 100644
--- a/src/sim/decay.ts
+++ b/src/game/systems/decay/index.ts
@@ -1,4 +1,4 @@
-import { spoilExpectation } from "../rules/decay.ts"
+import { spoilExpectation } from "../../rules/decay.ts"
/**
* What time does to the town: homes and buildings run down until a builder
* mends them, and fall into ruin if none does; fish and bread rot on the
@@ -7,12 +7,12 @@ import { spoilExpectation } from "../rules/decay.ts"
*/
import * as Random from "@typeonce/ritmo-math/Random"
-import { ruinDraft } from "../archetypes.ts"
-import { foods, goodIds, stepsOf } from "../content.ts"
-import { counted, placeName } from "../places.ts"
-import { Ruin } from "../schema.ts"
-import { Building, Burning, Charter, Chronicle, Condition, Game, Rules, House, Inventory, Pantry, Recipe, Rising, Rng, Site, Staff, Tile, Time } from "../schema.ts"
-import { elapsed, write } from "./shared.ts"
+import { ruinDraft } from "../../world/archetypes.ts"
+import { foods, goodIds, stepsOf } from "../../content/index.ts"
+import { counted, placeName } from "../../world/places.ts"
+import { Ruin } from "../../schema.ts"
+import { Building, Burning, Charter, Chronicle, Condition, Game, Rules, House, Inventory, Pantry, Recipe, Rising, Rng, Site, Staff, Tile, Time } from "../../schema.ts"
+import { elapsed, write } from "../shared.ts"
/** The pantry warns of rotting food at most this often. */
const ROT_WARNING = stepsOf(5 * 60)
diff --git a/src/sim/edits.ts b/src/game/systems/edits/index.ts
similarity index 98%
rename from src/sim/edits.ts
rename to src/game/systems/edits/index.ts
index 84af2bf..fbd44e1 100644
--- a/src/sim/edits.ts
+++ b/src/game/systems/edits/index.ts
@@ -6,18 +6,18 @@
* carried to the site afterwards. Upgrading a building is paid at once.
* Once the term has ended, only a new town, or another term, is taken.
*/
-import { buildingDraft, houseDraft, houseStart, parkDraft, roadDraft, rockDraft, RoleParts, rolesOf, StartParts, startOf, treeDraft, waterDraft } from "../archetypes.ts"
+import { buildingDraft, houseDraft, houseStart, parkDraft, roadDraft, rockDraft, RoleParts, rolesOf, StartParts, startOf, treeDraft, waterDraft } from "../../world/archetypes.ts"
import * as Random from "@typeonce/ritmo-math/Random"
-import { amounts, anA, builtCost, costText, goodIds, nextUpgrade, RESERVE_MAX, TAX_STEPS, stepsOf, total, upgradeAt, type Amounts, type Kind, type ParkPiece, type Upgrade } from "../content.ts"
-import { canPlace, cellsOf, GridBuilder, ownerAt, useAt } from "../grid.ts"
-import { inside } from "../iso.ts"
-import { generate } from "../mapgen.ts"
-import { Road, Water, Tree } from "../schema.ts"
-import { Appeal, Building, Tile, Census, Charter, Chronicle, Crown, Fate, Fires, Game, Guide, Rules, History, House, Inventory, Land, Ledger, Market, Mood, Pantry, Park, Paved, Paused, Policy, Rising, Rng, Rock, Service, Site, Status, Stock, Storage, Time, TownHall, Toast, Treasury, Upgraded, Works, Edits, Selection } from "../schema.ts"
-import { salvageOf, salvageText, withWorks } from "../rules/salvage.ts"
-import { elapsed, rollWinters, termTicks, TileRead, useOf, write } from "./shared.ts"
-import type { Rules as RuleInputs } from "../rules/config.ts"
-import { crownGap, foundedFate } from "./term.ts"
+import { amounts, anA, builtCost, costText, goodIds, nextUpgrade, RESERVE_MAX, TAX_STEPS, stepsOf, total, upgradeAt, type Amounts, type Kind, type ParkPiece, type Upgrade } from "../../content/index.ts"
+import { canPlace, cellsOf, GridBuilder, ownerAt, useAt } from "../../world/grid.ts"
+import { inside } from "../../world/iso.ts"
+import { generate } from "../../world/mapgen.ts"
+import { Road, Water, Tree } from "../../schema.ts"
+import { Appeal, Building, Tile, Census, Charter, Chronicle, Crown, Fate, Fires, Game, Guide, Rules, History, House, Inventory, Land, Ledger, Market, Mood, Pantry, Park, Paved, Paused, Policy, Rising, Rng, Rock, Service, Site, Status, Stock, Storage, Time, TownHall, Toast, Treasury, Upgraded, Works, Edits, Selection } from "../../schema.ts"
+import { salvageOf, salvageText, withWorks } from "../../rules/salvage.ts"
+import { elapsed, rollWinters, termTicks, TileRead, useOf, write } from "../shared.ts"
+import type { Rules as RuleInputs } from "../../rules/config.ts"
+import { crownGap, foundedFate } from "../term/index.ts"
export const unlocked = (kind: Pick<Kind, "unlock"> | ParkPiece, census: { readonly settlers: number; readonly citizens: number }) =>
census.settlers + census.citizens >= kind.unlock.residents && census.citizens >= kind.unlock.citizens
diff --git a/src/sim/hazards.ts b/src/game/systems/hazards/index.ts
similarity index 96%
rename from src/sim/hazards.ts
rename to src/game/systems/hazards/index.ts
index 35ec923..94641f2 100644
--- a/src/sim/hazards.ts
+++ b/src/game/systems/hazards/index.ts
@@ -1,5 +1,5 @@
-import { every } from "../content.ts"
-import { near, riskIncrements } from "../rules/risks.ts"
+import { every } from "../../content/index.ts"
+import { near, riskIncrements } from "../../rules/risks.ts"
/**
* The neighbourhood and its dangers. Every so often the town's desirability
* is reckoned cell by cell (`Appraise`). Once a second every home's risk of
@@ -12,14 +12,14 @@ import { near, riskIncrements } from "../rules/risks.ts"
*/
import * as Random from "@typeonce/ritmo-math/Random"
-import { appealGrid, appealAt, buildingSource, homeSource, landSource, parkSources, type AppealSource } from "../appeal.ts"
-import { ruinDraft } from "../archetypes.ts"
-import { goodIds, risk, upgradeAt, type GoodId } from "../content.ts"
-import { doors, nearest, pathTo, reach, useAt } from "../grid.ts"
-import { counted, placeName, type Landmark } from "../places.ts"
-import type { Point } from "../iso.ts"
-import { Appeal, Building, Burning, Charter, Chronicle, Condition, Figure, Fires, Game, Rules, Grid, House, Inventory, Mood, Park, Paused, Paved, Rescue, Rising, Risk, Rng, Road, Route, Ruin, Service, Sick, Site, Staff, Storage, Tile, Time, Tree, Treasury, Upgraded, WalkerOf, Water } from "../schema.ts"
-import { elapsed, seasonAt, write } from "./shared.ts"
+import { appealGrid, appealAt, buildingSource, homeSource, landSource, parkSources, type AppealSource } from "../../world/appeal.ts"
+import { ruinDraft } from "../../world/archetypes.ts"
+import { goodIds, risk, upgradeAt, type GoodId } from "../../content/index.ts"
+import { doors, nearest, pathTo, reach, useAt } from "../../world/grid.ts"
+import { counted, placeName, type Landmark } from "../../world/places.ts"
+import type { Point } from "../../world/iso.ts"
+import { Appeal, Building, Burning, Charter, Chronicle, Condition, Figure, Fires, Game, Rules, Grid, House, Inventory, Mood, Park, Paused, Paved, Rescue, Rising, Risk, Rng, Road, Route, Ruin, Service, Sick, Site, Staff, Storage, Tile, Time, Tree, Treasury, Upgraded, WalkerOf, Water } from "../../schema.ts"
+import { elapsed, seasonAt, write } from "../shared.ts"
// ── Desirability ──────────────────────────────────────────────────────────
@@ -70,7 +70,7 @@ export const Appraise = Game.System(
/** The risks are reckoned this often (once a second). */
export const RISK_TICKS = 60
-export { paceAt } from "../rules/risks.ts"
+export { paceAt } from "../../rules/risks.ts"
export const Hazards = Game.System(
"Town/Hazards",
diff --git a/src/sim/logistics.ts b/src/game/systems/logistics/index.ts
similarity index 96%
rename from src/sim/logistics.ts
rename to src/game/systems/logistics/index.ts
index fdc1027..9b0b3c6 100644
--- a/src/sim/logistics.ts
+++ b/src/game/systems/logistics/index.ts
@@ -1,8 +1,8 @@
-import { every } from "../content.ts"
-import { transport } from "../rules/config.ts"
-import { wantsBurgherGoods, wantsCitizenGoods } from "../rules/households.ts"
-import { appealAt } from "../appeal.ts"
-import { preferDelivery } from "../rules/transport.ts"
+import { every } from "../../content/index.ts"
+import { transport } from "../../rules/config.ts"
+import { wantsBurgherGoods, wantsCitizenGoods } from "../../rules/households.ts"
+import { appealAt } from "../../world/appeal.ts"
+import { preferDelivery } from "../../rules/transport.ts"
/**
* Carriers: every good that moves walks along the roads in a carrier's
* crate. What a building wants — a site's materials, a workshop's input, a
@@ -11,11 +11,11 @@ import { preferDelivery } from "../rules/transport.ts"
* storage balances the demands it can meet. Construction comes first. Crates
* already on their way count against a demand, so no one is sent twice.
*/
-import { goodIds, provisions, type GoodId } from "../content.ts"
-import { doors, nearest, pathTo, reach, key, type Reach } from "../grid.ts"
-import type { Point } from "../iso.ts"
-import { Building, Burning, Carriers, Errand, Figure, Game, Rules, Grid, House, Appeal, Inventory, Recipe, Rising, Route, Service, Site, Storage, Tile, Time, WalkerOf, Works } from "../schema.ts"
-import { CELL_STEPS } from "./shared.ts"
+import { goodIds, provisions, type GoodId } from "../../content/index.ts"
+import { doors, nearest, pathTo, reach, key, type Reach } from "../../world/grid.ts"
+import type { Point } from "../../world/iso.ts"
+import { Building, Burning, Carriers, Errand, Figure, Game, Rules, Grid, House, Appeal, Inventory, Recipe, Rising, Route, Service, Site, Storage, Tile, Time, WalkerOf, Works } from "../../schema.ts"
+import { CELL_STEPS } from "../shared.ts"
/** The most a carrier takes at once. */
const LOAD = transport.load
diff --git a/src/sim/orphans.ts b/src/game/systems/orphans/index.ts
similarity index 94%
rename from src/sim/orphans.ts
rename to src/game/systems/orphans/index.ts
index 5935ba3..35273b3 100644
--- a/src/sim/orphans.ts
+++ b/src/game/systems/orphans/index.ts
@@ -4,7 +4,7 @@
* sending its firefighters, say), the belonging fails and the newcomer would
* stay behind with no home: it goes too, as it would have with its building.
*/
-import { Field, Game, Route, FieldOf, WalkerOf } from "../schema.ts"
+import { Field, Game, Route, FieldOf, WalkerOf } from "../../schema.ts"
export const DropOrphans = Game.System(
"Town/DropOrphans",
diff --git a/src/sim/shared.ts b/src/game/systems/shared.ts
similarity index 95%
rename from src/sim/shared.ts
rename to src/game/systems/shared.ts
index f633f00..4e4f7c1 100644
--- a/src/sim/shared.ts
+++ b/src/game/systems/shared.ts
@@ -1,7 +1,7 @@
/** Queries and small helpers the simulation's systems share. */
-import { doors, type TileLike, type Use } from "../grid.ts"
+import { doors, type TileLike, type Use } from "../world/grid.ts"
import { Field, Game, House, Park, Paved, Road, Rock, Ruin, Tile, Tree, Water, type GridValue } from "../schema.ts"
-import type { Point } from "../iso.ts"
+import type { Point } from "../world/iso.ts"
/** Every tile, with enough to tell what it is. */
export const TileRead = Game.Query({
diff --git a/src/sim/term.ts b/src/game/systems/term/index.ts
similarity index 97%
rename from src/sim/term.ts
rename to src/game/systems/term/index.ts
index 013576e..6484f0b 100644
--- a/src/sim/term.ts
+++ b/src/game/systems/term/index.ts
@@ -1,14 +1,14 @@
-import { approvalTarget, nextApproval } from "../rules/approval.ts"
-import { shippedRules } from "../rules/config.ts"
+import { approvalTarget, nextApproval } from "../../rules/approval.ts"
+import { shippedRules } from "../../rules/config.ts"
/**
* The term in office: the seasons turn, the crown asks for goods, the
* town's approval follows how it is treated, the town's history is kept,
* the town rises through its ranks, and the term ends: lost, or run out.
*/
-import { crown, HISTORY_TICKS, stepsOf, WINTER_WARNING, type GoodId } from "../content.ts"
+import { crown, HISTORY_TICKS, stepsOf, WINTER_WARNING, type GoodId } from "../../content/index.ts"
import * as Random from "@typeonce/ritmo-math/Random"
-import { Building, Census, Charter, Chronicle, Crown, Fate, Game, Rules, History, House, Inventory, Ledger, Mood, Pantry, Paused, Policy, Recipe, Rising, Rng, Site, Stock, Storage, Time, Treasury, TownHall, Upgraded } from "../schema.ts"
-import { elapsed, seasonAt, termTicks, write } from "./shared.ts"
+import { Building, Census, Charter, Chronicle, Crown, Fate, Game, Rules, History, House, Inventory, Ledger, Mood, Pantry, Paused, Policy, Recipe, Rising, Rng, Site, Stock, Storage, Time, Treasury, TownHall, Upgraded } from "../../schema.ts"
+import { elapsed, seasonAt, termTicks, write } from "../shared.ts"
// ── Time ──────────────────────────────────────────────────────────────────
@@ -188,8 +188,8 @@ export const foundedFate = () => ({
score: 0
})
-import { goalsOf, larder, nextRank, scoreOf, steadyNet } from "../rules/goals.ts"
-export { goalsOf, larder, nextRank, scoreOf, steadyNet } from "../rules/goals.ts"
+import { goalsOf, larder, nextRank, scoreOf, steadyNet } from "../../rules/goals.ts"
+export { goalsOf, larder, nextRank, scoreOf, steadyNet } from "../../rules/goals.ts"
/**
* Once a second: does the term end, or the town rise? The term is lost to
diff --git a/src/sim/town.ts b/src/game/systems/town/index.ts
similarity index 95%
rename from src/sim/town.ts
rename to src/game/systems/town/index.ts
index 85b1e29..96c5f67 100644
--- a/src/sim/town.ts
+++ b/src/game/systems/town/index.ts
@@ -1,18 +1,18 @@
-import { every } from "../content.ts"
-import { tradeCollection } from "../rules/trade.ts"
+import { every } from "../../content/index.ts"
+import { tradeCollection } from "../../rules/trade.ts"
/**
* The town: homes grow, level up, or empty depending on what reaches them;
* taxes are collected from homes connected to the town hall and upkeep paid
* for every standing building and park; and the census counts it all.
*/
-import { appealAt, parkUpkeep } from "../appeal.ts"
-import { doors, key, reach } from "../grid.ts"
-import { amounts, goodIds, upgradeAt, upkeepOf, type GoodId } from "../content.ts"
-import { Appeal, Building, Burning, Census, Charter, Flow, Game, Rules, Grid, House, Inventory, Ledger, Market, Mood, Park, Paused, Policy, Rebuilt, Rising, Risk, Sick, Site, Staff, Storage, Tile, Time, TownHall, Treasury, Upgraded } from "../schema.ts"
-import { connected, elapsed, seasonAt } from "./shared.ts"
+import { appealAt, parkUpkeep } from "../../world/appeal.ts"
+import { doors, key, reach } from "../../world/grid.ts"
+import { amounts, goodIds, upgradeAt, upkeepOf, type GoodId } from "../../content/index.ts"
+import { Appeal, Building, Burning, Census, Charter, Flow, Game, Rules, Grid, House, Inventory, Ledger, Market, Mood, Park, Paused, Policy, Rebuilt, Rising, Risk, Sick, Site, Staff, Storage, Tile, Time, TownHall, Treasury, Upgraded } from "../../schema.ts"
+import { connected, elapsed, seasonAt } from "../shared.ts"
-import { ageNeeds, baseCollection, mealDecay, adminOf, capacity, met, rateOf, shortOf, taxOf, tierFor } from "../rules/households.ts"
-export { adminOf, appealOf, askOf, capacity, kept, met, priceOf, satisfaction, taxOf, tierFor, type Rates } from "../rules/households.ts"
+import { ageNeeds, baseCollection, mealDecay, adminOf, capacity, met, rateOf, shortOf, taxOf, tierFor } from "../../rules/households.ts"
+export { adminOf, appealOf, askOf, capacity, kept, met, priceOf, satisfaction, taxOf, tierFor, type Rates } from "../../rules/households.ts"
/**
* Needs wear off, food faster in winter. Every so often a home settles
diff --git a/src/sim/walkers.ts b/src/game/systems/walkers/index.ts
similarity index 96%
rename from src/sim/walkers.ts
rename to src/game/systems/walkers/index.ts
index dabe5a3..f46c5b6 100644
--- a/src/sim/walkers.ts
+++ b/src/game/systems/walkers/index.ts
@@ -1,7 +1,7 @@
-import { serveGoods } from "../rules/households.ts"
-import { transport } from "../rules/config.ts"
-import { planPatrols } from "../rules/patrol.ts"
-import { appealAt } from "../appeal.ts"
+import { serveGoods } from "../../rules/households.ts"
+import { transport } from "../../rules/config.ts"
+import { planPatrols } from "../../rules/patrol.ts"
+import { appealAt } from "../../world/appeal.ts"
/**
* Walking: every walker steps along its route; service buildings send a
* walker out now and then, who wanders the roads serving the homes beside
@@ -11,12 +11,12 @@ import { appealAt } from "../appeal.ts"
* planks and stone to mend — and walks home when its range is walked.
*/
-import { amounts, categoryColor, each, provisions, stepsOf, total, type Amounts } from "../content.ts"
-import { DIRS, doors, isRoad, key, nearest, ownerAt, pathTo, reach, useAt } from "../grid.ts"
-import { inside, type Point } from "../iso.ts"
-import { Building, Burning, Condition, Figure, Game, Rules, Grid, Appeal, Handed, Patrol, House, Inventory, Pantry, Paused, Recipe, Rescue, Rising, Risk, Roam, Route, Service, Sick, Site, Staff, Status, Tile, Time, WalkerOf, type HandedValue, type Status as StatusValue } from "../schema.ts"
-import { CELL_STEPS } from "./shared.ts"
-import { paced } from "./work.ts"
+import { amounts, categoryColor, each, provisions, stepsOf, total, type Amounts } from "../../content/index.ts"
+import { DIRS, doors, isRoad, key, nearest, ownerAt, pathTo, reach, useAt } from "../../world/grid.ts"
+import { inside, type Point } from "../../world/iso.ts"
+import { Building, Burning, Condition, Figure, Game, Rules, Grid, Appeal, Handed, Patrol, House, Inventory, Pantry, Paused, Recipe, Rescue, Rising, Risk, Roam, Route, Service, Sick, Site, Staff, Status, Tile, Time, WalkerOf, type HandedValue, type Status as StatusValue } from "../../schema.ts"
+import { CELL_STEPS } from "../shared.ts"
+import { paced } from "../work/index.ts"
/** Steps a walker takes each tick: 1.25 cells a second. */
const WALK = transport.walk
diff --git a/src/sim/work.ts b/src/game/systems/work/index.ts
similarity index 98%
rename from src/sim/work.ts
rename to src/game/systems/work/index.ts
index 367f6f2..6252401 100644
--- a/src/sim/work.ts
+++ b/src/game/systems/work/index.ts
@@ -1,5 +1,5 @@
-import { every } from "../content.ts"
-import { wildTreeSpots, canSeedTree } from "../rules/land.ts"
+import { every } from "../../content/index.ts"
+import { wildTreeSpots, canSeedTree } from "../../rules/land.ts"
/**
* Building and working: the grid and the town's stock are indexed, sites
* whose materials are in start going up, workers are assigned, recipes
@@ -8,20 +8,20 @@ import { wildTreeSpots, canSeedTree } from "../rules/land.ts"
*/
import * as Random from "@typeonce/ritmo-math/Random"
-import { fieldDraft, treeDraft } from "../archetypes.ts"
-import { amounts, anA, asUpgraded, crewOf, goodIds, stepsOf, total, upgradeAt, worksNeeded, type Amounts, type Crew } from "../content.ts"
+import { fieldDraft, treeDraft } from "../../world/archetypes.ts"
+import { amounts, anA, asUpgraded, crewOf, goodIds, stepsOf, total, upgradeAt, worksNeeded, type Amounts, type Crew } from "../../content/index.ts"
/** The flow of goods is counted in slices this many seconds long, and the last `FLOW_SLICES` of them (a minute) are kept. */
const FLOW_SLICE = 10
const FLOW_SLICES = 6
const each = (f: (g: (typeof goodIds)[number]) => number): Amounts => Object.fromEntries(goodIds.map((g) => [g, f(g)])) as Amounts
-import { around, doors, GridBuilder, key, ownerAt, reach, roadPrint, useAt } from "../grid.ts"
-import { Building, Burning, Carriers, Charter, Chronicle, Errand, Flow, Roam, Condition, Field, FieldOf, Game, Rules, Gatherer, Grid, House, Inventory, Land, Paused, Paved, Planter, Recipe, Rising, Rng, Rock, Service, Site, Staff, Status, Stock, Storage, Tile, Time, Treasury, Tree, Upgraded, type Status as StatusValue, Water, Works } from "../schema.ts"
-import { connected, elapsed, seasonAt, TileRead, useOf, write } from "./shared.ts"
+import { around, doors, GridBuilder, key, ownerAt, reach, roadPrint, useAt } from "../../world/grid.ts"
+import { Building, Burning, Carriers, Charter, Chronicle, Errand, Flow, Roam, Condition, Field, FieldOf, Game, Rules, Gatherer, Grid, House, Inventory, Land, Paused, Paved, Planter, Recipe, Rising, Rng, Rock, Service, Site, Staff, Status, Stock, Storage, Tile, Time, Treasury, Tree, Upgraded, type Status as StatusValue, Water, Works } from "../../schema.ts"
+import { connected, elapsed, seasonAt, TileRead, useOf, write } from "../shared.ts"
-import { assignWorkers, equipmentPace, effort, paced } from "../rules/production.ts"
-export { effort, paced } from "../rules/production.ts"
+import { assignWorkers, equipmentPace, effort, paced } from "../../rules/production.ts"
+export { effort, paced } from "../../rules/production.ts"
/**
* What stands where on the land, for every system after it this step.
diff --git a/src/appeal.ts b/src/game/world/appeal.ts
similarity index 99%
rename from src/appeal.ts
rename to src/game/world/appeal.ts
index 299da45..dccc2f6 100644
--- a/src/appeal.ts
+++ b/src/game/world/appeal.ts
@@ -1,5 +1,5 @@
import { Ops } from "@typeonce/ritmo-math"
-import { shippedRules, type Rules } from "./rules/config.ts"
+import { shippedRules, type Rules } from "../rules/config.ts"
/**
* Desirability: how pleasant each cell is to live on. Buildings and the land
* add to it or take from it, fading with distance (see `Kind.appeal` and
@@ -11,7 +11,7 @@ import { shippedRules, type Rules } from "./rules/config.ts"
* shared by the simulation (which keeps the whole grid, see `Appraise`) and
* the page (which explains one cell).
*/
-import { upgradeAt, type GroundId, type KindId, type PropId } from "./content.ts"
+import { upgradeAt, type GroundId, type KindId, type PropId } from "../content/index.ts"
import { cellOf, DIRS, key } from "./grid.ts"
import { GRID, inside, type Point } from "./iso.ts"
diff --git a/src/archetypes.ts b/src/game/world/archetypes.ts
similarity index 97%
rename from src/archetypes.ts
rename to src/game/world/archetypes.ts
index 784b681..5a8d20b 100644
--- a/src/archetypes.ts
+++ b/src/game/world/archetypes.ts
@@ -1,4 +1,4 @@
-import { shippedRules, type Rules } from "./rules/config.ts"
+import { shippedRules, type Rules } from "../rules/config.ts"
/**
* Content to components: how each thing in `content.ts` is assembled from
* the schema's components. A building is a `Tile`, a `Building`, a `Status`,
@@ -6,10 +6,10 @@ import { shippedRules, type Rules } from "./rules/config.ts"
* costs materials starts as a `Site`, anything else starts `Rising`; the
* land is a `Tile` and its own marker.
*/
-import { amounts, goodIds, total, type GroundId, type Kind } from "./content.ts"
+import { amounts, goodIds, total, type GroundId, type Kind } from "../content/index.ts"
import type { Point } from "./iso.ts"
-import { Building, Carriers, Condition, Field, Game, Gatherer, House, Inventory, Park, Planter, Recipe, Rising, Risk, Road, Rock, Ruin, Service, Site, Staff, Status, Storage, Tile, Tree, Water } from "./schema.ts"
-import { stepsOf } from "./content.ts"
+import { Building, Carriers, Condition, Field, Game, Gatherer, House, Inventory, Park, Planter, Recipe, Rising, Risk, Road, Rock, Ruin, Service, Site, Staff, Status, Storage, Tile, Tree, Water } from "../schema.ts"
+import { stepsOf } from "../content/index.ts"
const site = (cost: Kind["cost"]) => {
const owed = amounts(cost.materials)
diff --git a/src/grid.ts b/src/game/world/grid.ts
similarity index 99%
rename from src/grid.ts
rename to src/game/world/grid.ts
index 6bf0171..faa979d 100644
--- a/src/grid.ts
+++ b/src/game/world/grid.ts
@@ -5,7 +5,7 @@
* each step.
*/
import { GRID, inside, type Point } from "./iso.ts"
-import type { GridValue, Use } from "./schema.ts"
+import type { GridValue, Use } from "../schema.ts"
export const key = (x: number, y: number): number => y * GRID + x
export const cellOf = (k: number): Point => ({ x: k % GRID, y: Math.floor(k / GRID) })
diff --git a/src/iso.ts b/src/game/world/iso.ts
similarity index 100%
rename from src/iso.ts
rename to src/game/world/iso.ts
diff --git a/src/mapgen.ts b/src/game/world/mapgen.ts
similarity index 98%
rename from src/mapgen.ts
rename to src/game/world/mapgen.ts
index 2233277..806674c 100644
--- a/src/mapgen.ts
+++ b/src/game/world/mapgen.ts
@@ -1,4 +1,4 @@
-import { shippedRules, type Rules } from "./rules/config.ts"
+import { shippedRules, type Rules } from "../rules/config.ts"
/**
* A new town's land, from its charter: an island-like stretch of land of
* the charter's size, its coast wandering in and out and a few capes
@@ -11,7 +11,7 @@ import { shippedRules, type Rules } from "./rules/config.ts"
import { Ops } from "@typeonce/ritmo-math"
import * as Random from "@typeonce/ritmo-math/Random"
-import { GROWN, type CharterValue } from "./content.ts"
+import { GROWN, type CharterValue } from "../content/index.ts"
import { DIRS, key } from "./grid.ts"
import { GRID, inside, type Point } from "./iso.ts"
diff --git a/src/places.ts b/src/game/world/places.ts
similarity index 97%
rename from src/places.ts
rename to src/game/world/places.ts
index d02b845..74de804 100644
--- a/src/places.ts
+++ b/src/game/world/places.ts
@@ -3,7 +3,7 @@
* landmark ("Mill Lane", "Chapel Street"), so a fire or a theft can be told
* as news. The same building always gives its streets the same name.
*/
-import type { KindId } from "./content.ts"
+import type { KindId } from "../content/index.ts"
import { ringOf } from "./appeal.ts"
const streetOf: Readonly<Record<KindId, string>> = {
diff --git a/src/asset-lab/main.ts b/src/labs/asset-lab/main.ts
similarity index 97%
rename from src/asset-lab/main.ts
rename to src/labs/asset-lab/main.ts
index de697e4..27c7000 100644
--- a/src/asset-lab/main.ts
+++ b/src/labs/asset-lab/main.ts
@@ -16,15 +16,15 @@ import {
homeVariant,
plate,
plateHalf
-} from "../art.ts"
-import { kinds, goods } from "../content.ts"
-import { key } from "../grid.ts"
-import { samplePark } from "./town-props.ts"
-import type { PropId } from "../content.ts"
-import { drawPlot } from "../art.ts"
-import { U, toScreen } from "../iso.ts"
-import { inkAssets, assetCategoryTitles, type InkAsset } from "./assets.ts"
-import { buildAsset, exportAsset, reloadExportedAsset } from "./renderer.ts"
+} from "../../render/art.ts"
+import { kinds, goods } from "../../game/content/index.ts"
+import { key } from "../../game/world/grid.ts"
+import { samplePark } from "../../render/three/assets/town-props.ts"
+import type { PropId } from "../../game/content/index.ts"
+import { drawPlot } from "../../render/art.ts"
+import { U, toScreen } from "../../game/world/iso.ts"
+import { inkAssets, assetCategoryTitles, type InkAsset } from "../../render/three/assets/assets.ts"
+import { buildAsset, exportAsset, reloadExportedAsset } from "../../render/three/assets/renderer.ts"
import "./style.css"
const root = document.querySelector<HTMLDivElement>("#lab")!
diff --git a/src/asset-lab/style.css b/src/labs/asset-lab/style.css
similarity index 100%
rename from src/asset-lab/style.css
rename to src/labs/asset-lab/style.css
diff --git a/src/effects-lab/main.ts b/src/labs/effects-lab/main.ts
similarity index 95%
rename from src/effects-lab/main.ts
rename to src/labs/effects-lab/main.ts
index 7046d54..2f027d5 100644
--- a/src/effects-lab/main.ts
+++ b/src/labs/effects-lab/main.ts
@@ -1,10 +1,10 @@
import * as THREE from "three"
-import { house } from "../asset-lab/homes.ts"
-import { home, type Tier } from "../content.ts"
-import { U } from "../iso.ts"
-import { ModelHandle,ModelPool } from "../render3d/pool.ts"
-import { surfaceState,type SurfaceState } from "../render3d/surface-state.ts"
-import { StructureEffects } from "../render3d/structure-effects.ts"
+import { house } from "../../render/three/assets/homes.ts"
+import { home, type Tier } from "../../game/content/index.ts"
+import { U } from "../../game/world/iso.ts"
+import { ModelHandle,ModelPool } from "../../render/three/pool.ts"
+import { surfaceState,type SurfaceState } from "../../render/three/surface-state.ts"
+import { StructureEffects } from "../../render/three/structure-effects.ts"
import "./style.css"
const cases: Array<{title:string;note:string;state:Partial<SurfaceState>}>=[
diff --git a/src/effects-lab/style.css b/src/labs/effects-lab/style.css
similarity index 100%
rename from src/effects-lab/style.css
rename to src/labs/effects-lab/style.css
diff --git a/src/gallery.ts b/src/labs/gallery/main.ts
similarity index 96%
rename from src/gallery.ts
rename to src/labs/gallery/main.ts
index 6b7f4d4..1d03c69 100644
--- a/src/gallery.ts
+++ b/src/labs/gallery/main.ts
@@ -7,11 +7,11 @@
*/
import { Application, Container, Graphics } from "pixi.js"
-import { carrierDress, cartLook, drawBuilding, drawField, drawHouse, drawRoads, drawRock, drawTree, drawWalker, drawWater, homeVariant, plate, plateHalf, residentDress, serviceDress } from "./art.ts"
-import { categoryColor, goodIds, kindIds, kinds } from "./content.ts"
-import { key } from "./grid.ts"
-import { icon, iconNames } from "./icons.ts"
-import { toScreen } from "./iso.ts"
+import { carrierDress, cartLook, drawBuilding, drawField, drawHouse, drawRoads, drawRock, drawTree, drawWalker, drawWater, homeVariant, plate, plateHalf, residentDress, serviceDress } from "../../render/art.ts"
+import { categoryColor, goodIds, kindIds, kinds } from "../../game/content/index.ts"
+import { key } from "../../game/world/grid.ts"
+import { icon, iconNames } from "../../ui/dom/kit/icons.ts"
+import { toScreen } from "../../game/world/iso.ts"
const app = new Application()
await app.init({ resizeTo: window, antialias: true, background: 0xf0f2ec, resolution: Math.min(window.devicePixelRatio || 1, 2), autoDensity: true })
diff --git a/src/map-lab/main.ts b/src/labs/map-lab/main.ts
similarity index 98%
rename from src/map-lab/main.ts
rename to src/labs/map-lab/main.ts
index 0fd2f6e..546146c 100644
--- a/src/map-lab/main.ts
+++ b/src/labs/map-lab/main.ts
@@ -1,8 +1,8 @@
import * as THREE from "three"
import { OrbitControls } from "three/addons/controls/OrbitControls.js"
-import { buildAsset, floorScale } from "../asset-lab/renderer.ts"
-import { inkAssets } from "../asset-lab/assets.ts"
-import { makePerson } from "../asset-lab/people.ts"
+import { buildAsset, floorScale } from "../../render/three/assets/renderer.ts"
+import { inkAssets } from "../../render/three/assets/assets.ts"
+import { makePerson } from "../../render/three/assets/people.ts"
import { testMap, districts } from "./map.ts"
import "./style.css"
diff --git a/src/map-lab/map.ts b/src/labs/map-lab/map.ts
similarity index 99%
rename from src/map-lab/map.ts
rename to src/labs/map-lab/map.ts
index f8411f0..7f59bc9 100644
--- a/src/map-lab/map.ts
+++ b/src/labs/map-lab/map.ts
@@ -1,4 +1,4 @@
-import { inkAssets, palette, type InkAsset, type Vertex } from "../asset-lab/assets.ts"
+import { inkAssets, palette, type InkAsset, type Vertex } from "../../render/three/assets/assets.ts"
export interface MapBuilding {
id: number
diff --git a/src/map-lab/style.css b/src/labs/map-lab/style.css
similarity index 100%
rename from src/map-lab/style.css
rename to src/labs/map-lab/style.css
diff --git a/src/model-review/handoff.css b/src/labs/model-review/handoff.css
similarity index 100%
rename from src/model-review/handoff.css
rename to src/labs/model-review/handoff.css
diff --git a/src/model-review/main.ts b/src/labs/model-review/main.ts
similarity index 98%
rename from src/model-review/main.ts
rename to src/labs/model-review/main.ts
index 3b17e6c..b000b2a 100644
--- a/src/model-review/main.ts
+++ b/src/labs/model-review/main.ts
@@ -1,8 +1,8 @@
import * as THREE from "three"
-import { assetById } from "../asset-lab/assets.ts"
-import { buildAsset, exportAsset } from "../asset-lab/renderer.ts"
-import { kindIds } from "../content.ts"
-import { ruralIds } from "../asset-lab/rural.ts"
+import { assetById } from "../../render/three/assets/assets.ts"
+import { buildAsset, exportAsset } from "../../render/three/assets/renderer.ts"
+import { kindIds } from "../../game/content/index.ts"
+import { ruralIds } from "../../render/three/assets/rural.ts"
import "./style.css"
import "./handoff.css"
diff --git a/src/model-review/park-models.ts b/src/labs/model-review/park-models.ts
similarity index 81%
rename from src/model-review/park-models.ts
rename to src/labs/model-review/park-models.ts
index 93a0806..df5a2c9 100644
--- a/src/model-review/park-models.ts
+++ b/src/labs/model-review/park-models.ts
@@ -1,9 +1,9 @@
-import { assetById } from "../asset-lab/assets.ts"
-import { Drawing, type InkAsset, type Vertex } from "../asset-lab/primitives.ts"
-import { bench, flowerBed, parkAsset } from "../asset-lab/town-props.ts"
+import { assetById } from "../../render/three/assets/assets.ts"
+import { Drawing, type InkAsset, type Vertex } from "../../render/three/assets/primitives.ts"
+import { bench, flowerBed, parkAsset } from "../../render/three/assets/town-props.ts"
import { builtPark } from "../park-lab/park.ts"
-import { key } from "../grid.ts"
-import type { GroundId } from "../content.ts"
+import { key } from "../../game/world/grid.ts"
+import type { GroundId } from "../../game/content/index.ts"
export function parkReviewModels(): InkAsset[] {
const models=["park-lamp","park-statue","park-fountain"].map(id=>assetById.get(id)!)
diff --git a/src/model-review/proportion-models.ts b/src/labs/model-review/proportion-models.ts
similarity index 77%
rename from src/model-review/proportion-models.ts
rename to src/labs/model-review/proportion-models.ts
index 07d02b5..21bdfdc 100644
--- a/src/model-review/proportion-models.ts
+++ b/src/labs/model-review/proportion-models.ts
@@ -1,9 +1,9 @@
-import type { KindId } from "../content.ts"
-import { assetById } from "../asset-lab/assets.ts"
-import { Drawing, type InkAsset } from "../asset-lab/primitives.ts"
-import { chair, chest } from "../asset-lab/furniture.ts"
-import { bench } from "../asset-lab/town-props.ts"
-import { scaffoldAsset } from "../asset-lab/scaffolding.ts"
+import type { KindId } from "../../game/content/index.ts"
+import { assetById } from "../../render/three/assets/assets.ts"
+import { Drawing, type InkAsset } from "../../render/three/assets/primitives.ts"
+import { chair, chest } from "../../render/three/assets/furniture.ts"
+import { bench } from "../../render/three/assets/town-props.ts"
+import { scaffoldAsset } from "../../render/three/assets/scaffolding.ts"
// This review belongs to one approved revision. Future building kinds should
// not silently join a comparison whose frozen originals cannot contain them.
diff --git a/src/model-review/proportions.css b/src/labs/model-review/proportions.css
similarity index 100%
rename from src/model-review/proportions.css
rename to src/labs/model-review/proportions.css
diff --git a/src/model-review/proportions.ts b/src/labs/model-review/proportions.ts
similarity index 99%
rename from src/model-review/proportions.ts
rename to src/labs/model-review/proportions.ts
index be5676f..a856bdf 100644
--- a/src/model-review/proportions.ts
+++ b/src/labs/model-review/proportions.ts
@@ -1,6 +1,6 @@
import * as THREE from "three"
-import { buildAsset, vertex3 } from "../asset-lab/renderer.ts"
-import type { InkAsset } from "../asset-lab/primitives.ts"
+import { buildAsset, vertex3 } from "../../render/three/assets/renderer.ts"
+import type { InkAsset } from "../../render/three/assets/primitives.ts"
import { proportionModels, architectureIds } from "./proportion-models.ts"
import { parkReviewModels } from "./park-models.ts"
import "./proportions.css"
diff --git a/src/model-review/style.css b/src/labs/model-review/style.css
similarity index 100%
rename from src/model-review/style.css
rename to src/labs/model-review/style.css
diff --git a/src/park-lab/main.ts b/src/labs/park-lab/main.ts
similarity index 97%
rename from src/park-lab/main.ts
rename to src/labs/park-lab/main.ts
index 4094b4a..afb46e0 100644
--- a/src/park-lab/main.ts
+++ b/src/labs/park-lab/main.ts
@@ -1,6 +1,6 @@
import * as THREE from "three"
-import { assetById } from "../asset-lab/assets.ts"
-import { buildAsset, type BuiltAsset } from "../asset-lab/renderer.ts"
+import { assetById } from "../../render/three/assets/assets.ts"
+import { buildAsset, type BuiltAsset } from "../../render/three/assets/renderer.ts"
import { builtPark, parkCells, parkSummary } from "./park.ts"
import "./style.css"
diff --git a/src/park-lab/park.ts b/src/labs/park-lab/park.ts
similarity index 77%
rename from src/park-lab/park.ts
rename to src/labs/park-lab/park.ts
index f536167..980e7d6 100644
--- a/src/park-lab/park.ts
+++ b/src/labs/park-lab/park.ts
@@ -1,8 +1,8 @@
-import { samplePark, parkAsset } from "../asset-lab/town-props.ts"
-import { groundAsset } from "../render3d/models.ts"
-import { parksOf } from "../appeal.ts"
-import { key } from "../grid.ts"
-import type { InkAsset, Vertex } from "../asset-lab/primitives.ts"
+import { samplePark, parkAsset } from "../../render/three/assets/town-props.ts"
+import { groundAsset } from "../../render/three/models.ts"
+import { parksOf } from "../../game/world/appeal.ts"
+import { key } from "../../game/world/grid.ts"
+import type { InkAsset, Vertex } from "../../render/three/assets/primitives.ts"
// Place actual park cells beside two road entrances, inside the game's grid.
export const parkCells=samplePark.map(c=>({...c,x:c.x+28,y:c.y+28}))
diff --git a/src/park-lab/style.css b/src/labs/park-lab/style.css
similarity index 100%
rename from src/park-lab/style.css
rename to src/labs/park-lab/style.css
diff --git a/src/asset-lab/service-study.ts b/src/labs/service-study/main.ts
similarity index 97%
rename from src/asset-lab/service-study.ts
rename to src/labs/service-study/main.ts
index 4750a51..5585308 100644
--- a/src/asset-lab/service-study.ts
+++ b/src/labs/service-study/main.ts
@@ -1,7 +1,7 @@
import * as THREE from "three"
-import { assetById } from "./assets.ts"
-import { buildAsset, exportAsset, floorScale, vertex3 } from "./renderer.ts"
-import "./service-study.css"
+import { assetById } from "../../render/three/assets/assets.ts"
+import { buildAsset, exportAsset, floorScale, vertex3 } from "../../render/three/assets/renderer.ts"
+import "./style.css"
const root = document.querySelector<HTMLElement>("#service-study")!
root.innerHTML = `
diff --git a/src/asset-lab/service-study.css b/src/labs/service-study/style.css
similarity index 100%
rename from src/asset-lab/service-study.css
rename to src/labs/service-study/style.css
diff --git a/src/save.ts b/src/platform/save.ts
similarity index 99%
rename from src/save.ts
rename to src/platform/save.ts
index 19ed249..1be80fa 100644
--- a/src/save.ts
+++ b/src/platform/save.ts
@@ -10,7 +10,7 @@
*/
import { Clock, Context, Effect, Schema } from "effect"
-import { goodIds, TOWN_RANK, TRADE_LOAD } from "./content.ts"
+import { goodIds, TOWN_RANK, TRADE_LOAD } from "../game/content/index.ts"
export const SAVE_FORMAT = "inkline-town/save"
/**
diff --git a/src/share/card.ts b/src/platform/share/card.ts
similarity index 97%
rename from src/share/card.ts
rename to src/platform/share/card.ts
index 7809788..a480172 100644
--- a/src/share/card.ts
+++ b/src/platform/share/card.ts
@@ -3,9 +3,9 @@
* strip of paper along the bottom saying what it is and how it stands (its
* verdict once the term is over), drawn in the page's ink and type.
*/
-import { lands, sizes } from "../content.ts"
-import { icon, type IconName } from "../icons.ts"
-import type { Stats } from "../ui.ts"
+import { lands, sizes } from "../../game/content/index.ts"
+import { icon, type IconName } from "../../ui/dom/kit/icons.ts"
+import type { Stats } from "../../view/contracts.ts"
import { PICTURE_HEIGHT, PICTURE_WIDTH, type ShareMeta } from "./format.ts"
const INK = "#3d4943",
diff --git a/src/share/client.ts b/src/platform/share/client.ts
similarity index 100%
rename from src/share/client.ts
rename to src/platform/share/client.ts
diff --git a/src/share/format.ts b/src/platform/share/format.ts
similarity index 100%
rename from src/share/format.ts
rename to src/platform/share/format.ts
diff --git a/src/art.ts b/src/render/art.ts
similarity index 99%
rename from src/art.ts
rename to src/render/art.ts
index 7dbc8c2..a1fe410 100644
--- a/src/art.ts
+++ b/src/render/art.ts
@@ -20,11 +20,11 @@
* - a crate is 6 units wide, a carried one 4.
*/
import { Container, Graphics } from "pixi.js"
-import type { SurfaceState } from "./render3d/surface-state.ts"
+import type { SurfaceState } from "./three/surface-state.ts"
-import { goods, GROWN, home, kinds, ROCK_AMOUNT, type GoodId, type GroundId, type Kind, type KindId, type PropId, type Tier } from "./content.ts"
-import { cellOf, DIRS, key } from "./grid.ts"
-import { flat, GRID, toScreen, U, type Point } from "./iso.ts"
+import { goods, GROWN, home, kinds, ROCK_AMOUNT, type GoodId, type GroundId, type Kind, type KindId, type PropId, type Tier } from "../game/content/index.ts"
+import { cellOf, DIRS, key } from "../game/world/grid.ts"
+import { flat, GRID, toScreen, U, type Point } from "../game/world/iso.ts"
export const ink = 0x3d4943
const plateFill = 0xf5f6f2
diff --git a/src/asset-lab/appearance.ts b/src/render/three/assets/appearance.ts
similarity index 89%
rename from src/asset-lab/appearance.ts
rename to src/render/three/assets/appearance.ts
index 1c01cd6..6028354 100644
--- a/src/asset-lab/appearance.ts
+++ b/src/render/three/assets/appearance.ts
@@ -1,5 +1,5 @@
import { type InkAsset } from "./primitives.ts"
-import { surfaceState } from "../render3d/surface-state.ts"
+import { surfaceState } from "../surface-state.ts"
export interface Appearance { worn?: boolean; band?: "poor" | "plain" | "fine"; winter?: boolean }
/** State is material data. The original mesh and its ink stay identical. */
export function withAppearance(asset: InkAsset, a: number, H: number, look: Appearance = {}, _home = false): InkAsset {
diff --git a/src/asset-lab/assets.ts b/src/render/three/assets/assets.ts
similarity index 97%
rename from src/asset-lab/assets.ts
rename to src/render/three/assets/assets.ts
index 91507f9..d88f4e6 100644
--- a/src/asset-lab/assets.ts
+++ b/src/render/three/assets/assets.ts
@@ -1,13 +1,13 @@
/** Portable polygon-and-stroke assets. Floor coordinates remain in cells;
* heights remain in the original drawing's pixels. No renderer types here. */
-import { kindIds, goodIds, kinds, home, propIds } from "../content.ts"
+import { kindIds, goodIds, kinds, home, propIds } from "../../../game/content/index.ts"
import { withAppearance } from "./appearance.ts"
-import { groundAsset } from "../render3d/models.ts"
-import { key } from "../grid.ts"
+import { groundAsset } from "../models.ts"
+import { key } from "../../../game/world/grid.ts"
import { makeBuilding, buildingDimensions } from "./buildings.ts"
import { house } from "./homes.ts"
import { marketHall, church } from "./service-upgrades.ts"
-import { U } from "../iso.ts"
+import { U } from "../../../game/world/iso.ts"
import { makeTree, makeRock, makeField, makeRoadPatch, makeWater } from "./land.ts"
import { personCatalogue, makeCarrier, makeGoods, makeCrate } from "./people.ts"
import { makeSite, makeConstruction, makeMarker, makeUpgradeMarker, makeSmoke, makePlot } from "./construction.ts"
diff --git a/src/asset-lab/buildings.ts b/src/render/three/assets/buildings.ts
similarity index 99%
rename from src/asset-lab/buildings.ts
rename to src/render/three/assets/buildings.ts
index 7e90e77..75891e5 100644
--- a/src/asset-lab/buildings.ts
+++ b/src/render/three/assets/buildings.ts
@@ -1,5 +1,5 @@
-import { kinds, type KindId } from "../content.ts"
-import { U } from "../iso.ts"
+import { kinds, type KindId } from "../../../game/content/index.ts"
+import { U } from "../../../game/world/iso.ts"
import { Drawing, palette, pale, square, sides, type Vertex, type Side } from "./primitives.ts"
import { finishTownBuilding, townBuildingNotes, institutionDoor, makeQuarry } from "./services.ts"
import { isWorkshop, makeWorkshop, workshopSmokeOrigin, townHallEntrance } from "./workshops.ts"
diff --git a/src/asset-lab/carpenter.ts b/src/render/three/assets/carpenter.ts
similarity index 97%
rename from src/asset-lab/carpenter.ts
rename to src/render/three/assets/carpenter.ts
index 5ecc6dc..ec993b0 100644
--- a/src/asset-lab/carpenter.ts
+++ b/src/render/three/assets/carpenter.ts
@@ -1,9 +1,9 @@
-import { U } from "../iso.ts"
+import { U } from "../../../game/world/iso.ts"
import { Drawing, palette, type Vertex } from "./primitives.ts"
import type { BuildingOptions } from "./buildings.ts"
import { beam, block, iron, orient, post, roof, stone, wood } from "./workshops.ts"
import { chair, chest } from "./furniture.ts"
-import { buildStages } from "../art.ts"
+import { buildStages } from "../../art.ts"
/** A roofed bench bay at the back leaves the forecourt open to work. */
export function makeCarpenter(options: BuildingOptions = {}) {
diff --git a/src/asset-lab/civic.ts b/src/render/three/assets/civic.ts
similarity index 99%
rename from src/asset-lab/civic.ts
rename to src/render/three/assets/civic.ts
index 4f0e82d..d545f43 100644
--- a/src/asset-lab/civic.ts
+++ b/src/render/three/assets/civic.ts
@@ -1,4 +1,4 @@
-import { U } from "../iso.ts"
+import { U } from "../../../game/world/iso.ts"
import { Drawing, mix, pale, sides, type Side, type Vertex } from "./primitives.ts"
import { beam, block, orient, roof, stone } from "./workshops.ts"
import type { BuildingOptions } from "./buildings.ts"
diff --git a/src/asset-lab/construction.ts b/src/render/three/assets/construction.ts
similarity index 96%
rename from src/asset-lab/construction.ts
rename to src/render/three/assets/construction.ts
index ae96cfc..9609e86 100644
--- a/src/asset-lab/construction.ts
+++ b/src/render/three/assets/construction.ts
@@ -1,7 +1,7 @@
import { Drawing, palette, square, type Vertex } from "./primitives.ts"
-import { buildStages } from "../art.ts"
-import { kinds, type KindId } from "../content.ts"
-import { U } from "../iso.ts"
+import { buildStages } from "../../art.ts"
+import { kinds, type KindId } from "../../../game/content/index.ts"
+import { U } from "../../../game/world/iso.ts"
import { buildingDimensions } from "./buildings.ts"
export function makeSite(share: number, size = 2) {
diff --git a/src/asset-lab/dimensions.ts b/src/render/three/assets/dimensions.ts
similarity index 94%
rename from src/asset-lab/dimensions.ts
rename to src/render/three/assets/dimensions.ts
index 3e4f714..3018f7f 100644
--- a/src/asset-lab/dimensions.ts
+++ b/src/render/three/assets/dimensions.ts
@@ -1,4 +1,4 @@
-import type { KindId } from "../content.ts"
+import type { KindId } from "../../../game/content/index.ts"
/** Authored vertical pixels. Walkers stay 17 units tall including their cap.
* Floors, openings and furniture share a human reference; towers do not. */
diff --git a/src/asset-lab/furniture.ts b/src/render/three/assets/furniture.ts
similarity index 95%
rename from src/asset-lab/furniture.ts
rename to src/render/three/assets/furniture.ts
index 8012727..9e43fd9 100644
--- a/src/asset-lab/furniture.ts
+++ b/src/render/three/assets/furniture.ts
@@ -1,4 +1,4 @@
-import { U } from "../iso.ts"
+import { U } from "../../../game/world/iso.ts"
import { Drawing } from "./primitives.ts"
import { block, wood, iron } from "./workshops.ts"
import { human } from "./dimensions.ts"
diff --git a/src/asset-lab/homes.ts b/src/render/three/assets/homes.ts
similarity index 94%
rename from src/asset-lab/homes.ts
rename to src/render/three/assets/homes.ts
index 9026936..a6e798d 100644
--- a/src/asset-lab/homes.ts
+++ b/src/render/three/assets/homes.ts
@@ -1,6 +1,6 @@
-import { home } from "../content.ts"
-import { homeVariant } from "../art.ts"
-import { U } from "../iso.ts"
+import { home } from "../../../game/content/index.ts"
+import { homeVariant } from "../../art.ts"
+import { U } from "../../../game/world/iso.ts"
import { Drawing, palette, sides, type Side } from "./primitives.ts"
import { human, residentialHeight } from "./dimensions.ts"
diff --git a/src/asset-lab/land.ts b/src/render/three/assets/land.ts
similarity index 99%
rename from src/asset-lab/land.ts
rename to src/render/three/assets/land.ts
index caa3c32..605e211 100644
--- a/src/asset-lab/land.ts
+++ b/src/render/three/assets/land.ts
@@ -1,5 +1,5 @@
import { Drawing, palette, square, type Vertex } from "./primitives.ts"
-import { U } from "../iso.ts"
+import { U } from "../../../game/world/iso.ts"
export const hash = (x: number, y: number) => {
let h = (x * 374761393 + y * 668265263) >>> 0
diff --git a/src/asset-lab/park-furnishings.ts b/src/render/three/assets/park-furnishings.ts
similarity index 99%
rename from src/asset-lab/park-furnishings.ts
rename to src/render/three/assets/park-furnishings.ts
index 7edfb87..b04ea4e 100644
--- a/src/asset-lab/park-furnishings.ts
+++ b/src/render/three/assets/park-furnishings.ts
@@ -1,4 +1,4 @@
-import { U } from "../iso.ts"
+import { U } from "../../../game/world/iso.ts"
import { Drawing, mix, type Vertex } from "./primitives.ts"
import { beam, block, iron, stone, wood } from "./workshops.ts"
import { human } from "./dimensions.ts"
diff --git a/src/asset-lab/park-ground.ts b/src/render/three/assets/park-ground.ts
similarity index 100%
rename from src/asset-lab/park-ground.ts
rename to src/render/three/assets/park-ground.ts
diff --git a/src/asset-lab/people.ts b/src/render/three/assets/people.ts
similarity index 99%
rename from src/asset-lab/people.ts
rename to src/render/three/assets/people.ts
index 7c7746a..0705438 100644
--- a/src/asset-lab/people.ts
+++ b/src/render/three/assets/people.ts
@@ -1,7 +1,7 @@
-import { carrierDress, cartLook, residentDress, serviceDress, homeVariant, type CartLook, type Load, type PersonDress } from "../art.ts"
-import { goods, type GoodId } from "../content.ts"
+import { carrierDress, cartLook, residentDress, serviceDress, homeVariant, type CartLook, type Load, type PersonDress } from "../../art.ts"
+import { goods, type GoodId } from "../../../game/content/index.ts"
import { Drawing, palette, type Vertex } from "./primitives.ts"
-import { U } from "../iso.ts"
+import { U } from "../../../game/world/iso.ts"
import { chair, chest } from "./furniture.ts"
const R = 45.2548
diff --git a/src/asset-lab/primitives.ts b/src/render/three/assets/primitives.ts
similarity index 98%
rename from src/asset-lab/primitives.ts
rename to src/render/three/assets/primitives.ts
index 24a7717..b7974f6 100644
--- a/src/asset-lab/primitives.ts
+++ b/src/render/three/assets/primitives.ts
@@ -1,8 +1,8 @@
/** Portable geometry in grid cells and original pixel heights. */
-import { U } from "../iso.ts"
-import type { GoodId, KindId, Tier } from "../content.ts"
-import type { CartLook, Load, PersonDress } from "../art.ts"
-import type { SurfaceState } from "../render3d/surface-state.ts"
+import { U } from "../../../game/world/iso.ts"
+import type { GoodId, KindId, Tier } from "../../../game/content/index.ts"
+import type { CartLook, Load, PersonDress } from "../../art.ts"
+import type { SurfaceState } from "../surface-state.ts"
export type Vertex = readonly [u: number, v: number, height: number]
export interface Face {
diff --git a/src/asset-lab/renderer.ts b/src/render/three/assets/renderer.ts
similarity index 99%
rename from src/asset-lab/renderer.ts
rename to src/render/three/assets/renderer.ts
index 04a2850..e55e792 100644
--- a/src/asset-lab/renderer.ts
+++ b/src/render/three/assets/renderer.ts
@@ -6,9 +6,9 @@ import { GLTFExporter } from "three/addons/exporters/GLTFExporter.js"
import { GLTFLoader } from "three/addons/loaders/GLTFLoader.js"
import { mergeGeometries, mergeVertices } from "three/addons/utils/BufferGeometryUtils.js"
import { palette, type Face, type InkAsset, type Vertex } from "./primitives.ts"
-import { installSurfaceShader } from "../render3d/surface-shader.ts"
-import { SmokePlume } from "../render3d/smoke-effects.ts"
-import { FountainWater } from "../render3d/fountain-effects.ts"
+import { installSurfaceShader } from "../surface-shader.ts"
+import { SmokePlume } from "../smoke-effects.ts"
+import { FountainWater } from "../fountain-effects.ts"
/** A 30° elevation and 45° heading reproduce the game's 64×32 projection.
* The vertical conversion preserves pixel-authored building heights exactly. */
diff --git a/src/asset-lab/rural.ts b/src/render/three/assets/rural.ts
similarity index 98%
rename from src/asset-lab/rural.ts
rename to src/render/three/assets/rural.ts
index 9b138aa..d4602de 100644
--- a/src/asset-lab/rural.ts
+++ b/src/render/three/assets/rural.ts
@@ -1,5 +1,5 @@
-import { type KindId } from "../content.ts"
-import { U } from "../iso.ts"
+import { type KindId } from "../../../game/content/index.ts"
+import { U } from "../../../game/world/iso.ts"
import { Drawing, palette, pale, type Side, type Vertex } from "./primitives.ts"
import { beam, block, iron, post, stone, wood } from "./workshops.ts"
import { human } from "./dimensions.ts"
diff --git a/src/asset-lab/scaffolding.ts b/src/render/three/assets/scaffolding.ts
similarity index 98%
rename from src/asset-lab/scaffolding.ts
rename to src/render/three/assets/scaffolding.ts
index 66e3cc9..bc28b10 100644
--- a/src/asset-lab/scaffolding.ts
+++ b/src/render/three/assets/scaffolding.ts
@@ -1,4 +1,4 @@
-import { U } from "../iso.ts"
+import { U } from "../../../game/world/iso.ts"
import { Drawing, type Vertex } from "./primitives.ts"
import { beam as solidBeam, block as solidBlock, stone, wood } from "./workshops.ts"
import { human } from "./dimensions.ts"
diff --git a/src/asset-lab/service-upgrades.ts b/src/render/three/assets/service-upgrades.ts
similarity index 99%
rename from src/asset-lab/service-upgrades.ts
rename to src/render/three/assets/service-upgrades.ts
index 08095fa..ac7c223 100644
--- a/src/asset-lab/service-upgrades.ts
+++ b/src/render/three/assets/service-upgrades.ts
@@ -1,5 +1,5 @@
-import { U } from "../iso.ts"
-import { kinds } from "../content.ts"
+import { U } from "../../../game/world/iso.ts"
+import { kinds } from "../../../game/content/index.ts"
import { makeBuilding } from "./buildings.ts"
import { Drawing, palette, pale, sides, type InkAsset, type Side, type Vertex } from "./primitives.ts"
diff --git a/src/asset-lab/services.ts b/src/render/three/assets/services.ts
similarity index 98%
rename from src/asset-lab/services.ts
rename to src/render/three/assets/services.ts
index 15ba1af..b07b049 100644
--- a/src/asset-lab/services.ts
+++ b/src/render/three/assets/services.ts
@@ -1,5 +1,5 @@
-import { kinds, type KindId } from "../content.ts"
-import { U } from "../iso.ts"
+import { kinds, type KindId } from "../../../game/content/index.ts"
+import { U } from "../../../game/world/iso.ts"
import { Drawing, palette, pale, sides, square, type Vertex, type Side } from "./primitives.ts"
import { bench, flowerBed } from "./town-props.ts"
import type { BuildingOptions } from "./buildings.ts"
diff --git a/src/asset-lab/town-props.ts b/src/render/three/assets/town-props.ts
similarity index 97%
rename from src/asset-lab/town-props.ts
rename to src/render/three/assets/town-props.ts
index 18f3cda..0cb6fca 100644
--- a/src/asset-lab/town-props.ts
+++ b/src/render/three/assets/town-props.ts
@@ -4,10 +4,10 @@
* They are built from the same primitives as everything else so they
* have complete rotatable geometry in the same pale ink palette.
*/
-import type { ParkCell } from "../appeal.ts"
-import { props, type GroundId, type PropId } from "../content.ts"
-import { cellOf, DIRS, key } from "../grid.ts"
-import { U } from "../iso.ts"
+import type { ParkCell } from "../../../game/world/appeal.ts"
+import { props, type GroundId, type PropId } from "../../../game/content/index.ts"
+import { cellOf, DIRS, key } from "../../../game/world/grid.ts"
+import { U } from "../../../game/world/iso.ts"
import { hash } from "./land.ts"
import { founderStatue, parkBench, parkFountain, parkLamp, plantedBorder } from "./park-furnishings.ts"
import { flowerPlot, gravelWalk, parkPaving, turf } from "./park-ground.ts"
diff --git a/src/asset-lab/trades.ts b/src/render/three/assets/trades.ts
similarity index 98%
rename from src/asset-lab/trades.ts
rename to src/render/three/assets/trades.ts
index 00e623a..6427ce7 100644
--- a/src/asset-lab/trades.ts
+++ b/src/render/three/assets/trades.ts
@@ -1,6 +1,6 @@
-import { buildStages } from "../art.ts"
-import { kinds, type KindId } from "../content.ts"
-import { U } from "../iso.ts"
+import { buildStages } from "../../art.ts"
+import { kinds, type KindId } from "../../../game/content/index.ts"
+import { U } from "../../../game/world/iso.ts"
import { Drawing, palette, pale, type Side, type Vertex } from "./primitives.ts"
import type { BuildingOptions } from "./buildings.ts"
import { beam, block, iron, orient, post, roof, stone, wheel, wood, workshopPoint } from "./workshops.ts"
diff --git a/src/asset-lab/upgrade-catalogue.ts b/src/render/three/assets/upgrade-catalogue.ts
similarity index 100%
rename from src/asset-lab/upgrade-catalogue.ts
rename to src/render/three/assets/upgrade-catalogue.ts
diff --git a/src/asset-lab/upgrade-dress.ts b/src/render/three/assets/upgrade-dress.ts
similarity index 98%
rename from src/asset-lab/upgrade-dress.ts
rename to src/render/three/assets/upgrade-dress.ts
index 77c960c..a646836 100644
--- a/src/asset-lab/upgrade-dress.ts
+++ b/src/render/three/assets/upgrade-dress.ts
@@ -1,6 +1,6 @@
/** Supported additions to the existing buildings, inside their plots. */
-import { U } from "../iso.ts"
-import type { KindId } from "../content.ts"
+import { U } from "../../../game/world/iso.ts"
+import type { KindId } from "../../../game/content/index.ts"
import { Drawing, square, type InkAsset } from "./primitives.ts"
import { beam, block, iron, orient, post, roof, stone, wheel, wood } from "./workshops.ts"
import type { BuildingOptions } from "./buildings.ts"
diff --git a/src/asset-lab/workshops.ts b/src/render/three/assets/workshops.ts
similarity index 99%
rename from src/asset-lab/workshops.ts
rename to src/render/three/assets/workshops.ts
index 44190dc..e2ec28e 100644
--- a/src/asset-lab/workshops.ts
+++ b/src/render/three/assets/workshops.ts
@@ -1,6 +1,6 @@
-import { buildStages } from "../art.ts"
-import { kinds, type KindId } from "../content.ts"
-import { U } from "../iso.ts"
+import { buildStages } from "../../art.ts"
+import { kinds, type KindId } from "../../../game/content/index.ts"
+import { U } from "../../../game/world/iso.ts"
import { rockOutcrop } from "./land.ts"
import { Drawing, palette, pale, type InkAsset, type Side, type Vertex } from "./primitives.ts"
import type { BuildingOptions } from "./buildings.ts"
diff --git a/src/render3d/fish-effects.ts b/src/render/three/fish-effects.ts
similarity index 96%
rename from src/render3d/fish-effects.ts
rename to src/render/three/fish-effects.ts
index e9a315d..4982e5d 100644
--- a/src/render3d/fish-effects.ts
+++ b/src/render/three/fish-effects.ts
@@ -1,6 +1,6 @@
import * as THREE from "three"
-import { floorScale, vertex3 } from "../asset-lab/renderer.ts"
-import type { Point } from "../iso.ts"
+import { floorScale, vertex3 } from "./assets/renderer.ts"
+import type { Point } from "../../game/world/iso.ts"
const vertex = `
attribute float seed;
diff --git a/src/render3d/fountain-effects.ts b/src/render/three/fountain-effects.ts
similarity index 98%
rename from src/render3d/fountain-effects.ts
rename to src/render/three/fountain-effects.ts
index 566b7ef..6606ae3 100644
--- a/src/render3d/fountain-effects.ts
+++ b/src/render/three/fountain-effects.ts
@@ -1,5 +1,5 @@
import * as THREE from "three"
-import type { InkAsset } from "../asset-lab/primitives.ts"
+import type { InkAsset } from "./assets/primitives.ts"
type Fountain = NonNullable<InkAsset["fountains"]>[number]
const floorScale=32*Math.SQRT2, heightScale=1/Math.cos(Math.PI/6)
diff --git a/src/render3d/input.ts b/src/render/three/input.ts
similarity index 99%
rename from src/render3d/input.ts
rename to src/render/three/input.ts
index 7b1841f..7ad695d 100644
--- a/src/render3d/input.ts
+++ b/src/render/three/input.ts
@@ -1,5 +1,5 @@
-import type { Point } from "../iso.ts"
-import type { UiValue } from "../ui.ts"
+import type { Point } from "../../game/world/iso.ts"
+import type { UiValue } from "../../view/contracts.ts"
import type { GameScene } from "./scene.ts"
/** Camera gestures and game gestures share the canvas, but a pan, orbit or
diff --git a/src/render3d/models.ts b/src/render/three/models.ts
similarity index 94%
rename from src/render3d/models.ts
rename to src/render/three/models.ts
index 8e53fd4..832e81b 100644
--- a/src/render3d/models.ts
+++ b/src/render/three/models.ts
@@ -1,20 +1,20 @@
import { buildStages, homeVariant } from "../art.ts"
-import { makeBuilding, buildingDimensions, type BuildingOptions } from "../asset-lab/buildings.ts"
-import { house } from "../asset-lab/homes.ts"
-import { Drawing, palette, square, type InkAsset, type Vertex, type Side } from "../asset-lab/primitives.ts"
-import { hash } from "../asset-lab/land.ts"
-import { kinds, home, type GroundId, type KindId, type PropId, type Tier } from "../content.ts"
-import { GRID, U, type Point } from "../iso.ts"
-import { key, cellOf, DIRS } from "../grid.ts"
-import type { Preview } from "../ui.ts"
-import { withAppearance, type Appearance } from "../asset-lab/appearance.ts"
-import { parkAsset, setts } from "../asset-lab/town-props.ts"
-import { isWorkshop, workshopConstruction } from "../asset-lab/workshops.ts"
-import { isTradeYard, tradeConstruction } from "../asset-lab/trades.ts"
-import { serviceBuilding, upgradeHeights, type ServiceKind } from "../asset-lab/service-upgrades.ts"
-import { dressedBuilding, dressedTop, isDressed, scaffoldAsset } from "../asset-lab/upgrade-dress.ts"
-import { carpenterConstruction } from "../asset-lab/carpenter.ts"
-import { civicEave } from "../asset-lab/civic.ts"
+import { makeBuilding, buildingDimensions, type BuildingOptions } from "./assets/buildings.ts"
+import { house } from "./assets/homes.ts"
+import { Drawing, palette, square, type InkAsset, type Vertex, type Side } from "./assets/primitives.ts"
+import { hash } from "./assets/land.ts"
+import { kinds, home, type GroundId, type KindId, type PropId, type Tier } from "../../game/content/index.ts"
+import { GRID, U, type Point } from "../../game/world/iso.ts"
+import { key, cellOf, DIRS } from "../../game/world/grid.ts"
+import type { Preview } from "../../view/contracts.ts"
+import { withAppearance, type Appearance } from "./assets/appearance.ts"
+import { parkAsset, setts } from "./assets/town-props.ts"
+import { isWorkshop, workshopConstruction } from "./assets/workshops.ts"
+import { isTradeYard, tradeConstruction } from "./assets/trades.ts"
+import { serviceBuilding, upgradeHeights, type ServiceKind } from "./assets/service-upgrades.ts"
+import { dressedBuilding, dressedTop, isDressed, scaffoldAsset } from "./assets/upgrade-dress.ts"
+import { carpenterConstruction } from "./assets/carpenter.ts"
+import { civicEave } from "./assets/civic.ts"
export { scaffoldAsset }
export type DoorSet = Record<Side, boolean>
diff --git a/src/render3d/pool.ts b/src/render/three/pool.ts
similarity index 98%
rename from src/render3d/pool.ts
rename to src/render/three/pool.ts
index 3aaa50b..0bf14d9 100644
--- a/src/render3d/pool.ts
+++ b/src/render/three/pool.ts
@@ -1,6 +1,6 @@
import * as THREE from "three"
-import { buildAsset, type BuiltAsset } from "../asset-lab/renderer.ts"
-import type { InkAsset } from "../asset-lab/primitives.ts"
+import { buildAsset, type BuiltAsset } from "./assets/renderer.ts"
+import type { InkAsset } from "./assets/primitives.ts"
import { surfaceState, type SurfaceState } from "./surface-state.ts"
import { installSurfaceShader } from "./surface-shader.ts"
diff --git a/src/render3d/portrait.ts b/src/render/three/portrait.ts
similarity index 95%
rename from src/render3d/portrait.ts
rename to src/render/three/portrait.ts
index 8448c17..16da251 100644
--- a/src/render3d/portrait.ts
+++ b/src/render/three/portrait.ts
@@ -5,8 +5,8 @@
* sits beside the 2D pictures the models were built from.
*/
import * as THREE from "three"
-import { buildAsset } from "../asset-lab/renderer.ts"
-import type { InkAsset } from "../asset-lab/primitives.ts"
+import { buildAsset } from "./assets/renderer.ts"
+import type { InkAsset } from "./assets/primitives.ts"
let renderer: THREE.WebGLRenderer | null = null
diff --git a/src/render3d/rock-blocks.ts b/src/render/three/rock-blocks.ts
similarity index 98%
rename from src/render3d/rock-blocks.ts
rename to src/render/three/rock-blocks.ts
index 647ebf2..f543973 100644
--- a/src/render3d/rock-blocks.ts
+++ b/src/render/three/rock-blocks.ts
@@ -5,7 +5,7 @@
* block's first cell; the others draw nothing. It only changes the picture:
* a quarry still cuts, and a rock still runs out, one cell at a time.
*/
-import { hash } from "../asset-lab/land.ts"
+import { hash } from "./assets/land.ts"
export interface RockCell {
readonly id: number
diff --git a/src/render3d/scene.ts b/src/render/three/scene.ts
similarity index 96%
rename from src/render3d/scene.ts
rename to src/render/three/scene.ts
index 0820aa3..6b8b770 100644
--- a/src/render3d/scene.ts
+++ b/src/render/three/scene.ts
@@ -1,18 +1,18 @@
import * as THREE from "three"
import { NodeRegistry } from "@typeonce/ritmo-render"
-import { buildAsset, floorScale, vertex3, type BuiltAsset } from "../asset-lab/renderer.ts"
-import { house } from "../asset-lab/homes.ts"
-import { makeBuilding } from "../asset-lab/buildings.ts"
-import type { InkAsset } from "../asset-lab/primitives.ts"
-import { GRID, type Point } from "../iso.ts"
-import { key } from "../grid.ts"
-import { kinds } from "../content.ts"
-import type { Preview, UiValue } from "../ui.ts"
+import { buildAsset, floorScale, vertex3, type BuiltAsset } from "./assets/renderer.ts"
+import { house } from "./assets/homes.ts"
+import { makeBuilding } from "./assets/buildings.ts"
+import type { InkAsset } from "./assets/primitives.ts"
+import { GRID, type Point } from "../../game/world/iso.ts"
+import { key } from "../../game/world/grid.ts"
+import { kinds } from "../../game/content/index.ts"
+import type { Preview, UiValue } from "../../view/contracts.ts"
import { ModelHandle, ModelPool } from "./pool.ts"
import { groundAsset, landAsset, overlayAsset, previewAsset, type OverlayCell } from "./models.ts"
-import { parkAsset } from "../asset-lab/town-props.ts"
+import { parkAsset } from "./assets/town-props.ts"
import { FishWater } from "./fish-effects.ts"
-import type { ParkCell } from "../appeal.ts"
+import type { ParkCell } from "../../game/world/appeal.ts"
/** Where the camera stands: the grid cell it looks at, its zoom, and its angles. */
export interface CameraView {
diff --git a/src/render3d/smoke-effects.ts b/src/render/three/smoke-effects.ts
similarity index 100%
rename from src/render3d/smoke-effects.ts
rename to src/render/three/smoke-effects.ts
diff --git a/src/render3d/structure-effects.ts b/src/render/three/structure-effects.ts
similarity index 98%
rename from src/render3d/structure-effects.ts
rename to src/render/three/structure-effects.ts
index faf3fb9..a96ab71 100644
--- a/src/render3d/structure-effects.ts
+++ b/src/render/three/structure-effects.ts
@@ -1,5 +1,5 @@
import * as THREE from "three"
-import { type InkAsset } from "../asset-lab/primitives.ts"
+import { type InkAsset } from "./assets/primitives.ts"
import { surfaceState, type SurfaceState } from "./surface-state.ts"
const vertex = `
diff --git a/src/render3d/surface-shader.ts b/src/render/three/surface-shader.ts
similarity index 100%
rename from src/render3d/surface-shader.ts
rename to src/render/three/surface-shader.ts
diff --git a/src/render3d/surface-state.ts b/src/render/three/surface-state.ts
similarity index 100%
rename from src/render3d/surface-state.ts
rename to src/render/three/surface-state.ts
diff --git a/src/townsfolk.ts b/src/render/three/townsfolk.ts
similarity index 92%
rename from src/townsfolk.ts
rename to src/render/three/townsfolk.ts
index c1e6f21..a89208b 100644
--- a/src/townsfolk.ts
+++ b/src/render/three/townsfolk.ts
@@ -4,13 +4,13 @@
* `residentDress`). They are only for looking at: not part of the
* simulation, not saved, and they do nothing to the town.
*/
-import { homeAt, residentDress } from "./art.ts"
-import { WalkerView } from "./render3d/views.ts"
-import type { GameScene } from "./render3d/scene.ts"
-import type { Tier } from "./content.ts"
-import { DIRS, doors, isRoad } from "./grid.ts"
-import { U, type Point } from "./iso.ts"
-import type { GridValue } from "./schema.ts"
+import { homeAt, residentDress } from "../art.ts"
+import { WalkerView } from "./views.ts"
+import type { GameScene } from "./scene.ts"
+import type { Tier } from "../../game/content/index.ts"
+import { DIRS, doors, isRoad } from "../../game/world/grid.ts"
+import { U, type Point } from "../../game/world/iso.ts"
+import type { GridValue } from "../../game/schema.ts"
/** A home as the townsfolk see it. */
export interface Household {
diff --git a/src/render3d/views.ts b/src/render/three/views.ts
similarity index 97%
rename from src/render3d/views.ts
rename to src/render/three/views.ts
index b1dd854..ff1cd99 100644
--- a/src/render3d/views.ts
+++ b/src/render/three/views.ts
@@ -11,18 +11,18 @@ import {
type Load,
type Emphasis
} from "../art.ts"
-import { kinds, home, GROWN, ROCK_AMOUNT, type KindId } from "../content.ts"
-import { U, type Point } from "../iso.ts"
-import { vertex3 } from "../asset-lab/renderer.ts"
-import { Drawing, type Vertex } from "../asset-lab/primitives.ts"
-import { makeSails, makeFlag, buildingSmokeOrigin, buildingDimensions } from "../asset-lab/buildings.ts"
-import { makeMarker, makeUpgradeMarker } from "../asset-lab/construction.ts"
-import { makeRuin } from "../asset-lab/town-props.ts"
+import { kinds, home, GROWN, ROCK_AMOUNT, type KindId } from "../../game/content/index.ts"
+import { U, type Point } from "../../game/world/iso.ts"
+import { vertex3 } from "./assets/renderer.ts"
+import { Drawing, type Vertex } from "./assets/primitives.ts"
+import { makeSails, makeFlag, buildingSmokeOrigin, buildingDimensions } from "./assets/buildings.ts"
+import { makeMarker, makeUpgradeMarker } from "./assets/construction.ts"
+import { makeRuin } from "./assets/town-props.ts"
import { StructureEffects } from "./structure-effects.ts"
import { SmokePlume } from "./smoke-effects.ts"
import { surfaceState, type SurfaceState } from "./surface-state.ts"
-import { makePerson, serviceCostume, type ServiceRole } from "../asset-lab/people.ts"
-import { makeTree, makeRock, makeField, hash } from "../asset-lab/land.ts"
+import { makePerson, serviceCostume, type ServiceRole } from "./assets/people.ts"
+import { makeTree, makeRock, makeField, hash } from "./assets/land.ts"
import { ModelHandle } from "./pool.ts"
import { buildingAsset, buildingHeight, buildingTop, homeAsset, homeKey, doorKey, noDoors, quantizeBuild, plateAsset, scaffoldAsset, treeVariant } from "./models.ts"
import type { GameScene, SceneNode } from "./scene.ts"
diff --git a/src/server/handler.ts b/src/server/handler.ts
index 642b329..8dd1151 100644
--- a/src/server/handler.ts
+++ b/src/server/handler.ts
@@ -15,7 +15,7 @@
* code runs on Cloudflare (an R2 bucket and the site's assets), under the
* dev server, and in tests (both in memory).
*/
-import { checkMeta, isGzip, newId, ID_PATTERN, PICTURE_LIMIT, pictureType, picturePath, sharePath, TOWN_LIMIT, type ShareMeta } from "../share/format.ts"
+import { checkMeta, isGzip, newId, ID_PATTERN, PICTURE_LIMIT, pictureType, picturePath, sharePath, TOWN_LIMIT, type ShareMeta } from "../platform/share/format.ts"
/** What the handler needs of an R2 bucket. */
export interface Bucket {
diff --git a/src/host.ts b/src/ui/dom/host.ts
similarity index 99%
rename from src/host.ts
rename to src/ui/dom/host.ts
index 542d492..7762c3f 100644
--- a/src/host.ts
+++ b/src/ui/dom/host.ts
@@ -47,20 +47,20 @@ import {
type ParkPiece,
type PropId,
type Tier
-} from "./content.ts"
-import { GRID } from "./iso.ts"
-import { goodIcon, icon, iconEl, type IconName } from "./icons.ts"
-import { generate } from "./mapgen.ts"
-import { askOf, priceOf } from "./sim/index.ts"
-import type { Group, Line, Panel, Stats, Tool, TradeMode, UiValue, View } from "./ui.ts"
-import { emptyPreview } from "./ui.ts"
-import { GameScene, type CameraView } from "./render3d/scene.ts"
-import { blobOf, cardFacts, drawCard, metaOf, scaled, verdictOf } from "./share/card.ts"
-import { handheld, offerLink, offerPicture, upload } from "./share/client.ts"
-import { PICTURE_HEIGHT, PICTURE_QUALITY, PICTURE_WIDTH } from "./share/format.ts"
-import { MapInput } from "./render3d/input.ts"
-import { portrait } from "./render3d/portrait.ts"
-import { pictureAsset } from "./render3d/models.ts"
+} from "../../game/content/index.ts"
+import { GRID } from "../../game/world/iso.ts"
+import { goodIcon, icon, iconEl, type IconName } from "./kit/icons.ts"
+import { generate } from "../../game/world/mapgen.ts"
+import { askOf, priceOf } from "../../game/schedule.ts"
+import type { Group, Line, Panel, Stats, Tool, TradeMode, UiValue, View } from "../../view/contracts.ts"
+import { emptyPreview } from "../../view/contracts.ts"
+import { GameScene, type CameraView } from "../../render/three/scene.ts"
+import { blobOf, cardFacts, drawCard, metaOf, scaled, verdictOf } from "../../platform/share/card.ts"
+import { handheld, offerLink, offerPicture, upload } from "../../platform/share/client.ts"
+import { PICTURE_HEIGHT, PICTURE_QUALITY, PICTURE_WIDTH } from "../../platform/share/format.ts"
+import { MapInput } from "../../render/three/input.ts"
+import { portrait } from "../../render/three/portrait.ts"
+import { pictureAsset } from "../../render/three/models.ts"
const el = <K extends keyof HTMLElementTagNameMap>(tag: K, className: string, text = "") => {
const node = document.createElement(tag)
diff --git a/src/icons.ts b/src/ui/dom/kit/icons.ts
similarity index 99%
rename from src/icons.ts
rename to src/ui/dom/kit/icons.ts
index 4450a72..554840b 100644
--- a/src/icons.ts
+++ b/src/ui/dom/kit/icons.ts
@@ -3,7 +3,7 @@
* the town's numbers, the tools. Each is a 16 × 16 SVG drawn with the same
* two line weights as the town, so they sit beside it as part of one drawing.
*/
-import { goods, type GoodId } from "./content.ts"
+import { goods, type GoodId } from "../../../game/content/index.ts"
const ink = "#3d4943"
const hex = (color: number) => `#${color.toString(16).padStart(6, "0")}`
diff --git a/src/factory.css b/src/ui/dom/styles/factory.css
similarity index 100%
rename from src/factory.css
rename to src/ui/dom/styles/factory.css
diff --git a/src/phone.css b/src/ui/dom/styles/phone.css
similarity index 100%
rename from src/phone.css
rename to src/ui/dom/styles/phone.css
diff --git a/src/ui.ts b/src/view/contracts.ts
similarity index 98%
rename from src/ui.ts
rename to src/view/contracts.ts
index 8c360ea..26a8e13 100644
--- a/src/ui.ts
+++ b/src/view/contracts.ts
@@ -4,11 +4,11 @@
* preview, and edits; the simulation applies the edits on its next step.
* None of it is saved: it is host state, handed to systems as a service.
*/
-import type { Amounts, CharterValue, GoodId, GroundId, KindId, PropId, Tier, WinterId } from "./content.ts"
-import type { IconName } from "./icons.ts"
-import type { Point } from "./iso.ts"
-import type { Status } from "./schema.ts"
-import type { OverlayCell } from "./render3d/models.ts"
+import type { Amounts, CharterValue, GoodId, GroundId, KindId, PropId, Tier, WinterId } from "../game/content/index.ts"
+import type { IconName } from "../ui/dom/kit/icons.ts"
+import type { Point } from "../game/world/iso.ts"
+import type { Status } from "../game/schema.ts"
+import type { OverlayCell } from "../render/three/models.ts"
/** How a line of a panel reads: fine, worth a look, wrong, or an aside. */
export type Tone = "ok" | "warn" | "bad" | "dim"
diff --git a/src/present.ts b/src/view/present.ts
similarity index 99%
rename from src/present.ts
rename to src/view/present.ts
index ebc28e4..5c106c9 100644
--- a/src/present.ts
+++ b/src/view/present.ts
@@ -5,18 +5,18 @@
* and the views follow the world.
*/
import { RenderSync } from "@typeonce/ritmo-render"
-import { hazardStrength } from "./render3d/surface-state.ts"
+import { hazardStrength } from "../render/three/surface-state.ts"
-import { appealAt, appealParts, buildingSource, homeSource, landSource, parkSources, parksOf, type AppealSource, type ParkCell, type ParkValue } from "./appeal.ts"
-import { homeHeight, topOf, type Alert, type Load, type Emphasis } from "./art.ts"
-import { BuildingView, HouseView, WalkerView, TreeView, RockView, FieldView, RuinView } from "./render3d/views.ts"
-import type { DoorSet, OverlayCell } from "./render3d/models.ts"
+import { appealAt, appealParts, buildingSource, homeSource, landSource, parkSources, parksOf, type AppealSource, type ParkCell, type ParkValue } from "../game/world/appeal.ts"
+import { homeHeight, topOf, type Alert, type Load, type Emphasis } from "../render/art.ts"
+import { BuildingView, HouseView, WalkerView, TreeView, RockView, FieldView, RuinView } from "../render/three/views.ts"
+import type { DoorSet, OverlayCell } from "../render/three/models.ts"
import {
amounts, BUILD_TICKS, builtCost, COMMUTE, provisions, RESTOCK_TICKS, step, condition as wear, CONDITION_MAX, costText, crewOf, crown as crownRules, fate, goodIds, goods, grounds, home, kinds, needTitle,
kindOrder, nextUpgrade, worksNeeded, PAVE_COST, propIds, props, ranks, risk, RISK_MAX, ROAD_COST, tierHome, total, upgradeAt, upkeepOf, winters, type Amounts, type GoodId, type Kind, type KindId, type Need, type Tier
-} from "./content.ts"
-import { around, canPlace, cellOf, doors, entrances, isRoad, key, lPath, nearest, reach, useAt, type TileLike } from "./grid.ts"
-import { GRID, inside, U, type Point } from "./iso.ts"
+} from "../game/content/index.ts"
+import { around, canPlace, cellOf, doors, entrances, isRoad, key, lPath, nearest, reach, useAt, type TileLike } from "../game/world/grid.ts"
+import { GRID, inside, U, type Point } from "../game/world/iso.ts"
import {
Appeal,
Building,
@@ -85,18 +85,18 @@ import {
Water,
type GridValue,
type Status as StatusValue
-} from "./schema.ts"
-import { capacity, CELL_STEPS, elapsed, goalsOf, larder, lockReason, met, seasonAt, SITE_SHARE, steadyNet, taxOf, termTicks, upgradeBlock, winterOf } from "./sim/index.ts"
-import { Townsfolk } from "./townsfolk.ts"
-import { emptyPreview, type Alert as Notice, type Group, type HitBox, type Legend, type Line, type View } from "./ui.ts"
-import { blockers as blockersOf, causeOf, servicesCause, streetAdvice, streetShort, type Cause, type Fix, type InTown, type Served, type Street } from "./rules/explain.ts"
-import { upgradeChanges, upgradePrice } from "./rules/upgrades.ts"
-import { breadBonus, moreAdmin, shortOf, streetTax, suppliedTaxOf, taxOutlook, type TaxedHome } from "./rules/households.ts"
-import { approvalTarget } from "./rules/approval.ts"
-import { salvageOf, salvageText, withWorks } from "./rules/salvage.ts"
-import { rockBlocks, type RockPart } from "./render3d/rock-blocks.ts"
-import { courseCount, GUIDE_QUIET, guideDone, guideStep, guideSteps, lockedNote, upcoming, type GuideFacts, type GuideFocus } from "./rules/guide.ts"
-import { anA, TAX_STEPS, stepsOf } from "./content.ts"
+} from "../game/schema.ts"
+import { capacity, CELL_STEPS, elapsed, goalsOf, larder, lockReason, met, seasonAt, SITE_SHARE, steadyNet, taxOf, termTicks, upgradeBlock, winterOf } from "../game/schedule.ts"
+import { Townsfolk } from "../render/three/townsfolk.ts"
+import { emptyPreview, type Alert as Notice, type Group, type HitBox, type Legend, type Line, type View } from "./contracts.ts"
+import { blockers as blockersOf, causeOf, servicesCause, streetAdvice, streetShort, type Cause, type Fix, type InTown, type Served, type Street } from "../game/rules/explain.ts"
+import { upgradeChanges, upgradePrice } from "../game/rules/upgrades.ts"
+import { breadBonus, moreAdmin, shortOf, streetTax, suppliedTaxOf, taxOutlook, type TaxedHome } from "../game/rules/households.ts"
+import { approvalTarget } from "../game/rules/approval.ts"
+import { salvageOf, salvageText, withWorks } from "../game/rules/salvage.ts"
+import { rockBlocks, type RockPart } from "../render/three/rock-blocks.ts"
+import { courseCount, GUIDE_QUIET, guideDone, guideStep, guideSteps, lockedNote, upcoming, type GuideFacts, type GuideFocus } from "../game/rules/guide.ts"
+import { anA, TAX_STEPS, stepsOf } from "../game/content/index.ts"
const cellAt = (at: Point): Point => {
return { x: Math.floor(at.x), y: Math.floor(at.y) }
diff --git a/test/balance-model.test.ts b/test/balance-model.test.ts
index 5b7f397..b4722aa 100644
--- a/test/balance-model.test.ts
+++ b/test/balance-model.test.ts
@@ -1,8 +1,8 @@
import assert from "node:assert/strict"
import { test } from "node:test"
import { readFileSync, readdirSync } from "node:fs"
-import { amounts, goodIds, kinds } from "../src/content.ts"
-import { resolveRules } from "../src/rules/config.ts"
+import { amounts, goodIds, kinds } from "../src/game/content/index.ts"
+import { resolveRules } from "../src/game/rules/config.ts"
import { analyze } from "../tools/balance/model/analyze.ts"
import { project } from "../tools/balance/model/project.ts"
import { searchParameters, searchDistricts } from "../tools/balance/model/search.ts"
@@ -13,13 +13,13 @@ import { verifyBuilds } from "../tools/balance/verify/builds.ts"
import { provenance } from "../tools/balance/provenance.ts"
import { assessTransfers } from "../tools/balance/model/transport.ts"
import { fixture } from "../tools/balance/verify/fixture.ts"
-import { capacity, moreAdmin, serveGoods, taxOf, taxOutlook, taxRoom, wantsCitizenGoods } from "../src/rules/households.ts"
-import { approvalTarget } from "../src/rules/approval.ts"
-import { tradeCollection } from "../src/rules/trade.ts"
-import { assignWorkers } from "../src/rules/production.ts"
-import { planPatrols } from "../src/rules/patrol.ts"
+import { capacity, moreAdmin, serveGoods, taxOf, taxOutlook, taxRoom, wantsCitizenGoods } from "../src/game/rules/households.ts"
+import { approvalTarget } from "../src/game/rules/approval.ts"
+import { tradeCollection } from "../src/game/rules/trade.ts"
+import { assignWorkers } from "../src/game/rules/production.ts"
+import { planPatrols } from "../src/game/rules/patrol.ts"
import { scenarioGrid } from "../tools/balance/scenario.ts"
-import { GRID } from "../src/iso.ts"
+import { GRID } from "../src/game/world/iso.ts"
test("candidate rules are immutable, isolated and also executed by the game", () => {
const base = resolveRules(), original = kinds.weaver.recipe!.seconds
@@ -37,10 +37,10 @@ test("candidate rules are immutable, isolated and also executed by the game", ()
test("the mathematical layer has no runtime or rendering value imports", () => {
const paths = [...readdirSync("tools/balance/model").filter((f) => f.endsWith(".ts")).map((f) => `tools/balance/model/${f}`),
- ...readdirSync("src/rules").filter((f) => f.endsWith(".ts")).map((f) => `src/rules/${f}`), "tools/balance/scenario.ts"]
+ ...readdirSync("src/game/rules").filter((f) => f.endsWith(".ts")).map((f) => `src/game/rules/${f}`), "tools/balance/scenario.ts"]
for (const path of paths) {
const text = readFileSync(path, "utf8").replace(/^import type [\s\S]*?from [^\n]+\n/gm, "")
- assert(!/import[^\n]*from ["'][^"']*(?:sim\/|schema\.ts|render3d|bevy-ts)[^"']*["']/.test(text), path)
+ assert(!/import[^\n]*from ["'][^"']*(?:systems\/|schema\.ts|render\/|bevy-ts)[^"']*["']/.test(text), path)
}
})
diff --git a/test/balance-victory.test.ts b/test/balance-victory.test.ts
index 2a6d6f9..81ee305 100644
--- a/test/balance-victory.test.ts
+++ b/test/balance-victory.test.ts
@@ -4,8 +4,8 @@ import { mkdtempSync, readFileSync, rmSync } from "node:fs"
import { tmpdir } from "node:os"
import { join } from "node:path"
import { spawnSync } from "node:child_process"
-import { resolveRules } from "../src/rules/config.ts"
-import { TOWN_RANK } from "../src/content.ts"
+import { resolveRules } from "../src/game/rules/config.ts"
+import { TOWN_RANK } from "../src/game/content/index.ts"
import { fingerprint } from "../tools/balance/provenance.ts"
/** The sensible mayor's 60-minute term on a generated charter, played once and shared by the tests below. */
diff --git a/test/clock-migration.test.ts b/test/clock-migration.test.ts
index e131459..977b829 100644
--- a/test/clock-migration.test.ts
+++ b/test/clock-migration.test.ts
@@ -3,9 +3,9 @@ import { test } from "node:test"
import { Effect } from "effect"
import { HostClock } from "@typeonce/ritmo"
import { Determinism } from "@typeonce/ritmo-devtools"
-import { load, memoryStorage, SAVE_FORMAT, SAVE_VERSION, Storage, World } from "../src/save.ts"
-import { headless } from "../src/sim/headless.ts"
-import { simulate } from "../src/sim/index.ts"
+import { load, memoryStorage, SAVE_FORMAT, SAVE_VERSION, Storage, World } from "../src/platform/save.ts"
+import { headless } from "../src/game/headless.ts"
+import { simulate } from "../src/game/schedule.ts"
test("version 9 saves retain the exact 60 Hz step count and load as snapshot format 2", () => {
const town = headless({ size: "small", term: 45, land: "fair", seed: 7 })
diff --git a/test/economy.test.ts b/test/economy.test.ts
index 010bfb1..d50bf71 100644
--- a/test/economy.test.ts
+++ b/test/economy.test.ts
@@ -2,7 +2,7 @@
* The economy's rules that must hold however the numbers are tuned: no
* piece a mayor can lay down gives back far more than its kind usually
* does for what it costs, and nothing comes for free. The figures come
- * from `src/rules/worth.ts`; the bands are the design's, so a change to
+ * from `src/game/rules/worth.ts`; the bands are the design's, so a change to
* one number that opens a hole a player could play over and over fails
* here.
*
@@ -13,11 +13,11 @@
*/
import assert from "node:assert/strict"
import { test } from "node:test"
-import { amounts, type GoodId, type GroundId, type KindId, type Need, type PropId } from "../src/content.ts"
-import { appealGrid, parkSources, parksOf, type ParkCell } from "../src/appeal.ts"
-import { shippedRules } from "../src/rules/config.ts"
-import { moreAdmin, tierFor } from "../src/rules/households.ts"
-import { chainWorth, crownMargin, dominates, homes, median, openingKit, producers, producerWorth, services, upgradeWorths } from "../src/rules/worth.ts"
+import { amounts, type GoodId, type GroundId, type KindId, type Need, type PropId } from "../src/game/content/index.ts"
+import { appealGrid, parkSources, parksOf, type ParkCell } from "../src/game/world/appeal.ts"
+import { shippedRules } from "../src/game/rules/config.ts"
+import { moreAdmin, tierFor } from "../src/game/rules/households.ts"
+import { chainWorth, crownMargin, dominates, homes, median, openingKit, producers, producerWorth, services, upgradeWorths } from "../src/game/rules/worth.ts"
import { district } from "../tools/balance/scenario.ts"
import { component, fixture } from "../tools/balance/verify/fixture.ts"
diff --git a/test/endless.test.ts b/test/endless.test.ts
index b5b0d18..fc9e81c 100644
--- a/test/endless.test.ts
+++ b/test/endless.test.ts
@@ -7,10 +7,10 @@
import assert from "node:assert/strict"
import { test } from "node:test"
-import { amounts, FACE_TICKS, goodIds, kinds, ranks, stepsOf, YEARS_PER_TERM } from "../src/content.ts"
-import { canPlace, GridBuilder } from "../src/grid.ts"
-import { goalsOf, nextRank, scoreOf } from "../src/rules/goals.ts"
-import { headless, type Snapshot } from "../src/sim/headless.ts"
+import { amounts, FACE_TICKS, goodIds, kinds, ranks, stepsOf, YEARS_PER_TERM } from "../src/game/content/index.ts"
+import { canPlace, GridBuilder } from "../src/game/world/grid.ts"
+import { goalsOf, nextRank, scoreOf } from "../src/game/rules/goals.ts"
+import { headless, type Snapshot } from "../src/game/headless.ts"
const charter = { size: "small", term: 45, land: "fair", seed: 11 } as const
diff --git a/test/furniture.test.ts b/test/furniture.test.ts
index 0936097..36da91f 100644
--- a/test/furniture.test.ts
+++ b/test/furniture.test.ts
@@ -6,8 +6,8 @@
import assert from "node:assert/strict"
import { test } from "node:test"
-import { resolveRules } from "../src/rules/config.ts"
-import { headless, type Snapshot } from "../src/sim/headless.ts"
+import { resolveRules } from "../src/game/rules/config.ts"
+import { headless, type Snapshot } from "../src/game/headless.ts"
const FOREVER = 1e9
const hallOf = (s: Snapshot) => s.entities.find((e) => e.components["Town/TownHall"])!
diff --git a/test/guide.test.ts b/test/guide.test.ts
index decc9cf..fd5503f 100644
--- a/test/guide.test.ts
+++ b/test/guide.test.ts
@@ -1,5 +1,5 @@
/**
- * The mayor's guide (`src/rules/guide.ts`): it teaches a course in order,
+ * The mayor's guide (`src/game/rules/guide.ts`): it teaches a course in order,
* chapter by chapter, and never falls silent before the town is complete;
* signs from the town go ahead of the course once it is founded; it puts
* away what the town has already done (shown or not); it says what opens a
@@ -9,8 +9,8 @@
import assert from "node:assert/strict"
import { test } from "node:test"
-import { amounts, kinds, type KindId } from "../src/content.ts"
-import { courseCount, courseSteps, guideDone, guideStep, guideSteps, lockedNote, PLANKS_LOW, STONE_LOW, upcoming, type GuideFacts } from "../src/rules/guide.ts"
+import { amounts, kinds, type KindId } from "../src/game/content/index.ts"
+import { courseCount, courseSteps, guideDone, guideStep, guideSteps, lockedNote, PLANKS_LOW, STONE_LOW, upcoming, type GuideFacts } from "../src/game/rules/guide.ts"
const fresh: GuideFacts = {
homes: 0,
diff --git a/test/homes-edit.test.ts b/test/homes-edit.test.ts
index 3486b90..e3f82c1 100644
--- a/test/homes-edit.test.ts
+++ b/test/homes-edit.test.ts
@@ -7,8 +7,8 @@
import assert from "node:assert/strict"
import { test } from "node:test"
-import { step } from "../src/content.ts"
-import { headless } from "../src/sim/headless.ts"
+import { step } from "../src/game/content/index.ts"
+import { headless } from "../src/game/headless.ts"
test("a homes edit along a fresh road raises every cottage in one step, empty", () => {
const town = headless({ size: "small", term: 45, land: "fair", seed: 7 })
diff --git a/test/ink-assets.test.ts b/test/ink-assets.test.ts
index 5c7c867..5426a35 100644
--- a/test/ink-assets.test.ts
+++ b/test/ink-assets.test.ts
@@ -1,11 +1,11 @@
import assert from "node:assert/strict"
import { test } from "node:test"
-import { inkAssets, assetById } from "../src/asset-lab/assets.ts"
-import { kindIds, goodIds, kinds } from "../src/content.ts"
-import { testMap } from "../src/map-lab/map.ts"
-import { U } from "../src/iso.ts"
-import { makeRock } from "../src/asset-lab/land.ts"
-import { church, marketHall, quartersFor } from "../src/asset-lab/service-upgrades.ts"
+import { inkAssets, assetById } from "../src/render/three/assets/assets.ts"
+import { kindIds, goodIds, kinds } from "../src/game/content/index.ts"
+import { testMap } from "../src/labs/map-lab/map.ts"
+import { U } from "../src/game/world/iso.ts"
+import { makeRock } from "../src/render/three/assets/land.ts"
+import { church, marketHall, quartersFor } from "../src/render/three/assets/service-upgrades.ts"
test("the portable catalogue covers all world object families", () => {
assert.equal(assetById.size, inkAssets.length, "Asset IDs must be unique")
diff --git a/test/legibility.test.ts b/test/legibility.test.ts
index 0206c91..c0330a7 100644
--- a/test/legibility.test.ts
+++ b/test/legibility.test.ts
@@ -10,14 +10,14 @@
import assert from "node:assert/strict"
import { test } from "node:test"
-import { COMMUTE, home, kinds, type CharterValue } from "../src/content.ts"
-import { appealAt } from "../src/appeal.ts"
-import { canPlace, GridBuilder, type Use } from "../src/grid.ts"
-import type { Snapshot } from "../src/sim/headless.ts"
-import { blockers, streetShort, whyUnmet, type InTown, type Served, type Street } from "../src/rules/explain.ts"
-import { capacity, streetRoom, streetTax, taxOf } from "../src/rules/households.ts"
-import { approvalTarget, grudgeAfter } from "../src/rules/approval.ts"
-import { headless } from "../src/sim/headless.ts"
+import { COMMUTE, home, kinds, type CharterValue } from "../src/game/content/index.ts"
+import { appealAt } from "../src/game/world/appeal.ts"
+import { canPlace, GridBuilder, type Use } from "../src/game/world/grid.ts"
+import type { Snapshot } from "../src/game/headless.ts"
+import { blockers, streetShort, whyUnmet, type InTown, type Served, type Street } from "../src/game/rules/explain.ts"
+import { capacity, streetRoom, streetTax, taxOf } from "../src/game/rules/households.ts"
+import { approvalTarget, grudgeAfter } from "../src/game/rules/approval.ts"
+import { headless } from "../src/game/headless.ts"
const settlers = { tier: 1 as const, residents: 4, food: 100, bread: 100, cloth: 0, faith: 100, furniture: 0, clock: 0 }
const plenty: InTown = { fish: 20, smoked: 0, bread: 30, cloth: 188, furniture: 0 }
diff --git a/test/model.test.ts b/test/model.test.ts
index c2de1b2..0c61c6c 100644
--- a/test/model.test.ts
+++ b/test/model.test.ts
@@ -16,12 +16,12 @@ import { Arbitrary, Data, Effect, Schema } from "effect"
import {
CONDITION_MAX, crown, goodIds, groundIds, home, kindOrder, kinds, landIds, market, propIds, ranks, RESERVE_MAX, RISK_MAX, TAX_STEPS, TRADE_LOAD, type CharterValue
-} from "../src/content.ts"
-import { canPlace, cellsOf, DIRS, entrances, GridBuilder, isRoad, key, type Use } from "../src/grid.ts"
-import { GRID, inside, type Point } from "../src/iso.ts"
-import { load, memoryStorage, save, Storage, World } from "../src/save.ts"
-import { headless, type Headless, type Snapshot } from "../src/sim/headless.ts"
-import type { Edit } from "../src/ui.ts"
+} from "../src/game/content/index.ts"
+import { canPlace, cellsOf, DIRS, entrances, GridBuilder, isRoad, key, type Use } from "../src/game/world/grid.ts"
+import { GRID, inside, type Point } from "../src/game/world/iso.ts"
+import { load, memoryStorage, save, Storage, World } from "../src/platform/save.ts"
+import { headless, type Headless, type Snapshot } from "../src/game/headless.ts"
+import type { Edit } from "../src/view/contracts.ts"
const RUNS = Number(process.env.RUNS ?? 25)
/** How large generated scenarios grow: at this size, sequences run to their full length. */
diff --git a/test/park-models.test.ts b/test/park-models.test.ts
index c18aeca..f1645ac 100644
--- a/test/park-models.test.ts
+++ b/test/park-models.test.ts
@@ -3,12 +3,12 @@ import { test } from "node:test"
import { readFileSync } from "node:fs"
import { gunzipSync } from "node:zlib"
import * as THREE from "three"
-import { assetById } from "../src/asset-lab/assets.ts"
-import { Drawing, type InkAsset } from "../src/asset-lab/primitives.ts"
-import { parkAsset, parkProp } from "../src/asset-lab/town-props.ts"
-import { parkReviewModels } from "../src/model-review/park-models.ts"
-import { human } from "../src/asset-lab/dimensions.ts"
-import { DIRS, key } from "../src/grid.ts"
+import { assetById } from "../src/render/three/assets/assets.ts"
+import { Drawing, type InkAsset } from "../src/render/three/assets/primitives.ts"
+import { parkAsset, parkProp } from "../src/render/three/assets/town-props.ts"
+import { parkReviewModels } from "../src/labs/model-review/park-models.ts"
+import { human } from "../src/render/three/assets/dimensions.ts"
+import { DIRS, key } from "../src/game/world/grid.ts"
import { assertNear } from "./near.ts"
const baseline=JSON.parse(gunzipSync(readFileSync(new URL("../public/model-review/parks-before.json.gz",import.meta.url))).toString()) as {revision:string;models:InkAsset[];walker:InkAsset}
diff --git a/test/pictures.test.ts b/test/pictures.test.ts
index daccf0c..e0b1d29 100644
--- a/test/pictures.test.ts
+++ b/test/pictures.test.ts
@@ -8,8 +8,8 @@ import assert from "node:assert/strict"
import { readFileSync } from "node:fs"
import { test } from "node:test"
-import { groundIds, kindIds, kinds, propIds } from "../src/content.ts"
-import { buildingAsset, homeAsset, noDoors, pictureAsset } from "../src/render3d/models.ts"
+import { groundIds, kindIds, kinds, propIds } from "../src/game/content/index.ts"
+import { buildingAsset, homeAsset, noDoors, pictureAsset } from "../src/render/three/models.ts"
test("every building's picture, at every level of upgrades, is the model the map draws", () => {
for (const id of kindIds) {
@@ -35,7 +35,7 @@ test("every piece of park is pictured as the map draws it, a furnishing standing
})
test("the page pictures nothing any other way", () => {
- const host = readFileSync(new URL("../src/host.ts", import.meta.url), "utf8")
+ const host = readFileSync(new URL("../src/ui/dom/host.ts", import.meta.url), "utf8")
assert.match(host, /pictureAsset\(/)
for (const other of ["drawParkPiece", "makeBuilding", "serviceBuilding", "dressedBuilding"]) assert.equal(host.includes(other), false, `host.ts pictures with ${other}`)
})
diff --git a/test/proportions.test.ts b/test/proportions.test.ts
index ca97d2e..f451e9a 100644
--- a/test/proportions.test.ts
+++ b/test/proportions.test.ts
@@ -2,14 +2,14 @@ import assert from "node:assert/strict"
import { test } from "node:test"
import { readFileSync } from "node:fs"
import { gunzipSync } from "node:zlib"
-import { home, kindIds } from "../src/content.ts"
-import { assetById } from "../src/asset-lab/assets.ts"
-import { house } from "../src/asset-lab/homes.ts"
-import { human, residentialHeight } from "../src/asset-lab/dimensions.ts"
-import { sides, type InkAsset } from "../src/asset-lab/primitives.ts"
-import { buildingAsset, buildingTop, noDoors } from "../src/render3d/models.ts"
-import { architectureIds, proportionModels } from "../src/model-review/proportion-models.ts"
-import { vertex3 } from "../src/asset-lab/renderer.ts"
+import { home, kindIds } from "../src/game/content/index.ts"
+import { assetById } from "../src/render/three/assets/assets.ts"
+import { house } from "../src/render/three/assets/homes.ts"
+import { human, residentialHeight } from "../src/render/three/assets/dimensions.ts"
+import { sides, type InkAsset } from "../src/render/three/assets/primitives.ts"
+import { buildingAsset, buildingTop, noDoors } from "../src/render/three/models.ts"
+import { architectureIds, proportionModels } from "../src/labs/model-review/proportion-models.ts"
+import { vertex3 } from "../src/render/three/assets/renderer.ts"
import { assertNear } from "./near.ts"
const baseline=JSON.parse(gunzipSync(readFileSync(new URL("../public/model-review/proportions-before.json.gz",import.meta.url))).toString()) as {revision:string;models:InkAsset[];walker:InkAsset}
diff --git a/test/render3d.test.ts b/test/render3d.test.ts
index fccd0d3..bbe0d51 100644
--- a/test/render3d.test.ts
+++ b/test/render3d.test.ts
@@ -1,17 +1,17 @@
import assert from "node:assert/strict"
import { test } from "node:test"
import * as THREE from "three"
-import { kindIds, kinds } from "../src/content.ts"
-import { U } from "../src/iso.ts"
-import { dressed } from "../src/asset-lab/upgrade-dress.ts"
-import { Drawing, type InkAsset } from "../src/asset-lab/primitives.ts"
-import { buildingAsset, buildingHeight, buildingTop, homeAsset, noDoors, scaffoldAsset, treeVariant } from "../src/render3d/models.ts"
-import { upgradeHeights } from "../src/asset-lab/service-upgrades.ts"
-import { ModelHandle, ModelPool } from "../src/render3d/pool.ts"
-import { assetById } from "../src/asset-lab/assets.ts"
-import { surfaceState, hazardStrength } from "../src/render3d/surface-state.ts"
-import { StructureEffects } from "../src/render3d/structure-effects.ts"
-import { vertex3 } from "../src/asset-lab/renderer.ts"
+import { kindIds, kinds } from "../src/game/content/index.ts"
+import { U } from "../src/game/world/iso.ts"
+import { dressed } from "../src/render/three/assets/upgrade-dress.ts"
+import { Drawing, type InkAsset } from "../src/render/three/assets/primitives.ts"
+import { buildingAsset, buildingHeight, buildingTop, homeAsset, noDoors, scaffoldAsset, treeVariant } from "../src/render/three/models.ts"
+import { upgradeHeights } from "../src/render/three/assets/service-upgrades.ts"
+import { ModelHandle, ModelPool } from "../src/render/three/pool.ts"
+import { assetById } from "../src/render/three/assets/assets.ts"
+import { surfaceState, hazardStrength } from "../src/render/three/surface-state.ts"
+import { StructureEffects } from "../src/render/three/structure-effects.ts"
+import { vertex3 } from "../src/render/three/assets/renderer.ts"
function valid(asset: InkAsset) {
for (const face of asset.faces) {
diff --git a/test/rural.test.ts b/test/rural.test.ts
index d89d8b8..4ac579e 100644
--- a/test/rural.test.ts
+++ b/test/rural.test.ts
@@ -1,13 +1,13 @@
import assert from "node:assert/strict"
import { test } from "node:test"
import * as THREE from "three"
-import { makeBuilding, buildingDimensions } from "../src/asset-lab/buildings.ts"
-import { ruralDoorIds } from "../src/asset-lab/rural.ts"
-import { sides, type InkAsset } from "../src/asset-lab/primitives.ts"
-import { vertex3 } from "../src/asset-lab/renderer.ts"
-import { noDoors } from "../src/render3d/models.ts"
-import { kinds } from "../src/content.ts"
-import { U } from "../src/iso.ts"
+import { makeBuilding, buildingDimensions } from "../src/render/three/assets/buildings.ts"
+import { ruralDoorIds } from "../src/render/three/assets/rural.ts"
+import { sides, type InkAsset } from "../src/render/three/assets/primitives.ts"
+import { vertex3 } from "../src/render/three/assets/renderer.ts"
+import { noDoors } from "../src/render/three/models.ts"
+import { kinds } from "../src/game/content/index.ts"
+import { U } from "../src/game/world/iso.ts"
test("rural timber doors stay within their plots when opened on any road face", () => {
for (const id of ruralDoorIds) for (const side of sides) for (const open of [0, 0.5, 1]) {
diff --git a/test/same-step-edits.test.ts b/test/same-step-edits.test.ts
index 918d53b..6645b58 100644
--- a/test/same-step-edits.test.ts
+++ b/test/same-step-edits.test.ts
@@ -7,8 +7,8 @@
import assert from "node:assert/strict"
import { test } from "node:test"
-import { step, type CharterValue } from "../src/content.ts"
-import { headless } from "../src/sim/headless.ts"
+import { step, type CharterValue } from "../src/game/content/index.ts"
+import { headless } from "../src/game/headless.ts"
const charter: CharterValue = { size: "small", term: 45, land: "fair", seed: 7 }
const roads = Array.from({ length: 9 }, (_, i) => ({ x: 34 + i, y: 31 }))
diff --git a/test/save.test.ts b/test/save.test.ts
index 7268092..b373141 100644
--- a/test/save.test.ts
+++ b/test/save.test.ts
@@ -1,5 +1,5 @@
/**
- * Saving and loading (`src/save.ts`) against a real headless town and
+ * Saving and loading (`src/platform/save.ts`) against a real headless town and
* storage in a map: every way a load can go, and that a failed one leaves
* the town as it was.
*/
@@ -8,8 +8,8 @@ import { test } from "node:test"
import { Effect } from "effect"
-import { load, loadLatest, memoryStorage, read, save, SAVE_FORMAT, SAVE_VERSION, Storage, World, type LoadError } from "../src/save.ts"
-import { headless, type Headless } from "../src/sim/headless.ts"
+import { load, loadLatest, memoryStorage, read, save, SAVE_FORMAT, SAVE_VERSION, Storage, World, type LoadError } from "../src/platform/save.ts"
+import { headless, type Headless } from "../src/game/headless.ts"
const worldOf = (town: Headless): World["Service"] => ({
snapshot: () => town.snapshot(),
diff --git a/test/share.test.ts b/test/share.test.ts
index 8dddd4c..a547513 100644
--- a/test/share.test.ts
+++ b/test/share.test.ts
@@ -9,10 +9,10 @@ import { gunzipSync, gzipSync } from "node:zlib"
import { Effect } from "effect"
-import { fileOf, loadText, memoryStorage, Storage, World } from "../src/save.ts"
+import { fileOf, loadText, memoryStorage, Storage, World } from "../src/platform/save.ts"
import { DAILY_SHARES, handle, memoryBucket, type Env, type Limiter } from "../src/server/handler.ts"
-import { checkMeta, ID_PATTERN, newId, pictureType, TOWN_LIMIT } from "../src/share/format.ts"
-import { headless, type Headless } from "../src/sim/headless.ts"
+import { checkMeta, ID_PATTERN, newId, pictureType, TOWN_LIMIT } from "../src/platform/share/format.ts"
+import { headless, type Headless } from "../src/game/headless.ts"
const PAGE = `<!doctype html><html><head><title>Inkline Town</title></head><body><div id="app"></div></body></html>`
const ORIGIN = "https://inkline.test"
diff --git a/test/this-tick.test.ts b/test/this-tick.test.ts
index 0ad768c..70ee709 100644
--- a/test/this-tick.test.ts
+++ b/test/this-tick.test.ts
@@ -7,10 +7,10 @@
import assert from "node:assert/strict"
import { test } from "node:test"
-import { Game } from "../src/schema.ts"
-import { headless } from "../src/sim/headless.ts"
-import { Households } from "../src/sim/town.ts"
-import { IndexGrid } from "../src/sim/work.ts"
+import { Game } from "../src/game/schema.ts"
+import { headless } from "../src/game/headless.ts"
+import { Households } from "../src/game/systems/town/index.ts"
+import { IndexGrid } from "../src/game/systems/work/index.ts"
test("a Grid writer placed after Households fails to compile and tryTick rejects it", () => {
const town = headless({ size: "small", term: 45, land: "fair", seed: 7 })
diff --git a/test/trades.test.ts b/test/trades.test.ts
index ff66ff5..d642422 100644
--- a/test/trades.test.ts
+++ b/test/trades.test.ts
@@ -1,14 +1,14 @@
import assert from "node:assert/strict"
import { test } from "node:test"
import * as THREE from "three"
-import { makeBuilding, buildingSmokeOrigin } from "../src/asset-lab/buildings.ts"
-import { tradeYardIds } from "../src/asset-lab/trades.ts"
-import { workshopPoint } from "../src/asset-lab/workshops.ts"
-import { type InkAsset, sides } from "../src/asset-lab/primitives.ts"
-import { buildingAsset, noDoors } from "../src/render3d/models.ts"
-import { vertex3 } from "../src/asset-lab/renderer.ts"
-import { kinds } from "../src/content.ts"
-import { U } from "../src/iso.ts"
+import { makeBuilding, buildingSmokeOrigin } from "../src/render/three/assets/buildings.ts"
+import { tradeYardIds } from "../src/render/three/assets/trades.ts"
+import { workshopPoint } from "../src/render/three/assets/workshops.ts"
+import { type InkAsset, sides } from "../src/render/three/assets/primitives.ts"
+import { buildingAsset, noDoors } from "../src/render/three/models.ts"
+import { vertex3 } from "../src/render/three/assets/renderer.ts"
+import { kinds } from "../src/game/content/index.ts"
+import { U } from "../src/game/world/iso.ts"
function hits(asset: InkAsset, start: THREE.Vector3, end: THREE.Vector3) {
const ray = new THREE.Ray(start, end.clone().sub(start).normalize())
diff --git a/test/workshops.test.ts b/test/workshops.test.ts
index e8df28a..3a6a507 100644
--- a/test/workshops.test.ts
+++ b/test/workshops.test.ts
@@ -1,12 +1,12 @@
import assert from "node:assert/strict"
import { test } from "node:test"
import * as THREE from "three"
-import { makeBuilding, buildingSmokeOrigin, buildingDimensions } from "../src/asset-lab/buildings.ts"
-import { workshopIds, workshopPoint } from "../src/asset-lab/workshops.ts"
-import { vertex3 } from "../src/asset-lab/renderer.ts"
-import { buildingAsset, noDoors } from "../src/render3d/models.ts"
-import { sides } from "../src/asset-lab/primitives.ts"
-import { U } from "../src/iso.ts"
+import { makeBuilding, buildingSmokeOrigin, buildingDimensions } from "../src/render/three/assets/buildings.ts"
+import { workshopIds, workshopPoint } from "../src/render/three/assets/workshops.ts"
+import { vertex3 } from "../src/render/three/assets/renderer.ts"
+import { buildingAsset, noDoors } from "../src/render/three/models.ts"
+import { sides } from "../src/render/three/assets/primitives.ts"
+import { U } from "../src/game/world/iso.ts"
test("open workshop forecourts retain air above the work floor on every road heading", () => {
for (const id of workshopIds) for (const side of sides) {
diff --git a/tools/balance/catalog.ts b/tools/balance/catalog.ts
index 3145e3f..74302ab 100644
--- a/tools/balance/catalog.ts
+++ b/tools/balance/catalog.ts
@@ -1,5 +1,5 @@
-import { type KindId } from "../../src/content.ts"
-import type { Rules } from "../../src/rules/config.ts"
+import { type KindId } from "../../src/game/content/index.ts"
+import type { Rules } from "../../src/game/rules/config.ts"
import { district } from "./scenario.ts"
import type { BuildAction, Scenario } from "./types.ts"
diff --git a/tools/balance/cli.ts b/tools/balance/cli.ts
index a632c32..36e9c26 100644
--- a/tools/balance/cli.ts
+++ b/tools/balance/cli.ts
@@ -1,6 +1,6 @@
import { mkdirSync, readFileSync, writeFileSync } from "node:fs"
import { resolve } from "node:path"
-import { resolveRules, type RulePatch } from "../../src/rules/config.ts"
+import { resolveRules, type RulePatch } from "../../src/game/rules/config.ts"
import { analyze } from "./model/analyze.ts"
import { project } from "./model/project.ts"
import { searchDistricts, searchParameters } from "./model/search.ts"
diff --git a/tools/balance/index.ts b/tools/balance/index.ts
index 9a94a98..df01228 100644
--- a/tools/balance/index.ts
+++ b/tools/balance/index.ts
@@ -8,4 +8,4 @@ export { searchParameters, searchDistricts } from "./model/search.ts"
export { fromSnapshot, scenarioGrid, validateScenario, district } from "./scenario.ts"
export type { Scenario, Inputs, Finding, Confidence, BuildAction, ProjectionOptions } from "./types.ts"
-export { parkValue, parksOf, parkSources, parkUpkeep, type ParkCell } from "../../src/appeal.ts"
+export { parkValue, parksOf, parkSources, parkUpkeep, type ParkCell } from "../../src/game/world/appeal.ts"
diff --git a/tools/balance/model/analyze.ts b/tools/balance/model/analyze.ts
index e1f63a4..6d98df2 100644
--- a/tools/balance/model/analyze.ts
+++ b/tools/balance/model/analyze.ts
@@ -1,12 +1,12 @@
-import { amounts, goodIds, type GoodId, type WinterId } from "../../../src/content.ts"
-import { appealAt, appealGrid, buildingSource, homeSource, landSource, parkSources, parkUpkeep } from "../../../src/appeal.ts"
-import { doors, nearest, reach } from "../../../src/grid.ts"
-import { assignWorkers, type Assignment } from "../../../src/rules/production.ts"
-import { baseCollection, wantsCitizenGoods, mealRate, mealsOf, refreshLevel, taxOf, tierFor } from "../../../src/rules/households.ts"
-import { riskIncrements, near } from "../../../src/rules/risks.ts"
-import { seasonAt } from "../../../src/rules/seasons.ts"
-import { spoilExpectation } from "../../../src/rules/decay.ts"
-import { goalsOf } from "../../../src/rules/goals.ts"
+import { amounts, goodIds, type GoodId, type WinterId } from "../../../src/game/content/index.ts"
+import { appealAt, appealGrid, buildingSource, homeSource, landSource, parkSources, parkUpkeep } from "../../../src/game/world/appeal.ts"
+import { doors, nearest, reach } from "../../../src/game/world/grid.ts"
+import { assignWorkers, type Assignment } from "../../../src/game/rules/production.ts"
+import { baseCollection, wantsCitizenGoods, mealRate, mealsOf, refreshLevel, taxOf, tierFor } from "../../../src/game/rules/households.ts"
+import { riskIncrements, near } from "../../../src/game/rules/risks.ts"
+import { seasonAt } from "../../../src/game/rules/seasons.ts"
+import { spoilExpectation } from "../../../src/game/rules/decay.ts"
+import { goalsOf } from "../../../src/game/rules/goals.ts"
import { scenarioGrid, validateScenario } from "../scenario.ts"
import { recipeCapacity, sourceCeiling } from "./throughput.ts"
import { missProbability, serviceProfile } from "./services.ts"
diff --git a/tools/balance/model/project.ts b/tools/balance/model/project.ts
index 3bcd210..2316bbf 100644
--- a/tools/balance/model/project.ts
+++ b/tools/balance/model/project.ts
@@ -1,13 +1,13 @@
-import { amounts, goodIds, type Amounts } from "../../../src/content.ts"
-import { parkUpkeep } from "../../../src/appeal.ts"
-import { ruleTicks } from "../../../src/rules/config.ts"
-import { baseCollection, capacity, mealRate, rateOf, serveGoods, shortOf, taxOf, tierFor } from "../../../src/rules/households.ts"
-import { seasonAt } from "../../../src/rules/seasons.ts"
-import { spoilExpectation } from "../../../src/rules/decay.ts"
-import { tradeCollection } from "../../../src/rules/trade.ts"
-import { approvalTarget, nextApproval } from "../../../src/rules/approval.ts"
+import { amounts, goodIds, type Amounts } from "../../../src/game/content/index.ts"
+import { parkUpkeep } from "../../../src/game/world/appeal.ts"
+import { ruleTicks } from "../../../src/game/rules/config.ts"
+import { baseCollection, capacity, mealRate, rateOf, serveGoods, shortOf, taxOf, tierFor } from "../../../src/game/rules/households.ts"
+import { seasonAt } from "../../../src/game/rules/seasons.ts"
+import { spoilExpectation } from "../../../src/game/rules/decay.ts"
+import { tradeCollection } from "../../../src/game/rules/trade.ts"
+import { approvalTarget, nextApproval } from "../../../src/game/rules/approval.ts"
import { analyze } from "./analyze.ts"
-import { around, cellsOf, key, ownerAt } from "../../../src/grid.ts"
+import { around, cellsOf, key, ownerAt } from "../../../src/game/world/grid.ts"
import { scenarioGrid } from "../scenario.ts"
import type { Inputs, BuildingAction, ModelBuilding, ProjectionOptions, Scenario } from "../types.ts"
diff --git a/tools/balance/model/search.ts b/tools/balance/model/search.ts
index b932a4b..c216815 100644
--- a/tools/balance/model/search.ts
+++ b/tools/balance/model/search.ts
@@ -1,6 +1,6 @@
-import type { KindId } from "../../../src/content.ts"
-import { amounts } from "../../../src/content.ts"
-import { resolveRules, type RulePatch, type Rules } from "../../../src/rules/config.ts"
+import type { KindId } from "../../../src/game/content/index.ts"
+import { amounts } from "../../../src/game/content/index.ts"
+import { resolveRules, type RulePatch, type Rules } from "../../../src/game/rules/config.ts"
import { analyze } from "./analyze.ts"
import { district } from "../scenario.ts"
import type { Inputs } from "../types.ts"
diff --git a/tools/balance/model/services.ts b/tools/balance/model/services.ts
index b8cc508..d5c4b49 100644
--- a/tools/balance/model/services.ts
+++ b/tools/balance/model/services.ts
@@ -1,7 +1,7 @@
-import { doors, key, nearest, reach, type TileLike } from "../../../src/grid.ts"
-import { planPatrols, serviceDoors } from "../../../src/rules/patrol.ts"
-import type { Rules } from "../../../src/rules/config.ts"
-import type { Assignment } from "../../../src/rules/production.ts"
+import { doors, key, nearest, reach, type TileLike } from "../../../src/game/world/grid.ts"
+import { planPatrols, serviceDoors } from "../../../src/game/rules/patrol.ts"
+import type { Rules } from "../../../src/game/rules/config.ts"
+import type { Assignment } from "../../../src/game/rules/production.ts"
import { scenarioGrid } from "../scenario.ts"
import type { ModelBuilding, Scenario } from "../types.ts"
diff --git a/tools/balance/model/throughput.ts b/tools/balance/model/throughput.ts
index 8662ef6..953f6aa 100644
--- a/tools/balance/model/throughput.ts
+++ b/tools/balance/model/throughput.ts
@@ -1,8 +1,8 @@
-import type { Kind, WinterId } from "../../../src/content.ts"
-import { around, useAt, ownerAt, type GridBuilder } from "../../../src/grid.ts"
-import { ruleTicks, type Rules } from "../../../src/rules/config.ts"
-import { equipmentPace, effort, paced } from "../../../src/rules/production.ts"
-import type { Assignment } from "../../../src/rules/production.ts"
+import type { Kind, WinterId } from "../../../src/game/content/index.ts"
+import { around, useAt, ownerAt, type GridBuilder } from "../../../src/game/world/grid.ts"
+import { ruleTicks, type Rules } from "../../../src/game/rules/config.ts"
+import { equipmentPace, effort, paced } from "../../../src/game/rules/production.ts"
+import type { Assignment } from "../../../src/game/rules/production.ts"
import type { RecipeCapacity, Scenario, ModelBuilding } from "../types.ts"
/** Tiny periodic cadence calculation, not an ECS run. Products of average paces are insufficient. */
diff --git a/tools/balance/model/transport.ts b/tools/balance/model/transport.ts
index a4f87f9..fa142e4 100644
--- a/tools/balance/model/transport.ts
+++ b/tools/balance/model/transport.ts
@@ -1,6 +1,6 @@
-import type { GoodId } from "../../../src/content.ts"
-import { doors, nearest, reach } from "../../../src/grid.ts"
-import { preferDelivery } from "../../../src/rules/transport.ts"
+import type { GoodId } from "../../../src/game/content/index.ts"
+import { doors, nearest, reach } from "../../../src/game/world/grid.ts"
+import { preferDelivery } from "../../../src/game/rules/transport.ts"
import { scenarioGrid } from "../scenario.ts"
import type { Inputs } from "../types.ts"
diff --git a/tools/balance/provenance.ts b/tools/balance/provenance.ts
index 0a1f0d2..4d37279 100644
--- a/tools/balance/provenance.ts
+++ b/tools/balance/provenance.ts
@@ -1,16 +1,20 @@
import { execFileSync } from "node:child_process"
import { createHash } from "node:crypto"
import { readFileSync, readdirSync } from "node:fs"
-import { resolveRules, type Rules } from "../../src/rules/config.ts"
+import { join } from "node:path"
+import { resolveRules, type Rules } from "../../src/game/rules/config.ts"
import type { Scenario } from "./types.ts"
const stable = (value: unknown): unknown => Array.isArray(value) ? value.map(stable) : value !== null && typeof value === "object" ? Object.fromEntries(Object.entries(value).sort(([a], [b]) => a.localeCompare(b)).map(([k, v]) => [k, stable(v)])) : value
export const fingerprint = (value: unknown) => createHash("sha256").update(JSON.stringify(stable(value))).digest("hex")
+/** Every TypeScript file under `dir`, at any depth. */
+const sources = (dir: string): Array<string> => readdirSync(dir, { recursive: true, encoding: "utf8" }).filter((f) => f.endsWith(".ts")).map((f) => join(dir, f))
+
export const provenance = (rules: Rules, scenarios: ReadonlyArray<Scenario>) => {
- const paths = ["src/content.ts", "src/grid.ts", "src/appeal.ts", "tools/balance/catalog.ts", "tools/balance/scenario.ts", "tools/balance/types.ts", ...readdirSync("src/rules").filter((f) => f.endsWith(".ts")).map((f) => `src/rules/${f}`), ...readdirSync("src/sim").filter((f) => f.endsWith(".ts")).map((f) => `src/sim/${f}`), ...readdirSync("tools/balance/model").filter((f) => f.endsWith(".ts")).map((f) => `tools/balance/model/${f}`)].sort()
+ const paths = ["src/game/content/index.ts", "src/game/world/grid.ts", "src/game/world/appeal.ts", "tools/balance/catalog.ts", "tools/balance/scenario.ts", "tools/balance/types.ts", ...sources("src/game/rules"), ...sources("src/game/systems"), "src/game/schedule.ts", "src/game/headless.ts", ...readdirSync("tools/balance/model").filter((f) => f.endsWith(".ts")).map((f) => `tools/balance/model/${f}`)].sort()
return { modelVersion: 2, referencePr: "https://github.com/SandroMaglione/inkline-town/pull/3", referenceSha: execFileSync("git", ["rev-parse", "HEAD"], { encoding: "utf8" }).trim(), baselineReferenceSha: "9b7ce7336a18f917a10aa6e21ae32cb57af88643",
uncommittedSource: execFileSync("git", ["status", "--porcelain", "--", "src", "scripts", "tools/balance"], { encoding: "utf8" }).trim().length > 0,
- rulesSha256: fingerprint(rules), contentSha256: createHash("sha256").update(readFileSync("src/content.ts")).digest("hex"),
+ rulesSha256: fingerprint(rules), contentSha256: createHash("sha256").update(readFileSync("src/game/content/index.ts")).digest("hex"),
modelSourceSha256: fingerprint(paths.map((p) => [p, readFileSync(p, "utf8")])), scenarioSha256: scenarios.map((s) => ({ name: s.name, sha256: fingerprint(s) })),
parametersChanged: fingerprint(rules) !== fingerprint(resolveRules()) }
}
diff --git a/tools/balance/report.ts b/tools/balance/report.ts
index f485aef..bafe1f5 100644
--- a/tools/balance/report.ts
+++ b/tools/balance/report.ts
@@ -1,7 +1,7 @@
-import { amounts, type KindId } from "../../src/content.ts"
-import type { Rules } from "../../src/rules/config.ts"
-import { mealRate, refreshLevel } from "../../src/rules/households.ts"
-import { parkValue, parkUpkeep } from "../../src/appeal.ts"
+import { amounts, type KindId } from "../../src/game/content/index.ts"
+import type { Rules } from "../../src/game/rules/config.ts"
+import { mealRate, refreshLevel } from "../../src/game/rules/households.ts"
+import { parkValue, parkUpkeep } from "../../src/game/world/appeal.ts"
import { recipeCapacity } from "./model/throughput.ts"
import { analyze } from "./model/analyze.ts"
import { searchDistricts } from "./model/search.ts"
diff --git a/tools/balance/scenario.ts b/tools/balance/scenario.ts
index 2d701a0..6882a67 100644
--- a/tools/balance/scenario.ts
+++ b/tools/balance/scenario.ts
@@ -1,9 +1,9 @@
-import type { ParkCell } from "../../src/appeal.ts"
-import { amounts, goodIds, type KindId, type Tier } from "../../src/content.ts"
-import { GridBuilder, canPlace, doors, key, nearest, reach, type Use, type TileLike } from "../../src/grid.ts"
-import { GRID } from "../../src/iso.ts"
-import { shippedRules, type Rules } from "../../src/rules/config.ts"
-import type { Snapshot } from "../../src/sim/headless.ts"
+import type { ParkCell } from "../../src/game/world/appeal.ts"
+import { amounts, goodIds, type KindId, type Tier } from "../../src/game/content/index.ts"
+import { GridBuilder, canPlace, doors, key, nearest, reach, type Use, type TileLike } from "../../src/game/world/grid.ts"
+import { GRID } from "../../src/game/world/iso.ts"
+import { shippedRules, type Rules } from "../../src/game/rules/config.ts"
+import type { Snapshot } from "../../src/game/headless.ts"
import type { ModelBuilding, ModelHome, Scenario } from "./types.ts"
export const scenarioGrid = (s: Scenario, rules: Rules = shippedRules): GridBuilder => {
diff --git a/tools/balance/types.ts b/tools/balance/types.ts
index e1599eb..2e7a47a 100644
--- a/tools/balance/types.ts
+++ b/tools/balance/types.ts
@@ -1,9 +1,9 @@
-import type { Amounts, CharterValue, GroundId, PropId, KindId } from "../../src/content.ts"
-import type { ParkCell } from "../../src/appeal.ts"
-import type { TileLike } from "../../src/grid.ts"
-import type { Rules } from "../../src/rules/config.ts"
-import type { Needs, Rates } from "../../src/rules/households.ts"
-import type { TradePolicy } from "../../src/rules/trade.ts"
+import type { Amounts, CharterValue, GroundId, PropId, KindId } from "../../src/game/content/index.ts"
+import type { ParkCell } from "../../src/game/world/appeal.ts"
+import type { TileLike } from "../../src/game/world/grid.ts"
+import type { Rules } from "../../src/game/rules/config.ts"
+import type { Needs, Rates } from "../../src/game/rules/households.ts"
+import type { TradePolicy } from "../../src/game/rules/trade.ts"
export interface ModelHome extends Needs {
readonly id: number; readonly tile: TileLike; readonly residents: number; readonly clock: number
diff --git a/tools/balance/verify/checks.ts b/tools/balance/verify/checks.ts
index 5fd126e..f3a0cd2 100644
--- a/tools/balance/verify/checks.ts
+++ b/tools/balance/verify/checks.ts
@@ -1,6 +1,6 @@
import { citizenPark } from "../catalog.ts"
-import { amounts, type KindId } from "../../../src/content.ts"
-import { type Rules } from "../../../src/rules/config.ts"
+import { amounts, type KindId } from "../../../src/game/content/index.ts"
+import { type Rules } from "../../../src/game/rules/config.ts"
import { analyze } from "../model/analyze.ts"
import { recipeCapacity } from "../model/throughput.ts"
import { project } from "../model/project.ts"
diff --git a/tools/balance/verify/fixture.ts b/tools/balance/verify/fixture.ts
index 08f1e9c..2f22571 100644
--- a/tools/balance/verify/fixture.ts
+++ b/tools/balance/verify/fixture.ts
@@ -1,10 +1,10 @@
/** This is the only layer that imports the ECS runtime. Model inputs stay plain data. */
-import { goodIds } from "../../../src/content.ts"
-import { GRID } from "../../../src/iso.ts"
-import { ownerAt } from "../../../src/grid.ts"
-import { rolesOf, wearOf } from "../../../src/archetypes.ts"
-import { headless, type Headless, type Snapshot } from "../../../src/sim/headless.ts"
-import type { Rules } from "../../../src/rules/config.ts"
+import { goodIds } from "../../../src/game/content/index.ts"
+import { GRID } from "../../../src/game/world/iso.ts"
+import { ownerAt } from "../../../src/game/world/grid.ts"
+import { rolesOf, wearOf } from "../../../src/game/world/archetypes.ts"
+import { headless, type Headless, type Snapshot } from "../../../src/game/headless.ts"
+import type { Rules } from "../../../src/game/rules/config.ts"
import { scenarioGrid, validateScenario } from "../scenario.ts"
import type { BuildAction, Scenario } from "../types.ts"