Repository navigation
Lay out a town's streets and square before any of it is written - #103
Merged
Merged
Conversation
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
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)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes
A place with a
townsrow 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:interior::Builder). Every street is reachable from the square, no street passes four doorways, and the square comes first.turn::doorway::move_doorway, now shared withopen_the_way_in).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.data/location/town.yml: house 10, shop 3, workshop 2, smithy 1, inn 1, warehouse 1.{town} {kind} {n}.It is written once, with no model (
turn::town). Either the world is loaded throughEngine::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_intakes 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_outskips a town, and so doesreach::findings, which therefore does not warn that a town has no layout: its streets are stood in instead. Thelayoutandreachvector portions each gain a case and say so in their notes.store::TOWNSis an optional table, likefloors: 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 parityrewrote 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 Placeand in plan clauses.{A|An} {kind} in {town}, {width} by {depth} paces.For example,A square in Thornwick, 22 by 22 paces.{A|An} {kind} in {town}.For example,A house in Thornwick.{town} {kind} {n}. For example,Thornwick shop 1.{town} room {n}. That format is unchanged.The plan block, for a street or square only. The header and its paragraph:
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 becomesIt 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} sidea way out to {place}, which is outside {town}. This clause is unchanged; building rooms already get it.Nothing leads out of this {kind} yet.As sent for the square of the sweep world:
The naming line, which replaces
NAME THIS ROOMfor a street or square. These are the exact line breaks: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
namedescription, for a street or square only (schemas::detail_outdoors). It is one line:The narrator. In a street, the narrator (
moment.rsnarration context) reads the plan sentences above, and the lot names and street placeholders in its existingWays out of here:line. It reads nothing else new.Tests
tests/town.rsuses the new world, A Town of Three Streets. It has: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 outdoornamedescription. The Inn's room, in the same town, carries the indoor ones byte for byte.src/town.rshas 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
parity/worlds/a-town-of-three-streets.sql.parity/scripts/a-town-laid-out-before-it-is-written.yml, listed inPASSINGwith a golden and a records file. The walk: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 thePASSING_WITH_RUNNERscripts, the same as on main.fight --check sim: all 10 fight goldens agree.rake eval:realizationbefore 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.create_towns. This is the shapestore::OPTIONAL_SHAPESpins:20261204140420, and the world dump carries it.Townwithbelongs_to :location, andLocation has_one :town, dependent: :destroy.streetsas an integer of at least 0. The engine reads at most 100 (town::MOST_STREETS) and always lays out at least one street.town: {streets:, square:}on a location, loaded likefloor:(load_towns!), and add it to the exporter.floor:, and no town with aparent. The footprint is optional: the engine keeps a given one when it holds the grid, and sizes one from the street count otherwise.RenderedStep.lay_out_towns(database, story_id, dry_run)overEngine::lay_out_towns, withPlaythrough::RustEngine.lay_out_towns.Update::Steps::LayOutTownsthat runs beforeLayOutRooms.WorldSeed::Loader#lay_out_rooms!must skip a town (next if room.town.present?), mirroringlayout::lay_out. The loader does not lay the town out in its own transaction. The update step or the first walk-in does that.Location::Interior.entry_roomhas to take the first child with a box, mirroringway_in(src/turn.rs).laid_out?needs the same change wherever it decides a way in.EngineDatahas to pick up the new filelocation/town.test/models/engine_data_test.rblists it next tolocation/size.Engine::lay_out_townsreports these asNone.lib/engine_sweep/worlds/a-town-of-three-streets.ymlandlib/engine_sweep/scripts/a-town-laid-out-before-it-is-written.yml. Both are below.ext/renderedstep/Cargo.tomlto this PR's merge commit.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 thelayoutandreachvector portions.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_COMMITin.github/workflows/ci.ymlnamesad16f9f, the head of renderedstep/server#402. That commit carries items 1 to 10 and pins this branch atc724c05, so CI plays the new walk through the game's runner and gates.lib/engine_sweep/worlds/a-town-of-three-streets.ymllib/engine_sweep/scripts/a-town-laid-out-before-it-is-written.ymlThis is this PR's
parity/scriptsfile with its header comment andwhy:notes put back: