Skip to content

Lay out a town's streets and square before any of it is written - #103

Merged
calebl merged 5 commits into
mainfrom
fm/ta-town-s3-map
Dec 4, 2026
Merged

calebl merged 5 commits into
mainfrom
fm/ta-town-s3-map

Conversation

@calebl

@calebl calebl commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

What changes

A place with a towns row is a town. The row says how many streets the town has and whether it has a square. One seeded roll lays the town out before any of it is written:

  • Streets and square. Each one is an outdoor room with a box in the town's plane. They are cut into a near-square grid and walked as a serpentine, the way a floor's rooms are (interior::Builder). Every street is reachable from the square, no street passes four doorways, and the square comes first.
  • Ways in. Every doorway the file gives the town place that does not lead to a building lands on the first street with a doorway free, which is the square when there is one. The doorway keeps its barrier, key, hazard, passages and tolls (turn::doorway::move_doorway, now shared with open_the_way_in).
  • Anchors. A building is an anchor when the file joins it to the town by a doorway, or makes it a building of the town (parent: Thornwick). Each anchor is drawn one street with a doorway free, and stands on it by one doorway each way. Roll::FRONTAGE_SIDE (22) on the building's row says which side of that street it fronts. The roll is made among the sides with no street on them, worked out on every read and never kept.
  • Lots. Every frontage left over becomes a lot: a building stub of the town with one doorway to its street.
    • Its kind is dealt by weight from the new data/location/town.yml: house 10, shop 3, workshop 2, smithy 1, inn 1, warehouse 1.
    • Its footprint comes from "a few rooms", and its danger from the town's.
    • Its name is {town} {kind} {n}.
    • It is laid out when somebody walks in, like any building.

It is written once, with no model (turn::town). Either the world is loaded through Engine::lay_out_towns(story, dry_run), or else it happens on the turn somebody first walks into the town place, and that turn then writes the street they arrive on. Both give the same rows, and the same seed draws the same town. The town place itself is never written, and no street gets an exits call: its ways out are all laid out already.

Out of scope, as planned: districts, landmarks, residents with homes and work, the climate read, and the off-screen tick.

Smaller changes that follow from it

  • way_in takes a place's first room with a box, so an anchor or lot of a town is never taken for one of its streets (src/turn.rs).
  • layout::lay_out skips a town, and so does reach::findings, which therefore does not warn that a town has no layout: its streets are stood in instead. The layout and reach vector portions each gain a case and say so in their notes.
  • store::TOWNS is an optional table, like floors: a database from before it reads as holding no town.

What a model is sent

Every existing world's requests are byte-identical. parity --write parity rewrote no existing golden or records file. 111 scripts are unchanged, and only the new walk was written. Only the room writer's detail request for a street or square of a town gets new text. It is quoted here in full.

Teasers and names the engine writes onto rows. They reach the writer in ## The Place and in plan clauses.

  • Street or square teaser: {A|An} {kind} in {town}, {width} by {depth} paces. For example, A square in Thornwick, 22 by 22 paces.
  • Lot teaser: {A|An} {kind} in {town}. For example, A house in Thornwick.
  • Lot name: {town} {kind} {n}. For example, Thornwick shop 1.
  • A street's placeholder name until the writer names it is {town} room {n}. That format is unchanged.

The plan block, for a street or square only. The header and its paragraph:

## Where This {Kind} Is
The game's own records of this {kind}, already decided and not yours to
change. Write the {kind} around them: do not contradict a measurement, and
do not give it a way out this list does not have.

Then these sentences:

  • This {kind} is {w} by {d} paces -- about {W} by {D} metres.
  • It is part of {town}, which is {W} by {D} paces across. This becomes It is part of {town}. if the town has no footprint, which never happens once it is laid out.
  • Its ways out: {clause}; {clause}. Those are every way out of this {kind}. Each clause is one of:
    • to the {north|east|south|west}, {street}
    • {building}, which fronts it on the {north|east|south|west} side
    • a way out to {place}, which is outside {town}. This clause is unchanged; building rooms already get it.
  • With no ways out: Nothing leads out of this {kind} yet.

