Status: done (2026-11-09)
Priority: 2
Size: M
Arch: life
Phase: implement
Design ref: The player and what they see (The player’s commands, Needs and dark: Decided 7 and 8 Nov; The queue: Proposed, VB-079); Commands, time steps and views (Direct control: Decided); docs/architecture/target-v2.md, sections 4.1 (commands, source: 'player') and 4.7, principle 15; docs/review-life.md, section 2.
Goal: The player inhabits one pawn and plays it by queueing commands, which go before the pawn’s own logic; left to itself, the pawn does what its role’s automatic behaviour chooses, and the player may switch that off (Kim, 7 Nov). Needs go on: at dark it goes home unless a command of the player’s says otherwise (Kim, 8 Nov). This task is the simulation’s side; the page is VB-210. It widens “take control” (VB-076, answer 3).
Acceptance criteria:
st.player: null, or {pawn, auto, queue, refused, since} (@state documented, owned by sim/commands in src/owners.json, saved with the state; invariants in tests/lib/invariants.js: the pawn exists, the queue holds at most 8 commands, each with source player and the pawn as actor; refused is null or {verb, why, t}).sim/commands, on Sim: inhabit(st, id) (any living pawn, since whom to offer is the page’s, by Which pawn: VB-210, VB-213; auto on; records a player event, “Played by the player”), uninhabit(st) (records it), queue(st, cmd) (refused with a reason when full, when the verb does not exist or when the actor is not the player’s pawn), unqueue(st, i), setAuto(st, on).player at the next 6-minute step. A command refused then is dropped and kept in refused. A command is under way until its act ends: work while the pawn holds that job, walkTo until it arrives, goHome until it is indoors, idle until args.until.docs/review-life.md, section 2) leave the pawn alone while a player’s command is queued or under way: the idle list of the 6-minute step (src/sim/clock.js:95-104), lookUp (src/sim/jobs.js:130), callCooks (jobs.js:32), and the end of work (clock.js:40-46). With auto off and the queue empty, the first three leave it alone too, and the end of work still sends it home.tests/player.js, in npm test):
auto on and no commands, a populous tiny run over 5 game days hashes the same as the run with no player (the inhabited pawn is indistinguishable);work command is carried out before the planner’s choice, and neither lookUp nor callCooks takes the pawn off it;auto off the pawn takes no job in working hours, and goes home at the end of work;walkTo queued for 19:00 is carried out, not cut off by the end of work;st.player (tests/plaindata.js, tests/saves.js).tests/golden.json and the counters unchanged; npm run verify passes. Cost: one test of st.player per pawn at each site, no new loop.
Notes:walkTo verb accepts any tile that exists, since the planner’s idle walks sometimes end on a river tile; the player’s walks are offered only on tiles the walking rule opens (VB-209).docs/roadmap.md, section 3.2; the slices Decided by Kim): moved to slice 2, arch life (from core).QUESTION_ARCHIVE.md, “VB-079” and “VB-169”): a queue before the pawn’s own logic, the role’s automatic behaviour as the fallback with a switch, home at dark unless a command says otherwise. The draft’s panel (the list of jobs, “Walk here”) moved to VB-210, and its a.controller field to st.player, since the player is one source with one pawn at a time. Waits for VB-208, which also edits sim/jobs.debug, and work on any pawn, played or not.st.player and its operations (inhabit, uninhabit, queue, unqueue, setAuto, on Sim) are in sim/commands, with playerStep, which sim/clock calls at each 6-minute step before the agents move. The planner’s sites ask two predicates: commanded (a command queued or under way: the end of work) and unplanned (that, or auto off: the idle list, lookUp, callCooks). Reads st.agents, st.jobs and the calendar; writes st.player only, and acts through issue. No new module, no new loop: one test of st.player per pawn at each site.begun (null, then the game time it was issued at). The head stays in the queue while its act lasts, so “under way” needs no field beside the five of st.player, and the page can show it as the queue’s first line.haltForTalk verb is refused for a pawn on the player’s command, or a talk would end a player’s walk where it stood. The talk itself goes on (memories, the tie, the bubble).work already did. The planner never issued these to a working pawn.queue refuses skip: it would advance time from within a step.inhabit of a second pawn uninhabits the first, and both are recorded.WORK[1]), so the walk of the fifth test is queued for then, not 19:00.st.player are tested in tests/player.js (a queue with a command under way, the two runs hashed a day later, and a save from before the field), not in tests/plaindata.js and tests/saves.js, whose scenarios have no player; the JSON round trip there covers plain data. An older save loads with player: null.npm test (80 scripts) and npm run verify (93 scripts) pass. tests/golden.json re-recorded for two additions only, no behaviour hash changed: the key player (null) in each of the 16 state entries, and apiKeys.Sim (five new functions). Counters unchanged. tests/player.js shows teeth at each site against an unplayed control: the farmer leaves his field for the woods when the woodpile is low, and stays on the player’s command; the wife is called to cook at 14:00, and on the player’s command another of the household is.