VB-131: Herds as household data, at the farm and in the panels
Status: done (2026-10-31, dec0f5a)
Priority: 2
Size: M
Arch: animals
Phase: implement
Design ref: Animals; docs/review-animals.md (review of 31 October 2026); answers in QUESTION_ARCHIVE.md under “VB-047: animals review”.
Goal: Each household may keep a cattle herd and a sheep flock (Agreed). Nothing in the game holds animals yet; this task makes them data, breeds them each spring, and shows them by the farms.
Acceptance criteria:
st.herds[] (src/sim/herds.js, @state documented): {id, species 'cattle'|'sheep', household, home (tile), cull[], lean, unfed}; id is the index, never reused. Cattle hold head[] of named animals {id, name, sex, born, kind 'calf'|'heifer'|'cow'|'bull'|'steer'|'ox'} (ids from st.headSeq); sheep hold counts ewes, rams, lambs (Kim, 31 Oct: named cattle, counted sheep). At most one herd per species and household.
hh.hay (hay units) and hh.larder[] (food lots, used from VB-134) on every household.
Founders (Kim, 30 Oct): the first farm keeps 2 cows, a bull and a pair of oxen, 4 ewes and a ram; the second 2 cows and 4 ewes; the third 2 cows; the lone farm none. Cows 4–8 years old, the bull 4, oxen 5 and 6, ewes 2–5, the ram 3. Hay for the spring days still in the byre plus one winter (26 stall days × 1.1) of each farm’s need.
Populous: 3 in 4 farms keep cattle: 2 cows (households of up to 5), 3 (6–7) or 4 (8–9), aged 3–10, and a heifer with chance 0.5; the farm with most cows in each village keeps the bull; a farm with 3 or more cows keeps a pair of oxen while the byre (6 cattle, a calf counting half) has room. Half the farms keep 4–8 ewes; the farm with most ewes in each village keeps a ram. Hay for the 5 stall days left at the start × 1.1. Heirs: A1 3 cows, bull, oxen, 6 ewes and a ram; A2 a cow and 3 ewes; A4 2 cows and a heifer; B1 3 cows, bull, oxen, 6 ewes and a ram; B3 a cow.
Hay a stall day (HERD.hay): cow, bull and ox 1; heifer and steer 0.6; calf 0.4; ewe and ram 0.2; lamb 0.1. winterNeed(st, hh) = 21 stall days × the herd’s daily need.
Spring (spring day 3, at the start of the day): animals age: a calf of 1 becomes a heifer, or a steer, or a young bull when no bull of the village’s reach (12 steps between houses) is under 8; a heifer of 3 a cow; a steer of 3 an ox. Cattle of 15 and more die; each adult animal dies with chance 0.03 (cattle) or 0.05 (sheep). Then a cow calves with chance 0.85 if a bull of 2 or more lives within 12 steps of her farm (Kim, 31 Oct, as P), the calf dying with chance 0.15; a ewe lambs with chance 0.9 if a ram is within reach, twins with chance 0.3, each lamb dying with chance 0.2. When the bull is another household’s, the cow’s holder remembers “Lent us the bull” (+0.05, cap +0.2, 3 years; SOCIAL.memories.bull) about the bull’s holder. One log line per farm with births.
A dissolved household’s herds go to the household its first member moves to, merged into that household’s herd of the species; with no such household they are lost.
Page: a byre (fähus) beside the cottage of a household with a herd; in the grazing season (spring day 6 to autumn day 8), 6:00 to 20:00, its animals graze around the herd’s home tile next to the farm, each with a slow wander and two poses; in the byre otherwise. Drawn only in view and above the zoom at which pawns show, from sprites that are rebuilt only when a herd changes; never through visualDirty.
The settlers panel’s household card lists the herds (“Cattle: 2 cows (Stjärna, Rosa), the bull Brante, 2 oxen, a calf · Sheep: 4 ewes, a ram, 5 lambs”) and the hay with the winter’s need.
tools/sim.js --report herds: per household its herds by kind, ages and names, hay and winter need.
checkState: every herd’s household exists and is not dissolved (or the herd is empty); counts are whole and not negative; head ids unique; every head born in the past; kinds valid; hay and larder not negative.
tests/herds.js in npm test: the founders’ herds as above; after spring day 3 of year 2 at seed 7, calves and lambs are born; no cow calves without a bull in reach.
Re-record the golden file and list the changed entries in the PR.
Notes / questions:
Kim, 31 Oct 2026: cattle as named animals inside the herd, sheep as counts; calving by a bull within 12 steps (P).
Herds stand by the farm in this task; VB-136 takes them out to pasture with a herder.
Done: src/sim/herds.js (herds, spring breeding, scenario herds, handing on, words), HERD in src/sim/rules.js, the “Lent us the bull” memory; byre, cattle and sheep art and herd sprites in the page; --report herds; tests/herds.js. At founders seed 7 (tiny map) year 2 has 5 calves and 13 lambs. Golden: every founders and heirs entry changes (new fields herds, headSeq, hh.herds, hh.hay, hh.larder; herds draw from the one random stream, so later draws shift).
Follow-up in the same pull request (1aadf14): no losses over the winter are rolled in the game’s first spring (the founders lost a cow two days after landing in about a sixth of runs), and ewes and rams lost over the winter are named in the log line.