As sent for the square of the sweep world:

Where This Square Is

The game's own records of this square, already decided and not yours to
change. Write the square around them: do not contradict a measurement, and
do not give it a way out this list does not have.
This square is 22 by 22 paces -- about 33 by 33 metres. It is part of Thornwick, which is 40 by 40 paces across. Its ways out: The Shrine, which fronts it on the north side; to the east, Thornwick room 2; to the south, Thornwick room 4; a way out to The North Road, which is outside Thornwick. Those are every way out of this square.

The naming line, which replaces NAME THIS ROOM for a street or square. These are the exact line breaks:

- NAME THIS {KIND}. It is one {kind} of {town}. The player reads the {kind} and
  the town together -- "the <your name> of {town}" -- so name the {KIND} only,
  and never put the town's own name into it. A short noun phrase carrying the
  article English wants on it, 2 to 4 words: "the tanners' row", "the long
  street", "the well square". Name it for what the plan above says this {kind}
  is and for what you have just described along it. Never a comma in it

Once a street of the town is named, this follows it: . Places in {town} that are already named, so do not reuse one: {name}; {name}

The detail schema's name description, for a street or square only (schemas::detail_outdoors). It is one line:

What this {kind} is called -- ONLY when the instructions above ask you to name it. Leave this out entirely otherwise. A short noun phrase a player would type to walk into it, carrying the article English wants on it: "the long street". Never the name of the town it is in, never a name this story has already given to a place, a person or a thing, and never a comma.

The narrator. In a street, the narrator (moment.rs narration context) reads the plan sentences above, and the lot names and street placeholders in its existing Ways out of here: line. It reads nothing else new.

Tests

tests/town.rs uses the new world, A Town of Three Streets. It has:

  • Thornwick: three streets and a square.
  • The North Road: its way in.
  • The Shrine and The Inn: buildings joined to it by a doorway.
  • The Smithy: a building of the town with no doorway.

The tests:

  • every_street_is_reachable_and_none_passes_four_doorways: four rooms, the square first, each with a box inside the town's footprint and four doorways each way. Every one is reachable from the square, and nothing still leads to the town place.
  • the_anchors_stand_where_the_file_put_them_and_the_lots_fill_the_rest: the road arrives on the square. The Shrine, The Inn and The Smithy each front a street by one doorway each way, and keep their kinds. Every other frontage is a lot of a kind from the table, with its name, its teaser, a footprint and one doorway to its street.
  • the_same_seed_draws_the_same_town: two loads lay out the same rows. A dry run writes nothing and says the same. A second run does nothing. The town laid out on the first walk-in has the same rows as the loaded one.
  • no_street_gets_an_exits_call: walking into each of the four streets sends one location request each, and the walk sends no exits request at all.
  • a_street_is_told_its_shape_out_of_doors: no wall, door, stair or storey, and the square's sentences exactly.
  • a_street_is_written_and_named_out_of_doors: the streets' requests carry the outdoor header and the outdoor name description. The Inn's room, in the same town, carries the indoor ones byte for byte.

src/town.rs has unit tests over 0 to 60 streets, with and without a square: every room reachable, every doorway both ways, never past four. It also tests the same seed, the ways in, the lots, the footprint and the frontage side.

Sweep

  • New world parity/worlds/a-town-of-three-streets.sql.
  • New script parity/scripts/a-town-laid-out-before-it-is-written.yml, listed in PASSING with a golden and a records file. The walk:
    1. Into Thornwick, which writes the square: "the well square".
    2. Along each street: "the forge lane", "the tanners' row", "the inn street".
    3. Into The Inn, through the door that was moved onto its street.
    4. Back onto the street, and round to the square.
  • No existing golden or records file moved.

