Status: done (2026-10-30)
Priority: 2
Size: M
Design ref: Economy and jobs (Goods and the farming year: Making a field); Settlements and look. Kim, 30 Oct 2026 (VB-080, question 2): every generator places a farm’s fields as one contiguous shape within 4 tiles of the house, not necessarily next to it; a field made in play prefers to touch that block.
Goal: placeFields (src/sim/layout.js) takes the most fertile free tiles among the house’s neighbours, then at 2 steps, so a farm’s fields can be scattered around the house with gaps between them. chooseTile (src/sim/fields.js) picks each new field on its own, by fertility, stones and distance within REACH (4). Fields should lie together, as an infield, which also gives each farm a simpler fence.
Acceptance criteria:
placeFields(w, used, house, n, avoid) returns n free farmable tiles that form one connected group (each touches another of them, by hex neighbour), all within 4 steps of the house over land; they need not touch the house. Among the groups it finds, it takes the one with the highest summed fertility less 0.15 per step from the house to each tile, found by growing groups from each candidate tile within 4 steps, taking the best neighbouring tile each time. It returns null when no group of n exists, as today.chooseTile decides their layout: it scores a tile that touches one of the farm’s fields (or its project) +1, so a new field joins the block when a tile within REACH touches it; only when none does may it start a new block.makeFence) still close around each infield.placeFields also leaves out the yards (tiles next to any house or green) and the house’s own neighbours, so fields lie 2 to 4 steps out; reach is measured by walking (VB-112). addField keeps the fourth field in the block and out of the yards.chooseTile (founders) scores a tile touching one of the farm’s fields 1 better, and never takes one next to a house, a green or a planned plot house (builtTiles in src/sim/fields.js).tests/layout.js (in npm test): populous medium seeds 7 and 42 and heirs seed 7, every farm’s fields one block within 4 walking steps, next to no house or green. Founders at seed 7 after 10 years: 4 of 4 farms have their fields in one block.makeFence goes round the whole village (VB-113); the jsdom smoke test passes and the screenshots show it closed.