Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion BACKLOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ The order tasks are taken in, the first first (`node tools/backlog.js next`). So
| ID | Name | Arch | Pri | Size | Summary |
|----|------|------|-----|------|---------|
| [VB-1924](backlog/VB-1924.md)<a id="VB-1924"></a> | Plan: how a town grows before the ship | town | 1 | M | What gathers makers into a town before any ship comes, how big a town is (one of about 350 or two of about 150), and how the ship calls at a town's harbour; the pass settles the rows marked Under revision. |
| [VB-644](backlog/VB-644.md)<a id="VB-644"></a> | Dried fish for the fair: a shore head's target beyond its own need | fair | 2 | S | VB-255's fifth criterion, which waits for the fair: a head with a surplus in a shore village may take a project to dry fish beyond its need, aimed at the fair, its target in rations |
| [VB-665](backlog/VB-665.md)<a id="VB-665"></a> | Housekeeping: one scale for the simulation's meters, reviewed with Kim | - | 2 | S | Inventory every bounded or signed quantity the player is shown, its range in st and on the page; propose 0 to 100 and -100 to 100 with the motivated exceptions; questions for Kim |
| [VB-706](backlog/VB-706.md)<a id="VB-706"></a> | Standing answers where there is no tie: a stranger's yes rests on it | - | 2 | S | Standing changes nothing material: it weights customs and land disputes only. Kim, 16 Nov: where the pawn asked has no tie to the asker, standing is what it answers by. |
| [VB-707](backlog/VB-707.md)<a id="VB-707"></a> | A debtor's refusal is a breach the village knows, and costs standing | - | 2 | S | Ignoring a debt of honour costs nothing but a private memory, and sim/exchange's `propriety` has no caller. Kim, 16 Nov: a refusal by one who owes is a public breach. |
Expand Down
1 change: 1 addition & 0 deletions BACKLOG_ARCHIVE.md
Original file line number Diff line number Diff line change
Expand Up @@ -896,4 +896,5 @@ Done tasks and closed archs, moved out of `BACKLOG.md` so its tables list only o
| [VB-1495](backlog/VB-1495.md) | Repair: tests/browser-editor places no empty farm near the village | - | 1 | S | tests/browser-editor.js fails five checks, from 'no empty farm could be placed near the village' on; seen on main at 5e69f31, before VB-1491. |
| [VB-459](backlog/VB-459.md) | The harvest home: a yearly feast at the farm of a household with plenty | - | 2 | S | A new occasion kind: once a year a household above the feast's threshold asks kin and its holder's strongest ties, up to 20, to its farm when the grain is in. |
| [VB-1926](backlog/VB-1926.md) | The head's call is urgent or not: bring the load in, or drop everything | plans | 2 | M | Two calls home (Kim, 27 Nov): non-urgent, the default, brings the load in and arrives within about an hour; urgent drops the load and comes now. The head's call today is one kind, instant, and sets a load down only when the caller says so. |
| [VB-644](backlog/VB-644.md) | Dried fish for the fair: a shore head's target beyond its own need | fair | 2 | S | VB-255's fifth criterion, which waits for the fair: a head with a surplus in a shore village may take a project to dry fish beyond its need, aimed at the fair, its target in rations |
| [VB-083](backlog/VB-083.md) | Seasons on the map | roads | 3 | M | Seasonal tints and winter snow on the painted map. |
13 changes: 10 additions & 3 deletions backlog/VB-644.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
# VB-644: Dried fish for the fair: a shore head's target beyond its own need
Status: ready
Status: done (2026-11-27)
Priority: 2
Size: S
Arch: fair
Phase: implement
Design ref: design.md section 7, How a holder chooses: projects; backlog/VB-255.md
Goal: A surplus made for trade: a shore household with time to spare dries fish for the fair
Acceptance criteria:
- [ ] In a shore village (one whose households fish: `sim/drying`'s `villageFishes`), a head with a surplus (`sim/aims`, VB-255) sets a target for dried fish beyond its household's year (VB-698), aimed at the fair: its target stated in rations of dried fish (beyond the household's own year of them), its steps the rack's fishing and hanging as built, weighted by the head's lean as the other options are (goal=VB-255's menu, moved from VB-300; ref=design.md section 7, How a holder chooses: projects; Goods of place and side crafts)
- [ ] What was dried for the fair is carried there by the household's pawns and offered in its deals (VB-302); a test on a tiny shore village with `fix` on the stream `plans` (goal=a surplus made for trade, not eaten; ref=design.md, The fair: Need and Keeping goods)
- [x] In a shore village (one whose households fish: `sim/drying`'s `villageFishes`), a head with a surplus (`sim/aims`, VB-255) sets a target for dried fish beyond its household's year (VB-698), aimed at the fair: its target stated in rations of dried fish (beyond the household's own year of them), its steps the rack's fishing and hanging as built, weighted by the head's lean as the other options are (goal=VB-255's menu, moved from VB-300; ref=design.md section 7, How a holder chooses: projects; Goods of place and side crafts)
- [x] What was dried for the fair is carried there by the household's pawns and offered in its deals (VB-302); a test on a tiny shore village with `fix` on the stream `plans` (goal=a surplus made for trade, not eaten; ref=design.md, The fair: Need and Keeping goods)
- [ ] Numbers at populous small, 15 years, seeds 3, 7, 11, 42, before and after: dried fish made, taken to the fair and spoiled; hungry household-days as a description (goal=the cost of the project measured; ref=AGENTS.md, Working rules)
Seeds 7, 11, 42 (made/packed/spoiled/hungry days, before to after): 7: 34698/1200/303/512 to 34876/1550/376/612; 11: 27458/1330/127/2376 to 28065/920/263/2643; 42: 29911/1580/202/155 to 31449/1430/178/120. Seed 3 before: 26647/600/370/1903; after not taken: the run passed the 30-minute limit on a loaded machine. Packed comes home unsold nearly whole.

Noted by VB-255, 16 November 2026.
- 16 Nov 2026 (Kim, the session on the material economy): becomes the head's target for dried fish (VB-698), read against the asks (VB-699); no project of its own. Waits for VB-698 as well.
- 18 Nov 2026, amended to agree with VB-1123 (plan mode; Kim's decisions of 18 Nov): the stepping of targets leaves the game: no head, played or not, sets a target by hand, and the Plan tab's steppers go with the tab. "The head's target" in this task is the level the head reckons for itself, never one that is set. The level stays (Kim, 18 Nov): the player reckons it in their head, and a head not played reckons it as a margin it prefers over what survival needs, by its traits and skill, 1.5 times the baseline to start with. Drying fish beyond the household's own need is, in plan mode, an action at the shore placed on a member's bar, and what it brings is shown on the food's bar above the need, as surplus.

## Implementation (VB-644, 27 Nov 2026)
- Decision: no new target machinery. The fair is a menu option (`what: 'fair'`, sim/aims) beside field/claim/barn: no project plan, like the trial. Taken, `plan.aim.fair` (rations beyond the year) is added to the dried fish target by `goodTargets` (sim/seasonal); the yearly look lets it go or takes it again. Weight: base times the head's lean (`plan.head.bias.hours`), as the asks' reckoning.
- Amount: the spare hands' bound (`most`, sim/targets) within a back load (`Asks.carried`), whole rations. Steps are the rack's own (rackfish and dry kinds read the target); the dealer packs it by `fair.loadUp` as any larder good.
- Adding the option to shore menus changes the plans stream's draws there: seeds differ from before in shore villages.
- Undone: dried fish seldom changes hands at the fair (packed equals brought home in the runs), so the surplus mostly waits held; a better seller (asks for dried fish are rare) is for the tuning run.
1 change: 1 addition & 0 deletions docs/tuning.md
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ Both references meet the target (median at least 1%), so nothing below is urgent
| the shortfall that makes a household want a servant (plan.fit.servant, sim/levies fit) | any season short by more than 1e-9 hours takes a servant at the autumn round, bypassing SERVICE.short | not measured; review F5: a household a few hours short in one spring week takes one | a bar: the shortfall at least a servant's season of levy hours, or SERVICE.short kept | VB-1778 |
| the labour budget against the season's daily work (sim/levies fit, sim/estimate dailyLeft) | hungry household-days, populous seeds 7/11/42, 10 years (tools/gate.js) | 324/153/456 against the base's 145/76/153; founders 0/5/0 unchanged; no deaths by hunger | find which answer (targets lowered, hours demanded) the new shortfalls bring and tune its bar, or the levy rows, so the whole season's work fits a household that fed itself before | VB-1906 |
| populous seed 7 hunger after VB-1767 | hungry household-days in the gate's populous 7 run (10 years) | 391 against the base's 145 (populous 11: 58 vs 76; populous 42: 88 vs 153; no hunger deaths) | look at the keep's ask (only its season plan's shortfall, most at summer's turn) and the levied's naming in populous 7 before tuning OUTER | VB-1767 |
| AIMS fair weight and fairDried amount (sim/aims) | how much dried fish a shore head with a surplus makes for the fair | populous small 15y: little dried fish changes hands (packed comes home), nobody asks for it | leave until dried fish has demand at the fair | VB-644 |

## Mechanisms on their way that move the same numbers

Expand Down
32 changes: 31 additions & 1 deletion src/sim/aims.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,15 @@ VB['sim/aims'] = (() => {
hands: VB['sim/rules'].AGES.hands,
});
const KIND = Object.freeze(['field', 'claim', 'heir', 'barn', 'trial']);
const Targets = VB['sim/targets'];
// @state plan.aim (a household's standing plan; VB-255): absent until its first review after an autumn count, then {year (the year of cal
// of its last yearly look at the surplus), surplus (what that look, or the last one after a project ended, found), again (true when a
// project of the head's ended: it looks again at its next review), project (the id of the head's project plan under way, or null), what
// (its kind of KIND, or null), since (game hours: when it was taken, or null), shortSince (game hours since the food has stood under the
// surplus while it is under way, or null), trial (absent, or the crop of a trial taken: VB-351; it has no project plan, and ends when
// a field is sown with the crop out of turn, or the seed is gone)}. Written only here.
// a field is sown with the crop out of turn, or the seed is gone), fair (absent, or the rations of dried fish beyond its household's year
// that the head took for the fair at its last yearly look: VB-644, no project plan; sim/seasonal's goodTargets adds it to the target)}.
// Written only here.
// The household's working hands: members alive, of AIMS.hands' ages, not retired (as sim/agents counts their work: household.workHours).
function handsOf(st, hh) {
let n = 0;
Expand Down Expand Up @@ -139,8 +142,20 @@ VB['sim/aims'] = (() => {
if (!f.barn && !f.booth && st.villages[f.village].wood.length) out.push({ what: 'barn', weight: AIMS.base });
const crop = trialCrop(st, plan, hh, f);
if (crop) out.push({ what: 'trial', weight: AIMS.base * ambition, crop });
// dried fish for the fair (VB-644): in a village by fishing water, rations beyond the household's year that its spare hands can fish and
// hang and a back load carries; no project plan, a target (VB-698), weighed by the head's lean as the asks' reckoning is (VB-699)
const n = fairDried(st, hh, f);
if (n > 0) out.push({ what: 'fair', weight: AIMS.base * (plan.head ? plan.head.bias.hours : 1), n });
return out;
}
// The rations of dried fish beyond its year that household hh can make for the fair: what its spare hands bring (sim/targets' bound), within
// a back load (sim/asks' carried); 0 where its village does not fish.
function fairDried(st, hh, f) {
if (!VB['sim/drying'].villageFishes(st, st.villages[f.village])) return 0;
const M = Targets.MADE.get('dried fish'),
most = M.most(st, hh, f, Targets.hands(st, hh) * Targets.TARGET.spareHours);
return Math.floor(Math.min(most, VB['sim/asks'].carried('dried fish')));
}
// A trial (VB-351; design.md, How the head chooses what to sow: a trial is a project): a good head (sim/rotations' tierOf) whose store
// holds a field's seed of a crop its farm's rotation does not grow tries it on one field; the first such crop of CROPS, or null.
function trialCrop(st, plan, hh, f) {
Expand Down Expand Up @@ -270,9 +285,24 @@ VB['sim/aims'] = (() => {
if (yearly) B.year = c.year;
B.again = false;
B.surplus = surplusOf(st, plan, hh, f, c).all;
if (yearly && B.fair) {
delete B.fair; // each year's look takes the head's fair project again or lets it go
Seasonal.goodTargets(st, plan, hh);
}
// the head's prudence, its own choice and not a refusal (VB-1668): its yearly look begins a large project only with none under way
if (!B.surplus || Projects.ownOf(st, hh.id) || Projects.heldOff(st, hh.id)) return;
const o = choose(st, menu(st, plan, hh, f));
if (o && o.what === 'fair') {
B.fair = o.n;
Seasonal.goodTargets(st, plan, hh);
tell(
st,
hh,
'projectTaken',
`${fullName(st.pawns[hh.holder])} of ${f.name} sets out to dry ${o.n} rations of fish for the fair.`,
);
return;
}
if (!o || !begin(st, hh, o)) return;
if (o.what === 'trial') {
Object.assign(B, { trial: o.crop, what: 'trial', since: st.t });
Expand Down
4 changes: 3 additions & 1 deletion src/sim/seasonal.js
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,9 @@ VB['sim/seasonal'] = (() => {
// beyond the need, what the head reckons it can place of the asks it read (sim/asks, VB-699: plan.placed)
level =
(n === undefined || n === null ? Targets.need(st, hh, good) : n) +
((plan.placed && plan.placed.goods[good]) || 0),
((plan.placed && plan.placed.goods[good]) || 0) +
// and, for dried fish, what its head took for the fair as a project of its own surplus (sim/aims, VB-644)
(good === 'dried fish' && plan.aim && plan.aim.fair ? plan.aim.fair : 0),
G = targetOf(plan, good);
if (G) G.level = level;
else {
Expand Down
61 changes: 61 additions & 0 deletions tests/aims.js
Original file line number Diff line number Diff line change
Expand Up @@ -277,3 +277,64 @@ const roofOn = (st, hh, p) => {
assert.deepStrictEqual(checkState(st), [], 'invariants after the drop');
}
console.log("aims ok: surplus, menu, choice, barn and its halvings, drop after a season; the heir's plot passes to the village; timber kept");

// VB-644: dried fish for the fair. A head with a surplus in a village by fishing water may take, as its project, rations of dried fish beyond
// its household's year: a target (no project plan), the menu's option 'fair' weighed by its lean, the steps the rack's own; in a village
// with no shore, none. What was dried beyond the year is packed for the fair by the household's dealer, to be offered in its deals.
{
const shore = Array.from({ length: 14 }, (_, i) => (i < 3 ? '~'.repeat(20) : i < 5 ? 'FFFFFFFFFFFFFFFFFFFF' : '....................'));
const mk = (rows) => tinyState(tinyWorld(rows), [{ at: [9, 8], farms: 2, sizes: [5, 4] }], { seed: 4, herds: true });
const set = (st) => {
const c0 = cal(st.t);
Sim.advance(st, ((HERD.countDay + 1 - c0.doy + 48) % 48) * DAY);
const hh = st.households[0], f = st.farmsteads[hh.farmstead], plan = st.plans.households.get(hh.id), c = cal(st.t);
for (const p of [...Projects.projectsOf(st, 'household', hh.id)]) VB['sim/projectplans'].drop(st, p);
Stores.put(st, hh, Stores.grainGood('barley'), 5000, 'harvest');
Stores.put(st, hh, 'wood', 200, 'firewood');
hh.hay = TG(plan).hayWinters * VB['sim/herds'].winterNeed(st, hh) + 5;
TG(plan).fields = f.fields.length; // lint-allow: owner the test meets the fields' target
TG(plan).workable = f.fields.length + 2; // lint-allow: owner and gives hands for more
hh.workHours = [c.year * 4 + c.season, 0, 0]; // lint-allow: owner idle all the last season
delete plan.aim; // lint-allow: owner no look at the surplus yet
return { st, hh, f, plan, c };
};
const D = VB['sim/drying'], Targets = VB['sim/targets'], Asks = VB['sim/asks'], Fair = VB['sim/fair'];
const { st, hh, f, plan, c } = set(mk(shore));
assert.ok(D.villageFishes(st, st.villages[f.village]), 'a shore village');
const menu = A.menu(st, plan, hh, f), o = menu.find((x) => x.what === 'fair');
assert.ok(o && o.n > 0, 'the fair is on the menu of a shore head with a surplus');
assert.strictEqual(menu[menu.length - 1].what, 'fair', 'the last option');
assert.ok(near(o.weight, plan.head.bias.hours), "weighed by the head's lean");
assert.ok(o.n <= Asks.carried('dried fish'), 'within a back load');
const need = Targets.need(st, hh, 'dried fish');
st.rng.plans.fix = 0.999999; // the last option
P.reviewed(st, plan, c);
delete st.rng.plans.fix;
assert.strictEqual(plan.aim.fair, o.n, 'the head took the fair');
assert.strictEqual(plan.aim.project, null, 'no project plan');
assert.strictEqual(Projects.ownOf(st, hh.id), null);
assert.strictEqual(Targets.target(st, hh, 'dried fish'), need + o.n, 'its target for dried fish: the year and the fair');
assert.deepStrictEqual(checkState(st), [], 'invariants with the fair taken');
// the rack's fishing is posted while less than the target is held, though the year's need is held
hh.larder.length = 0; // lint-allow: owner a test empties the larder
VB['sim/larder'].addFood(st, hh, 'dried fish', need);
const posted = [];
VB['sim/kinds'].KINDS.rackfish.available(st, hh, f, { season: 1, sday: 3, doy: 15, day: 15, hour: 8 }, (k) => posted.push(k));
assert.strictEqual(posted.length, 1, 'beyond its year, the household still fishes for the rack');
// held, the dealer of the household packs it for the fair: carried by its pawn, to be offered in its deals
VB['sim/larder'].addFood(st, hh, 'dried fish', o.n);
const dealer = hh.members.find((id) => st.pawns[id].alive && VB['sim/records'].age(st, st.pawns[id]) >= 14);
VB['sim/events'].emit(st, 'gatheringSetOut', { pawn: dealer, household: hh.id, until: st.t + 3 * DAY });
const load = st.pawns[dealer].load;
assert.ok(load && Fair.held(load, 'dried fish') > 0, 'the household\'s pawn carries dried fish to the fair');
assert.ok((hh.ledger || []).some((e) => e.kind === 'fair' && e.good === 'dried fish' && e.n < 0), 'packed through the stores');
// a later year's look with no surplus lets it go
plan.aim.year = c.year - 1;
hh.workHours = [c.year * 4 + c.season, 1e6, 1e6]; // lint-allow: owner no idle hands: no surplus
P.reviewed(st, plan, c);
assert.strictEqual(plan.aim.fair, undefined, 'let go with the surplus');
assert.strictEqual(Targets.target(st, hh, 'dried fish'), need, 'its target back to the year');
// a village with no shore: no option
const dry = set(mk(Array.from({ length: 14 }, (_, i) => (i < 2 ? 'FFFFFFFFFFFFFFFFFFFF' : '....................'))));
assert.ok(!A.menu(dry.st, dry.plan, dry.hh, dry.f).some((x) => x.what === 'fair'), 'no fair fish where nobody fishes');
}
2 changes: 1 addition & 1 deletion tests/lib/invariants.js
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ function checkState(st) {
// VB-255: the head's projects: its record absent, or its year, its project under way (a live project plan of the household's,
// with its kind) or none, and the times not after now
const Ai = plan.aim, CROP_LIST_I = globalThis.VB['sim/stores'].CROP_LIST;
if (Ai !== undefined && !(Number.isInteger(Ai.year) && typeof Ai.surplus === 'boolean' && typeof Ai.again === 'boolean' &&
if (Ai !== undefined && !(Number.isInteger(Ai.year) && typeof Ai.surplus === 'boolean' && typeof Ai.again === 'boolean' && (Ai.fair === undefined || Ai.fair > 0) &&
(Ai.trial !== undefined ? Ai.project === null && Ai.what === 'trial' && Ai.since <= st.t && (CROP_LIST_I || []).includes(Ai.trial) // VB-351: a trial, no plan
: Ai.project === null ? Ai.what === null && Ai.since === null && Ai.shortSince === null
: globalThis.VB['sim/aims'].KIND.includes(Ai.what) && Ai.since <= st.t && (Ai.shortSince === null || Ai.shortSince <= st.t) &&
Expand Down
Loading