Gate (offline, both provider keys unset)

  • cargo fmt --check: clean.
  • cargo clippy --workspace --all-targets --locked -- -D warnings: clean.
  • cargo test --workspace --locked: 547 passed, 0 failed.
  • BLESS=1 cargo test --test vectors: stable. Only the two new cases were blessed.
  • parity --check parity: 112 of 116 agree. The four that do not are the PASSING_WITH_RUNNER scripts, the same as on main.
  • fight --check sim: all 10 fight goldens agree.
  • Engine doctor findings (noticed, carry, material, wear and layout): none on the-salt-assizes, the-lunar-cartographer, the-unrecorded-hour, or the new world once laid out.
  • No model was called. The realization baseline runs on the game side, once the paired PR below carries the migration and loader: rake eval:realization before and after, capped at 0.50 USD in total.

What the game needs (paired PR in renderedstep/server)

The paired game PR is renderedstep/server#402. The world dump here is that PR's loader dump of the world below, at its migration 20261204140420. It has the same rows and schema as the first, hand-built dump. The script here is the game's script re-emitted by Ruby's YAML library (parity/README.md). Neither change moved a golden, a records file or a request.

  1. Migration create_towns. This is the shape store::OPTIONAL_SHAPES pins:
    create_table :towns do |t|
      t.references :location, null: false, foreign_key: { on_delete: :cascade }, index: { unique: true }
      t.integer :streets, null: false
      t.boolean :square, null: false, default: false
      t.timestamps
    end
    The game PR's version is 20261204140420, and the world dump carries it.
  2. The model.
    • Add Town with belongs_to :location, and Location has_one :town, dependent: :destroy.
    • Validate streets as an integer of at least 0. The engine reads at most 100 (town::MOST_STREETS) and always lays out at least one street.
    • Add a factory and a model test.
  3. The loader and the exporter.
    • Add the key town: {streets:, square:} on a location, loaded like floor: (load_towns!), and add it to the exporter.
    • Validate it: no town with floor:, and no town with a parent. The footprint is optional: the engine keeps a given one when it holds the grid, and sizes one from the street count otherwise.
  4. Laying the town out.
    • The extension needs RenderedStep.lay_out_towns(database, story_id, dry_run) over Engine::lay_out_towns, with Playthrough::RustEngine.lay_out_towns.
    • Add an Update::Steps::LayOutTowns that runs before LayOutRooms.
    • WorldSeed::Loader#lay_out_rooms! must skip a town (next if room.town.present?), mirroring layout::lay_out. The loader does not lay the town out in its own transaction. The update step or the first walk-in does that.
  5. Location::Interior.entry_room has to take the first child with a box, mirroring way_in (src/turn.rs). laid_out? needs the same change wherever it decides a way in.
  6. EngineData has to pick up the new file location/town. test/models/engine_data_test.rb lists it next to location/size.
  7. Doctor findings. All three are warnings:
    • a laid-out town with a doorway still on the town place, meaning an anchor or way in that found no frontage. Engine::lay_out_towns reports these as None.
    • a town with more anchors and ways in than it has frontages;
    • a street past four doorways. This is the engine's invariant, worth asserting.
  8. The map page has to draw a town's streets and square in its plane, with each anchor and lot at its frontage.
  9. The Ruby loop, if anything still plays it outside the tests, must not send a town place to the model. A town place is laid out, never written.
  10. The world, the script and the pin.
    • Add lib/engine_sweep/worlds/a-town-of-three-streets.yml and lib/engine_sweep/scripts/a-town-laid-out-before-it-is-written.yml. Both are below.
    • Move ext/renderedstep/Cargo.toml to this PR's merge commit.
    • Vendor parity/goldens/a-town-laid-out-before-it-is-written.json, parity/records/a-town-laid-out-before-it-is-written.json, parity/worlds/a-town-of-three-streets.sql, and the layout and reach vector portions.
    • Add test/engine_parity/a-town-laid-out-before-it-is-written.checks.json (SCRIPT=a-town-laid-out-before-it-is-written bin/rails engine:checks). It was not written here, because there is no game run.

