◈ SETTLEMENT DESIGN JOURNAL

Build log / Step 43 of 45

STEP 43 · VERSION 0.0.4 EXTENDED · 1 DECEMBER 2026

The code review: a quicker valley, a heifer, and children in school

How we got here. The owner, 1 December: "review and improve all game code."

Planned: check every script, fix what is slow, wrong or left over, and keep every check passing. No new features.

  • A long unattended run. A new tool, tools/soak.gd, plays the game for years with nobody at it. It answers every request with one of its options, picked by a seeded random number, so different seeds take the valley different ways. Every midnight it checks what must always hold (no store below nothing, food lots that add up, no two buildings with one name, no debt of less than nothing). It can time each part of the hour, and it can save the game, load the save into a second simulation and play the two side by side for three days.
  • Slow. With sixteen households, in October 1827, an hour of game time took 68 ms and some mornings stopped for two seconds. Three causes. The side panel was rewritten after every hour the simulation played (24 ms each time), even at the speeds where it plays several hours between two drawn frames. Every search for the nearest tree or rock asked three things of every tree in the valley (is it felled, is it on someone's land, can we get to it) before it looked at how far away it was. And every neighbor's errand that ended redrew every building. Now the panel and the scene are brought up to date once a frame; searches look at distance first; "can we reach the far side of the creek today" is asked once, not once a tree.
  • A heifer in milk. Clark Beddows sells the Hales a two-year-old heifer "to bring into milk when she calves" (step 42). She gave milk like a cow from the day she came, until the game was saved and loaded. Then she was dry, with a calving date of March 1824, a year before she was born. Now a heifer gives no milk until her first calf, before a save and after it, and a save that already holds the mistake is put right when it loads.
  • Children in the schoolroom. The check for "is this child at school this hour" was written at step 39 and nothing ever called it. Children were counted as attending while a planned job had them somewhere else, and Thomas's card said "Playing near the house". Now, from nine to one in the winter term, the children and Mrs. Ashby are in the schoolroom, their cards say so, and their other work starts at one.
  • Smaller things. Pigs' weights were rounded to a tenth after a day's gain of 0.35 kg, a midpoint every day, so a pig gained 0.3 or 0.4 by the last bit of a number: to a hundredth now. Loading a game put Clark Beddows on the list of late arrivals. Worn ground was more than half of every save (555 of 955 KB): wear is kept to a thousandth. A land deal of a kind that doesn't exist is refused, not guessed at.
  • Left over, removed. An if true: round the field code, three functions nothing called, and creek constants in the scene from before the terrain moved into data.

The shots are from the valley the town run saved on 15 October 1827 (steps 41 and 42), loaded with this build and played on to a school morning, 6 November.

Thomas Hale's card at ten on a school morning: At school, with Mrs. Ashby
6 November 1827, ten o'clock: Thomas's card says where he is. In the list on the right, Samuel and Lydia Pratt are at school too.
The valley from above in November 1827, with the neighbors panel open
The valley that afternoon: sixteen households. This is the game that took 68 ms an hour.
The schoolroom on the Hales' barn at ten: nobody outside but Abel
Ten o'clock: the schoolroom on the barn. Twenty children and Mrs. Ashby are inside; Abel is in the yard by the hens.
The same place at two: Ruth is outside
Two o'clock: school is out, and Ruth is in the yard.
Measured: Checks: 790 before, 815 now, all passing; the whole run takes 46 seconds where it took 82. The 1827 valley, sixteen households, October to January: 68 ms for an hour of game time before, 8 ms now; the slowest hour 2.3 s before, 0.15 s now. A new game's first year: 25 ms an hour before, 0.7 ms now. The panel's own rewrite: 24 ms before, 14 ms now, and once a frame instead of once an hour. The neighbors' morning plans: 95 ms before, 7 ms now. Two games played from the same seeds before and after the speed-ups (1824 to 1825, and 1826 to 1827) ended the same in every part of the save. Soak, with the fixes in: four runs, seven game years, seeds 7, 5, 3 and 11, twenty-eight saves loaded and played beside the original: no problems.
Not done, and known: Not every line was read. The tools went over every script; the parts read line by line are the ones they pointed at (work and site searches, paths, the animals' day and the save; the neighbors' planner and deliveries; the school; request routing; the panel and the scene). The visitors, roads, traffic, property, money, trader, township and drover scripts were not read line by line; they came through the soak with no problems. The simulation still takes the house door's position from the scene, so a simulation with no scene walks nowhere. A loaded game can differ from the one it was saved from by a rounding (a load of firewood 51.7 kg, not 51.8), because a save is text. The answers to "short of food", "short of firewood" and "short of hay" are the same code three times. The autosave each dawn takes about 40 ms with sixteen households.
FIELD NOTES · HOW THIS STEP WAS CHECKED

Field notes

Checks: the quicker ways of asking give the old answers (16: a point inside a claim, 4,000 cases at any rotation; stumps; reaching a place, the nearest tree and the nearest rock with the creek wadeable, in flood, and in flood with a footbridge; the neighbors' nearest tree; which path cells are drawn; a land deal that doesn't exist); the school morning (4, within step 39's); the heifer (5, within step 42's). 815 in all.

What they show

  • A point is inside a claim by plain arithmetic exactly when the old way says so, for 4,000 claims and points.
  • With every fourth tree felled and every third rock worked out, the nearest tree and rock the Hales may use are the ones the slow search finds, whatever the creek is doing.
  • At eleven on 6 November 1827 Thomas and Daniel Ashby are in the schoolroom and Mrs. Ashby is keeping school; by three they aren't.
  • The heifer gives no milk, before a save and after it; nobody says she has "gone dry"; a save with the 1824 calving date is mended; Bessie's own date is left alone.
What playing caught that the checks didn't
  • All 790 checks passed with every one of these in the game. The checks for Clark's heifer asked whether she was bought, not what she gave. The checks for the school counted days attended, not where the children were.
  • The slowness never showed in the checks: their valleys are small and have no panel. It showed in the first soak run from the saved 1827 game, with a stopwatch on each part of the hour.
  • The heifer, the pigs' weights and Clark on the arrivals list all came from one test the checks didn't have: load a save into a second game and play both. The first time, the two games had drifted apart in three days.
  • That test also found something that is not a fault to fix here: numbers written to a save as text can come back different in the last digit. The soak allows for that and reports anything larger.
  • Rendering the school morning showed the children's cards and the empty yard; the checks only see the records.