village-builder

VB-212: The moving round’s acts: the player’s wish stands in for its pawn’s own

Status: done (2026-11-10) Priority: 2 Size: M Arch: life Phase: implement Design ref: The player and what they see (The round’s acts: Decided, 8 Nov: “the same rules should apply to player controlled pawn as to other pawns to the extent possible”; Marriage: Decided, 8 Nov); Inheritance and expansion (Leaving home, Empty farms, Households short of people, Moving to new land); docs/review-life.md, section 3. Goal: The big acts of a life (moving out, claiming an empty farm, going into service, settling new land) happen at the moving round, by the round’s rules. Where the round asks what a pawn itself wants, the player’s wish should stand in, and the round should decide as it does for anyone, at the round. Acceptance criteria:

Survey (10 Nov 2026): every place the moving round reads what a pawn wants. st.demand is counted once a round by countDemand (src/sim/heirs.js:391) from staysWhy (src/sim/heirs.js:379); everything else reads st.demand.

Place What it reads Sorted as The player’s wish
staysWhy, src/sim/heirs.js:380-381 alive, 18 or more, not retired, not a holder nor married to one rule none
staysWhy, src/sim/heirs.js:382 first heir to the farm at home (placeIfMarried) the pawn’s own wish: it waits for the farm out: true moves out all the same
staysWhy, src/sim/heirs.js:383 restoring a farm it claimed (claimOf) rule none
staysWhy, src/sim/heirs.js:384 (new) the pawn’s own wish out: false stays, true wants out
staysWhy, src/sim/heirs.js:385-386 first heir to a farm elsewhere the pawn’s own wish out: true moves out all the same
claimants, src/sim/farmclaims.js:64-90 (the round’s claimFarms, :124; claimableFarm, :129) who may claim (barred: no farm, claim, plot or ward), within reach, the custom’s order, couples first, the oldest rule none
claimants, src/sim/farmclaims.js:72 which farm it would take: any it may the pawn’s own wish claim: a farm id (only that one) or false (none)
handOn, src/sim/heirs.js:327-332 the landless adult of the village who has waited longest takes a farm handed on at a marriage rule (who), the pawn’s own wish (that it takes it) claim: as above, the farm being the one handed on
takeServants, src/sim/service.js:93 unfit (free to move, unmarried, of serving age), handsLeft, distance, the order rule none
takeServants, src/sim/service.js:93 that it would serve: anyone who wants out would the pawn’s own wish serve: false declines; true is as the pawn would
startPlots and the cottage, src/sim/expansion.js:92, :143; plotPrio, src/sim/jobs.js:78 a plot for those who wait in st.demand rule: it follows from wanting out through out only
careForOrphans, src/sim/service.js:44 a landless adult of the ward’s kin becomes guardian rule (a duty to kin) through out only
the handover’s weighing, src/sim/lifecycle.js:169 whether anyone of the village waits for land rule through out only
settle, src/sim/settle.js:215 the draw by rounds waited (SETTLE.chance) not sorted: QUESTIONS.md, VB-212, question 1; left a rule through out only
partyOf, src/sim/settle.js:53 a waiting sibling “chooses to follow” (SETTLE.follow) not sorted: question 2; left a rule through out only
partyOf, src/sim/settle.js:47; claimants, src/sim/farmclaims.js:89; startClaim, :98 a couple moves as one, and one of them claims for both not sorted: question 3; left a rule none: the spouse’s wish is its own
the marriage round, src/sim/lifecycle.js:145-200 whom it marries and where the couple lives unchanged here (VB-233) none

The wishes only narrow (Kim, 10 Nov): out alone decides st.demand; a wish for a farm or against service does not put an heir into it.

Implementation (10 Nov 2026): st.player.wishes ({out, claim, serve}, each null at inhabit), set by Sim.wish(st, kind, value) (wish in src/sim/commands.js, which checks the shape only: the round decides), kept until changed, and read through wishOf(st, id, kind) in src/sim/records.js (below sim/farmclaims in load order, which sim/commands is not) at the four points the survey names: staysWhy, claimants, handOn, takeServants. staysWhy takes the wish as its last argument, so Sim.opportunities can ask what the pawn itself would do: the played pawn’s leave carries own, and each of the round’s acts says what bars it now, the wishes counted in. The pawn panel (roundBox in src/page/play.js) offers the three wishes under “At the moving round” with those reasons, and says that a couple moves together. An older save’s player loads with no wishes (src/sim/saves.js); invariants in tests/lib/invariants.js.

Impact note: reads st.player in sim/records (the reader), and through it in sim/heirs, sim/farmclaims and sim/service; writes st.player.wishes only in sim/commands, its owner. No new module; one new state field, saved with the player. New coupling: the three round modules read the player’s wishes, through one function. No abstraction added: a verb would not fit, since a wish is not an act and is not checked against the rules when made.

Cost: wishOf is two comparisons a call, at the round only: once per living pawn in countDemand, once per claimant candidate, once per waiting adult in takeServants. Nothing is added to a step.

Validation (10 Nov 2026): npm run verify passes (98 scripts); npm test passes (84 scripts, with the new tests/wishes.js: the criteria’s four cases, a farm wished for and none, service declined, no wishes hashing as no player over a round and a day, saved and loaded). Golden file: the behaviour entries are unchanged; apiKeys: Sim changes, for the new Sim.wish. tests/browser.js sets a wish from the panel and takes it back. No numbers before and after: with no player, and with a player who makes no wish, the run is unchanged.