SERVER_COMMIT in .github/workflows/ci.yml names ad16f9f, the head of renderedstep/server#402. That commit carries items 1 to 10 and pins this branch at c724c05, so CI plays the new walk through the game's runner and gates.

lib/engine_sweep/worlds/a-town-of-three-streets.yml
# A town the file gives only its street count and a square, with a road
# into it, two buildings joined to it by a doorway and one building of it
# with none. Nothing of the town is written: the engine lays its streets,
# square and lots out before any of it is (`a-town-laid-out-before-it-is-written.yml`).
format: 2
universe:
  physics: Ordinary physics.
  technology: Lanterns, iron keys and hand tools.
  weapons: Short blades and cudgels.
  geographies: A small town of three streets around a square.
  civilizations: Townsfolk who keep a shrine, an inn and a forge.
  history: The shrine is older than the square around it.
  economics: Coin and barter.
  politics: A town council keeps the peace.
  religion: The town leaves candles at the shrine.
  races:
  - name: Townsfolk
    description: Ordinary people of the town.
story:
  title: A Town of Three Streets
  genre: town adventure
  start_time: '2026-12-03T08:00:00Z'
  preface: Thornwick is a small town of three streets around a square.
  summary: Wren walks the streets of Thornwick.
opening_scene:
  location: The North Road
  characters: [Wren]
  description: You stand on the north road with the roofs of Thornwick ahead.
  summary: Wren arrives on the north road.
characters:
- fullname: Wren
  nickname: Wren
  race: Townsfolk
  age: 31
  sex: female
  is_protagonist: true
  is_companion: false
  backstory: She grew up on the north road and has never walked all of Thornwick.
  personality: Curious and careful.
  appearance: A grey coat and a lantern.
  likes: Quiet mornings.
  dislikes: Locked doors.
  fears: The dark under the shrine.
  stats: {level: 3, hit_die: 8, strength: 12, dexterity: 12, will: 12}
locations:
- name: The North Road
  detail_level: realized
  opening: true
  population: nobody
  description: A rutted road running south between hedges to the edge of Thornwick.
  teaser: The road into Thornwick.
  lore: Carters have used it longer than the town has had a name.
- name: The Shrine
  detail_level: stub
  kind: temple
  population: nobody
  width: 12
  depth: 10
  teaser: A stone shrine with its door standing open.
- name: Thornwick
  detail_level: stub
  teaser: A small town of three streets around a square.
  town:
    streets: 3
    square: true
- name: The Inn
  detail_level: stub
  kind: inn
  population: nobody
  width: 10
  depth: 9
  teaser: A low inn with a painted sign over its door.
- name: The Smithy
  detail_level: stub
  kind: smithy
  population: nobody
  parent: Thornwick
  width: 8
  depth: 8
  teaser: A smithy with its forge banked for the night.
connections:
- between: [The North Road, Thornwick]
  distance: adjacent
  travel_method: walking
- between: [Thornwick, The Shrine]
  distance: adjacent
  travel_method: walking
- between: [Thornwick, The Inn]
  distance: adjacent
  travel_method: walking
lib/engine_sweep/scripts/a-town-laid-out-before-it-is-written.yml

This is this PR's parity/scripts file with its header comment and why: notes put back:

