Skip to content

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

Retune the numbers the ledger flagged

Claudee7c7f1cbce5d
diff --git a/docs/how-to-play.md b/docs/how-to-play.md
index d1ce64f..082381f 100644
--- a/docs/how-to-play.md
+++ b/docs/how-to-play.md
@@ -203,7 +203,7 @@ goals again. *Governing*: the ranks, up to a city (and, once the town rank opens
a market hall where homes lie beyond every walker). While a step's homes or building
are going up it says so (carriers bringing planks to the site), so you know
you did your part; when the town cannot build what a step asks for yet, it
-says what opens it (*the farm opens at 30 residents*), or that the treasury
+says what opens it (*the farm opens at 60 residents*), or that the treasury
must save up, and goes on to a building it can. It never asks for a
building before the town needs it, as upkeep starts the day it stands: the
lumberjack and sawmill wait until planks fall below 25, the quarry until
diff --git a/src/content.ts b/src/content.ts
index 1b8485e..0573714 100644
--- a/src/content.ts
+++ b/src/content.ts
@@ -25,7 +25,7 @@ export const goods: Readonly<Record<GoodId, { readonly title: string; readonly c
fish: { title: "fish", color: 0x2f8c87, price: 2 },
smoked: { title: "smoked fish", color: 0x9a5b3a, price: 4 },
wheat: { title: "wheat", color: 0xd6ae2e, price: 1 },
- flour: { title: "flour", color: 0xc9b48a, price: 2 },
+ flour: { title: "flour", color: 0xc9b48a, price: 3 },
bread: { title: "bread", color: 0xc4523f, price: 4 },
wool: { title: "wool", color: 0xa7ada4, price: 2 },
cloth: { title: "cloth", color: 0x8a58a8, price: 6 }
@@ -226,7 +226,7 @@ export const kinds: Readonly<Record<KindId, Kind>> = {
mine: {
id: "mine", title: "Mine", blurb: "digs ore from a deposit nearby",
category: "gathering", size: 2, half: 10, stories: 1, roof: "flat", bays: 2, window: 6, topper: "chimney",
- cost: { coins: 200, materials: { planks: 6, stone: 4 } }, upkeep: 10, workers: 4, crew: "settlers", unlock: { residents: 0, citizens: 10 }, buildable: true,
+ cost: { coins: 200, materials: { planks: 6, stone: 4 } }, upkeep: 6, workers: 4, crew: "settlers", unlock: { residents: 0, citizens: 10 }, buildable: true,
recipe: { input: null, inputs: 0, output: "ore", batch: 1, seconds: 10 }, gathers: { source: "ore", radius: 3 }, carriers: 2,
wear: 50, dusty: true, appeal: { value: -8, reach: 4 }
},
@@ -261,34 +261,34 @@ export const kinds: Readonly<Record<KindId, Kind>> = {
farm: {
id: "farm", title: "Farm", blurb: "sows fields around it and harvests the wheat",
category: "food", size: 3, half: 12, stories: 1, roof: "gable", bays: 2, window: 4, topper: "none",
- cost: { coins: 120, materials: { planks: 4 } }, upkeep: 5, workers: 2, crew: "settlers", unlock: { residents: 30, citizens: 0 }, buildable: true,
+ cost: { coins: 120, materials: { planks: 4 } }, upkeep: 5, workers: 2, crew: "settlers", unlock: { residents: 60, citizens: 0 }, buildable: true,
recipe: { input: null, inputs: 0, output: "wheat", batch: 1, seconds: 4 }, gathers: { source: "field", radius: 2 },
plants: { what: "field", radius: 2, seconds: 3, max: 8 }, carriers: 2, appeal: { value: -2, reach: 2 }
},
mill: {
id: "mill", title: "Mill", blurb: "grinds wheat into flour",
category: "food", size: 2, half: 8, stories: 2, roof: "flat", bays: 2, window: 4, topper: "sails",
- cost: { coins: 150, materials: { planks: 6, stone: 2, tools: 1 } }, upkeep: 8, workers: 2, crew: "citizens", unlock: { residents: 30, citizens: 0 }, buildable: true,
+ cost: { coins: 150, materials: { planks: 6, stone: 2, tools: 1 } }, upkeep: 8, workers: 2, crew: "citizens", unlock: { residents: 60, citizens: 0 }, buildable: true,
recipe: { input: "wheat", inputs: 1, output: "flour", batch: 1, seconds: 6 }, holds: { accepts: ["wheat", "flour"], cap: 8 }, carriers: 2,
wear: 60, appeal: { value: -4, reach: 3 }
},
bakery: {
id: "bakery", title: "Bakery", blurb: "bakes flour into bread",
category: "food", size: 2, half: 12, stories: 1, roof: "flat", bays: 2, window: 6, topper: "chimney",
- cost: { coins: 150, materials: { planks: 4, stone: 4, tools: 1 } }, upkeep: 8, workers: 2, crew: "citizens", unlock: { residents: 30, citizens: 0 }, buildable: true,
+ cost: { coins: 150, materials: { planks: 4, stone: 4, tools: 1 } }, upkeep: 8, workers: 2, crew: "citizens", unlock: { residents: 60, citizens: 0 }, buildable: true,
recipe: { input: "flour", inputs: 1, output: "bread", batch: 2, seconds: 6 }, holds: { accepts: ["flour", "bread"], cap: 8 }, carriers: 2,
wear: 60, hot: true, appeal: { value: -4, reach: 3 }
},
sheep: {
id: "sheep", title: "Sheep farm", blurb: "shears sheep for wool",
category: "crafts", size: 3, half: 12, stories: 1, roof: "gable", bays: 2, window: 4, topper: "none",
- cost: { coins: 100, materials: { planks: 4 } }, upkeep: 5, workers: 2, crew: "settlers", unlock: { residents: 15, citizens: 0 }, buildable: true,
+ cost: { coins: 100, materials: { planks: 4 } }, upkeep: 5, workers: 2, crew: "settlers", unlock: { residents: 40, citizens: 0 }, buildable: true,
recipe: { input: null, inputs: 0, output: "wool", batch: 1, seconds: 6 }, carriers: 2, appeal: { value: -2, reach: 2 }
},
weaver: {
id: "weaver", title: "Weaver", blurb: "weaves wool into cloth",
category: "crafts", size: 2, half: 12, stories: 1, roof: "flat", bays: 2, window: 6, topper: "none",
- cost: { coins: 150, materials: { planks: 4, stone: 2, tools: 1 } }, upkeep: 8, workers: 2, crew: "citizens", unlock: { residents: 15, citizens: 0 }, buildable: true,
+ cost: { coins: 150, materials: { planks: 4, stone: 2, tools: 1 } }, upkeep: 8, workers: 2, crew: "citizens", unlock: { residents: 40, citizens: 0 }, buildable: true,
recipe: { input: "wool", inputs: 1, output: "cloth", batch: 1, seconds: 6 }, holds: { accepts: ["wool", "cloth"], cap: 8 }, carriers: 2,
wear: 60, appeal: { value: -2, reach: 2 }
},
@@ -307,7 +307,7 @@ export const kinds: Readonly<Record<KindId, Kind>> = {
chapel: {
id: "chapel", title: "Chapel", blurb: "a walker brings faith to the homes it passes",
category: "services", size: 2, half: 12, stories: 2, roof: "flat", bays: 2, window: 6, topper: "cupola",
- cost: { coins: 200, materials: { planks: 6, stone: 6 } }, upkeep: 10, workers: 1, crew: "citizens", unlock: { residents: 15, citizens: 0 }, buildable: true,
+ cost: { coins: 200, materials: { planks: 6, stone: 6 } }, upkeep: 10, workers: 1, crew: "citizens", unlock: { residents: 40, citizens: 0 }, buildable: true,
service: { service: "faith", seconds: 8, range: 22 }, appeal: { value: 4, reach: 4, full: 2 },
upgrade: {
title: "Church", blurb: "a church with a tower: its priest walks further, more often, and the streets around it are the finest", rank: 2,
@@ -330,7 +330,7 @@ export const kinds: Readonly<Record<KindId, Kind>> = {
hospital: {
id: "hospital", title: "Hospital", blurb: "physicians call more often and walk further",
category: "services", size: 3, half: 16, stories: 2, roof: "flat", bays: 2, window: 6, topper: "cupola",
- cost: { coins: 400, materials: { planks: 10, stone: 10, tools: 2 } }, upkeep: 16, workers: 4, crew: "citizens", unlock: { residents: 0, citizens: 40 }, buildable: true,
+ cost: { coins: 400, materials: { planks: 10, stone: 10, tools: 2 } }, upkeep: 10, workers: 4, crew: "citizens", unlock: { residents: 0, citizens: 40 }, buildable: true,
service: { service: "health", seconds: 4, range: 40 }, appeal: { value: 2, reach: 3, full: 2 }
},
watchhouse: {
@@ -688,17 +688,17 @@ export const lands: Readonly<Record<LandId, {
}>> = {
rich: {
title: "rich", blurb: "deep forests, plenty of stone and ore, two lakes, a full treasury",
- forests: 7, stone: 4.5, ore: 3, rock: 40, lakes: 2, coins: 2400,
+ forests: 7, stone: 4.5, ore: 3, rock: 40, lakes: 2, coins: 1250,
stock: amounts({ wood: 15, planks: 50, stone: 24, tools: 10, fish: 30 })
},
fair: {
title: "fair", blurb: "enough of everything, if it is not wasted",
- forests: 5.5, stone: 3, ore: 2, rock: 32, lakes: 2, coins: 1900,
+ forests: 5.5, stone: 3, ore: 2, rock: 32, lakes: 2, coins: 1100,
stock: amounts({ wood: 10, planks: 40, stone: 16, tools: 10, fish: 20 })
},
harsh: {
title: "harsh", blurb: "thin woods, little stone, one deposit of ore, one lake",
- forests: 4, stone: 2, ore: 1, rock: 24, lakes: 1, coins: 1500,
+ forests: 4, stone: 2, ore: 1, rock: 24, lakes: 1, coins: 950,
stock: amounts({ wood: 10, planks: 30, stone: 12, tools: 8, fish: 15 })
}
}
@@ -792,9 +792,9 @@ export const crown = {
/** Nor more than this share of what the town's storage holds of one good. */
room: 0.6,
/** Reward as a multiple of what the goods would fetch from traders, plus a bonus; the fine is the goods' worth plus the bonus. */
- reward: 2,
+ reward: 1.3,
fine: 1,
- bonus: 50,
+ bonus: 25,
/** How long the crown remembers a missed request, in minutes. */
memory: 4,
/** Requests missed in a row before the crown dismisses the mayor. */
diff --git a/test/balance-model.test.ts b/test/balance-model.test.ts
index 0e23027..4d42af7 100644
--- a/test/balance-model.test.ts
+++ b/test/balance-model.test.ts
@@ -131,10 +131,10 @@ test("the mathematical plan reaches citizens through ordinary game construction"
const rules = resolveRules(), { scenario, builds } = buildScenario(rules)
const r = verifyBuilds({ rules, scenario }, builds)
assert.deepEqual(r.messages, [])
- // 32 in citizens' homes: its three-cell park holds one furnishing that counts, too few to lift a townhouse.
- assert.equal(r.actual.at(-1)!.citizens, 32)
+ // Six of its sixteen homes become citizens' homes: 48 citizens.
+ assert.equal(r.actual.at(-1)!.citizens, 48)
assert(r.firstCitizenSecond !== null && r.firstCitizenSecond <= 300)
- assert.equal(r.prediction.rows.at(-1)!.citizens, 32)
+ assert.equal(r.prediction.rows.at(-1)!.citizens, 48)
assert(r.prediction.assumptions.length > 0)
assert.equal(r.errors.length, r.actual.length)
})
diff --git a/test/economy.test.ts b/test/economy.test.ts
index 389c2a4..7a457f8 100644
--- a/test/economy.test.ts
+++ b/test/economy.test.ts
@@ -6,10 +6,10 @@
* one number that opens a hole a player could play over and over fails
* here.
*
- * A rule the shipped game breaks today is marked `todo` with what breaks
- * it: the suite stays green, and `node --test` lists each one, so this
- * file is also the list of holes still open. Once a hole is closed, drop
- * its `todo` and the rule holds from then on.
+ * A rule the shipped game breaks is marked `todo` with what breaks it: the
+ * suite stays green, and `node --test` lists each one, so this file is
+ * also the list of holes still open. Once a hole is closed, drop its
+ * `todo` and the rule holds from then on.
*/
import assert from "node:assert/strict"
import { test } from "node:test"
@@ -31,7 +31,7 @@ const round = (n: number) => Math.round(n * 100) / 100
/** A producer adds between half and twice what producers usually add for each coin of upkeep. */
const PRODUCER_BAND = [0.5, 2] as const
-test("every producer adds about what producers usually do for its upkeep", { todo: "fishery ×2.8 and bakery ×2.0 of the usual; mill ×0.29 and mine ×0.47" }, () => {
+test("every producer adds about what producers usually do for its upkeep", () => {
const all = producers(rules), usual = median(all.map((p) => p.perUpkeep))
none(all.filter((p) => p.perUpkeep < usual * PRODUCER_BAND[0] || p.perUpkeep > usual * PRODUCER_BAND[1])
.map((p) => `${p.id}: adds ${round(p.adds)}/min for ${p.upkeep} upkeep, ×${round(p.perUpkeep / usual)} of the usual ${round(usual)}`), "producer outside the band")
@@ -106,32 +106,33 @@ test("administration is charged by the resident, so finer homes pay for their pe
// ── The opening ───────────────────────────────────────────────────────────
-/** The share of the first citizens' buildings a new town's treasury pays for, at most; and the homes they need, at least. */
-const OPENING_SHARE = 0.7
+/** The share of the first citizens' buildings a new town's treasury pays for, at most (it cannot buy them all at once); and the homes they need, at least. */
+const OPENING_SHARE = 1
const OPENING_HOMES = 15
-test("a new town's treasury pays for only part of the first citizens' buildings", { todo: "every land's treasury buys the whole kit (1260 coins): rich 190%, fair 151%, harsh 119%" }, () => {
+test("a new town's treasury pays for only part of the first citizens' buildings", () => {
const kit = openingKit(10, rules)
none((Object.entries(rules.lands) as Array<[string, { coins: number }]>).filter(([, l]) => l.coins > kit.cost * OPENING_SHARE)
.map(([id, l]) => `${id}: ${l.coins} coins for a ${kit.cost}-coin kit (${kit.kinds.join(", ")}), ${Math.round((l.coins / kit.cost) * 100)}%`), "opening paid for")
})
-test("the first citizens' buildings open only once the town has grown", { todo: "all of them open by the 8th cottage" }, () => {
+test("the first citizens' buildings open only once the town has grown", () => {
const kit = openingKit(10, rules)
assert(kit.unlockHomes >= OPENING_HOMES, `the ${kit.kinds.join(", ")} all open at ${kit.unlockHomes} cottages`)
})
// ── The crown ─────────────────────────────────────────────────────────────
-test("answering the crown with bought goods does not pay", { todo: "the reward (2× price + 50) beats buying at 1.5× on requests of 10 to 30" }, () => {
+test("answering the crown with bought goods pays no more than its thanks", () => {
+ // The bonus is the crown's thanks for answering at all; the goods themselves are paid about what they cost to buy.
const goods = (Object.keys(rules.goods) as Array<GoodId>).filter((g) => rules.spoils[g] === undefined)
- none(goods.flatMap((g) => [10, 20, 30].map((n) => crownMargin(g, n, rules))).filter((m) => m.margin > 0)
+ none(goods.flatMap((g) => [10, 20, 30].map((n) => crownMargin(g, n, rules))).filter((m) => m.margin > rules.crown.bonus)
.map((m) => `${m.amount} ${m.good}: reward ${m.reward}, bought for ${m.bought}, +${m.margin}`), "crown pays for bought goods")
})
// ── Services ──────────────────────────────────────────────────────────────
-test("a bigger building for a service walks at least as far for its upkeep as a smaller one", { todo: "a hospital walks 37.5 cells a coin of upkeep, a healer 56" }, () => {
+test("a bigger building for a service walks at least as far for its upkeep as a smaller one", () => {
const all = services(rules), out: Array<string> = []
for (const big of all) for (const small of all)
if (big.service === small.service && big.cost > small.cost && big.perUpkeep < small.perUpkeep)
diff --git a/test/guide.test.ts b/test/guide.test.ts
index 9756f33..cab3737 100644
--- a/test/guide.test.ts
+++ b/test/guide.test.ts
@@ -84,16 +84,16 @@ test("after ten homes the course goes on to citizens, never falling silent, a bu
// Ten homes stand, and quiet or not, the guide has the next step. Stone in store: no quarry yet.
assert.equal(next(founded()), "cloth")
assert.equal(next(founded({ stock: amounts({ planks: 30, stone: STONE_LOW - 2 }) })), "quarry", "a quarry once stone runs low")
- // Cloth and faith open at 15 residents, bread at 30: with 20, cloth comes first.
- const twenty = founded({ residents: 20 }, ["quarry"])
- assert.equal(next(twenty), "cloth")
- assert.equal(next(founded({ residents: 20 }, ["quarry", "sheep", "weaver"])), "chapel")
+ // Cloth and faith open at 40 residents, bread at 60: with 45, cloth comes first.
+ const some = founded({ residents: 45 }, ["quarry"])
+ assert.equal(next(some), "cloth")
+ assert.equal(next(founded({ residents: 45 }, ["quarry", "sheep", "weaver"])), "chapel")
// Bread cannot be made yet: the step says what opens it.
- const short = founded({ residents: 20 }, ["quarry", "sheep", "weaver", "chapel"])
+ const short = founded({ residents: 45 }, ["quarry", "sheep", "weaver", "chapel"])
assert.equal(next(short), "wheat")
- assert.match(lockedNote(guideSteps.find((s) => s.id === "wheat")!, short)!, /opens at 30 residents \(20 now\)/)
- assert.equal(next(founded({ residents: 30 }, ["quarry", "sheep", "weaver", "chapel", "farm", "mill"])), "bakery")
- const supplied = founded({ residents: 40 }, ["quarry", "sheep", "weaver", "chapel", "farm", "mill", "bakery"])
+ assert.match(lockedNote(guideSteps.find((s) => s.id === "wheat")!, short)!, /opens at 60 residents \(45 now\)/)
+ assert.equal(next(founded({ residents: 60 }, ["quarry", "sheep", "weaver", "chapel", "farm", "mill"])), "bakery")
+ const supplied = founded({ residents: 70 }, ["quarry", "sheep", "weaver", "chapel", "farm", "mill", "bakery"])
assert.equal(next(supplied), "citizens")
assert.equal(next({ ...supplied, finerHomes: 1, sawTown: false }, { quiet: true }, founding.map((s) => s.id)), "goals")
// The last word: the ranks, up to a city.
@@ -122,7 +122,7 @@ test("the course never asks for a building before the town needs it, and says wh
})
test("a step the treasury cannot pay for says to save up, and gives way to one it can", () => {
- const poor = founded({ residents: 20, coins: 120 }, [])
+ const poor = founded({ residents: 45, coins: 120 }, [])
const chapel = guideSteps.find((s) => s.id === "chapel")!
assert.match(lockedNote(chapel, poor)!, /Save up: the chapel costs 200 coins \(120 now\)/)
// The sheep farm (100) can be paid for, the weaver (150) not yet: the cloth step asks, the cheaper first.
diff --git a/tools/balance/catalog.ts b/tools/balance/catalog.ts
index f53752c..3145e3f 100644
--- a/tools/balance/catalog.ts
+++ b/tools/balance/catalog.ts
@@ -14,17 +14,24 @@ export const citizensDistrict = (rules: Rules, parks = true): Scenario => {
return parks ? { ...s, parks: citizenPark() } : s
}
+/**
+ * What the authored district has to spend: its own budget, not a land's starting treasury, so the fixture
+ * measures the model against the game rather than the opening's difficulty.
+ */
+export const AUTHORED_BUDGET = 2000
+
/** Authored flat-land starting district. Roads/homes are charged; it is not a generated-map or human-win claim. */
export const buildScenario = (rules: Rules) => {
const kinds: KindId[] = ["farm", "mill", "bakery", "sheep", "weaver", "market", "chapel", "lumberjack", "sawmill", "quarry", "fishery"]
- const template = district("authored-bootstrap", Array(12).fill(1), kinds, false, rules)
+ // Sixteen cottages: enough residents to open the bread chain.
+ const template = district("authored-bootstrap", Array(16).fill(1), kinds, false, rules)
const hall = template.buildings.find((b) => b.kind === "townhall")!
const initial = { ...rules.lands.fair.stock, planks: rules.lands.fair.stock.planks - template.homes.length }
const land: Scenario["land"][number][] = [...template.land.filter((l) => l.type === "water")]
const lumber = template.buildings.find((b) => b.kind === "lumberjack")!, quarry = template.buildings.find((b) => b.kind === "quarry")!
for (let x = lumber.tile.x - 3; x < lumber.tile.x + 3; x++) for (let y = 35; y < 39; y++) land.push({ tile: { x, y, size: 1 }, type: "tree", amount: 1, growth: rules.grown.tree })
for (let x = quarry.tile.x; x < quarry.tile.x + 2; x++) land.push({ tile: { x, y: 34, size: 1 }, type: "stone", amount: rules.lands.fair.rock, growth: 0 })
- const scenario: Scenario = { ...template, land, name: "authored-bootstrap", coins: rules.lands.fair.coins - template.homes.length * rules.home.cost.coins - template.roads.length * rules.roadCost,
+ const scenario: Scenario = { ...template, land, name: "authored-bootstrap", coins: AUTHORED_BUDGET - template.homes.length * rules.home.cost.coins - template.roads.length * rules.roadCost,
buildings: [{ ...hall, stock: initial }], trade: { buys: ["tools", "planks"], sells: [], reserve: 10 } }
const order: ReadonlyArray<readonly [KindId, number]> = [["sawmill", 0], ["lumberjack", 0], ["fishery", 0], ["quarry", 30], ["mill", 60], ["bakery", 90], ["farm", 120], ["sheep", 150], ["weaver", 180], ["market", 210], ["chapel", 240]]
const builds: BuildAction[] = order.map(([kind, at]) => ({ kind, at, tile: template.buildings.find((b) => b.kind === kind)!.tile }))