# A TOWN IS LAID OUT BEFORE A WORD OF IT IS WRITTEN.
#
# Thornwick is a stub in its world file with a `town:` block (three streets
# and a square) and no footprint. Walking into it sends no place call: the
# engine lays its streets and square out as outdoor rooms in the town's
# plane, moves the road onto the square, stands The Shrine, The Inn and The
# Smithy each on a street, deals a lot onto every frontage left, and writes
# the square the player arrives on. Each street is then written as it is
# reached, with one call and no exits call, told its size, its town, which
# way each street lies and which side each building fronts it on, and named
# as a street of the town.
#
# WHAT THIS WALK PINS IS THE ROWS AND THE REQUESTS. The engine's records for
# it hold every row each step wrote and every request each step sent.
story: A Town of Three Streets
why: a town's map is laid out by the engine before any of it is written, and no street gets an exits call
steps:
- id: into-thornwick
  type: "/move Thornwick"
  why: the town is laid out and the square written, told its shape out of doors
  browser:
    token: into-thornwick
    realizes: Thornwick
    replies:
    - purpose: location
      prompt_includes:
      - 'teaser: A square in Thornwick, 22 by 22 paces.'
      - This square is 22 by 22 paces -- about 33 by 33 metres.
      - It is part of Thornwick, which is 40 by 40 paces across.
      - 'Its ways out: The Shrine, which fronts it on the north side; to the east, Thornwick room 2; to the south, Thornwick room 4; a way out to The North Road, which is outside Thornwick. Those are every way out of this square.'
      - NAME THIS SQUARE. It is one square of Thornwick.
      prompt_excludes:
      - wall
      - storey
      - one room inside
      content:
        description: A wide cobbled square with a well at its middle and the shrine's steps on its north side.
        lore: The town was laid out from this well.
        name: the well square
        items: []
        people: []
    - purpose: arrival
      unavailable: true
  expect:
    location: the well square (realized)
    exits:
    - The North Road (realized)
    - The Shrine (stub)
    - Thornwick room 2 (stub)
    - Thornwick room 4 (stub)
    here:
    - bench
    - cart
    - lamp post
    - tarpaulin
    changed: true
    refused: false
- id: along-the-first-street
  type: "/move Thornwick room 2"
  why: a street is written with one call, fronted by The Smithy and a lot, and named apart from the square
  browser:
    token: along-the-first-street
    realizes: Thornwick room 2
    replies:
    - purpose: location
      prompt_includes:
      - 'teaser: A street in Thornwick,'
      - It is part of Thornwick, which is 40 by 40 paces across.
      - The Smithy, which fronts it on the
      - Thornwick shop 1, which fronts it on the
      - to the west, the well square
      - NAME THIS STREET. It is one street of Thornwick.
      - 'Places in Thornwick that are already named, so do not reuse one: the well square'
      prompt_excludes:
      - wall
      - storey
      content:
        description: A narrow street of soot-dark fronts running off the square, a forge glowing at one door.
        lore: The smiths took this street first.
        name: the forge lane
        items: []
        people: []
    - purpose: arrival
      unavailable: true
  expect:
    location: the forge lane (realized)
    changed: true
    refused: false
- id: along-the-second-street
  type: "/move Thornwick room 3"
  why: the lots dealt onto a street are told as buildings fronting it
  browser:
    token: along-the-second-street
    realizes: Thornwick room 3
    replies:
    - purpose: location
      prompt_includes:
      - Thornwick house 1, which fronts it on the
      - Thornwick smithy 1, which fronts it on the
      prompt_excludes:
      - wall
      - storey
      content:
        description: A long street of tall narrow houses, washing strung between the upper windows.
        lore: The tanners lived here before the river moved.
        name: the tanners' row
        items: []
        people: []
    - purpose: arrival
      unavailable: true
  expect:
    location: the tanners' row (realized)
    changed: true
    refused: false
- id: along-the-third-street
  type: "/move Thornwick room 4"
  why: the inn the file joined to the town fronts this street
  browser:
    token: along-the-third-street
    realizes: Thornwick room 4
    replies:
    - purpose: location
      prompt_includes:
      - The Inn, which fronts it on the
      - the well square
      prompt_excludes:
      - wall
      - storey
      content:
        description: A short street that bends back to the square, the inn's painted sign hanging over it.
        lore: Drovers stop here on the way to market.
        name: the inn street
        items: []
        people: []
    - purpose: arrival
      unavailable: true
  expect:
    location: the inn street (realized)
    changed: true
    refused: false
- id: into-the-inn
  type: "/move The Inn"
  why: a building's door, moved onto its street, still leads in, and its rooms are told the indoor sentences
  browser:
    token: into-the-inn
    realizes: The Inn
    replies:
    - purpose: location
      content:
        description: A low timbered inn with a painted sign of a plough.
        lore: The inn is as old as the square.
        place_kind: warehouse
        parameters:
          inside: a few rooms
          storeys_above: one storey up
          storeys_below: nothing below
          danger: safe
          gradient: the same throughout
          hazard: none
    - purpose: location
      content:
        description: A taproom with a long bench under the window and a cold hearth.
        lore: The drovers drink here.
        items: []
        people: []
    - purpose: arrival
      unavailable: true
  expect:
    location: The Inn room 1 (realized)
    changed: true
    refused: false
- id: back-onto-the-street
  type: "/move the inn street"
  why: the way out of the inn leads back to the street it fronts
  expect:
    location: the inn street (realized)
    changed: true
    refused: false
- id: round-to-the-square
  type: "/move the well square"
  why: the streets join back to the square
  expect:
    location: the well square (realized)
    changed: true
    refused: false

A place with a towns row (how many streets, whether a square) is laid out
by one seeded roll: its streets and square as outdoor rooms with boxes in
the town's plane, cut into a grid walked as a serpentine like a floor's so
every street is reachable and none passes four doorways. Its ways in land
on the square; each building the file joins to it, or makes a building of
it, fronts one street (Roll::FRONTAGE_SIDE says which side); and every
frontage left is a lot, a building stub dealt from data/location/town.yml
and laid out when entered, as any building is.

It is written once with no model: by Engine::lay_out_towns as the world
is loaded, or else on the first entry. The same seed draws the same town.
No street gets an exits call. A street or square is told its plan out of
doors (size, town, which way each street lies, which side each building
fronts it on) and named with its own instruction; every other room's
requests are unchanged.

The doorway moving open_the_way_in did moves to turn::doorway, shared by
both. way_in now takes a place's first room with a box, so a lot or an
anchor of a town is never taken for one of its streets. The doctor does not warn about
a town having no layout: its streets are stood in instead.

Adds the sweep world a-town-of-three-streets and the walk
a-town-laid-out-before-it-is-written.
For a street or square of a town only, the room writer's plan block reads
"## Where This Street Is" (or Square) and says "this street" where it
said "this room", and the detail schema's name description asks what this
street is called, with "the long street" for its example, never the
town's name, and never a name already given to a place. Every other room's
requests are byte-identical.
…yout

A case each: a town's place is neither laid out as a room that stands on
its own nor warned about as a place with no layout, and the road beside it
is both, as before.
The world is the game's loader dump at its towns migration, 20261204140420,
in place of the hand-built one: the same rows and schema, with the
timestamps, the migration version and the statement order the loader
gives. The script is re-emitted by Ruby's YAML library, as every script
here is. No golden, records file or request moves.
calebl added a commit to renderedstep/server that referenced this pull request Dec 4, 2026
…ipt and world are the ones the game writes

The engine now stores parity/scripts/a-town-laid-out-before-it-is-written.yml
re-emitted, so bin/rails engine:vendored agrees byte for byte, and its
parity/worlds/a-town-of-three-streets.sql is the loader-built dump at migration
20261204140420. No engine source changed between the two pins.
@calebl
calebl merged commit 3558baa into main Dec 4, 2026
4 checks passed
calebl added a commit to renderedstep/server that referenced this pull request Dec 4, 2026
Its tree differs from c724c05 only in the engine's own CI workflow; the
goldens, scripts and vector portions here are 3558baa's, byte for byte.
calebl added a commit to renderedstep/server that referenced this pull request Dec 4, 2026
Lay out a town's streets and square before any of it is written (game half of renderedstep/engine#103)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant