@hackbuild/agents-views 0.2.12 → 0.2.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -176,6 +176,6 @@ Changes are in the repository [CHANGELOG](../../CHANGELOG.md). Code is MIT ([LIC
176
176
  | `dist/index.js` (main entry, imports external) | 6,346 bytes | 6,663 bytes |
177
177
  | `dist/agents-views.iife.js` (single file build) | 6,512 bytes | 6,837 bytes |
178
178
 
179
- Measured 2026-12-02 by `node tools/lint-packages.mjs` (gzip level 9) from the packed
179
+ Measured 2026-12-03 by `node tools/lint-packages.mjs` (gzip level 9) from the packed
180
180
  tarball. Generated from `tools/size-budget.json`; CI fails when a file moves more than
181
181
  5 percent from its row.
@@ -2104,7 +2104,7 @@ const brain = {
2104
2104
  motor.mode = 'stop'; motor.face = null; motor.ignore = null; dog.postureT.sit = dog.postureT.down = dog.postureT.bow = dog.postureT.reach = 0; dog.pawLift = 0;
2105
2105
  if (dog.org) dog.org.inert.capture();
2106
2106
  if (prev === 'sleep') { this.stage = 'awake'; SLEEP.wakeUp(); if (dog.org) dog.org.rem = 0; }
2107
- this.dwell = now + (ON('L.noise') ? ORG.exg(TV('Br.dwellMu'), 1, TV('Br.dwellTau')) : 6);
2107
+ chooseShape(); CHOOSE.setWith(RNG, b, now); this.dwell = CHOOSE.dwellUntil;
2108
2108
  }
2109
2109
  },
2110
2110
  stimulus(kind, s = 1) {
@@ -2334,7 +2334,16 @@ Object.assign(brain, {
2334
2334
 
2335
2335
  // ---- yard/dog/choice.js
2336
2336
  // dog brain: choice. Each behaviour gets a utility from drives, percepts and learning; the choice keeps
2337
- // one long enough to finish, and records why.
2337
+ // one long enough to finish, and records why. The sampled choice, its dwell and its latencies are the
2338
+ // library's Chooser, stepped on the yard's stream (RNG) so the draw order stays; the yard keeps its
2339
+ // pending switch (it also carries the cue's go function and where the head looks) and the canned
2340
+ // argmax path, whose line is drawn before its dwell.
2341
+ const CHOOSE = new HDRIVE.Chooser({ rng: () => 0.5, options: BEH });
2342
+ ENV.dispose(() => CHOOSE.free());
2343
+ const chooseShape = () => CHOOSE.configure({
2344
+ temperature: TV('Br.temp'), commitment: TV('Br.commit') * (1 + 0.35 * PT('independence')), dwellMu: TV('Br.dwellMu'), dwellTau: TV('Br.dwellTau'),
2345
+ reactMu: TV('Br.reactMu'), reactTau: TV('Br.reactTau'), reactScale: 1 - 0.12 * PT('reactivity'), sample: ON('L.sample'), noise: ON('L.noise'),
2346
+ });
2338
2347
  Object.assign(brain, {
2339
2348
  utilities() {
2340
2349
  const U = this.util, d = this.d, org = ON('L.organic');
@@ -2396,25 +2405,18 @@ Object.assign(brain, {
2396
2405
  if (this.pending) { if (now >= this.pending.at) { const p = this.pending; this.pending = null; if (p.fn) p.fn(); else { this.kindNext = p.kind; this.causeNext = p.ev; this.set(p.b, p.why); } } return; }
2397
2406
  let best = 'idle', bv = -1; for (const b of BEH) if (U[b] > bv) { bv = U[b]; best = b; }
2398
2407
  if (!ON('L.sample')) { U[this.cur] += 0.12; if (U[this.cur] >= bv) best = this.cur; if (best !== this.cur) { this.lastChoice = { at: now, U: Object.assign({}, U), cur: this.cur, best, picked: best, path: 'argmax' }; this.kindNext = 'top'; this.causeNext = this.choiceEv(best, whyOf(best), 'top'); this.set(best, whyOf(best)); } return; }
2399
- const commit = TV('Br.commit') * (1 + 0.35 * PT('independence'));
2400
- const curU = U[this.cur] + (this.done ? -1 : commit);
2401
- const lat = mul => ON('L.noise') ? ORG.exg(TV('Br.reactMu') * mul * (1 - 0.12 * PT('reactivity')), 0.06, TV('Br.reactTau') * mul) : 0;
2402
- // react: something much better that cannot wait starts after a short heavy tailed latency, while the head already turns to it
2403
- if (best !== this.cur && bv > curU + 0.05 && (REACTIVE.has(best) || (this.forced && this.forced.b === best && this.forced.until > now))) {
2404
- this.pending = { b: best, why: whyOf(best), at: now + lat(1), look: this.causeOf(best) };
2405
- { const P = this.pending, kind = this.forced && this.forced.b === best && this.forced.until > now ? 'forced' : 'react'; P.kind = kind; this.lastChoice = { at: now, U: Object.assign({}, U), cur: this.cur, curU, commit, best, picked: best, path: 'react', lat: P.at - now }; P.ev = this.choiceEv(best, P.why, kind, P.at - now); }
2406
- return;
2407
- }
2408
- // otherwise choose only when the current act is done or its dwell ran out: sample, so the best option usually but not always wins
2409
- if (this.done || now > this.dwell) {
2410
- const T = TV('Br.temp'), ex = BEH.map(b => [b, Math.exp(((b === this.cur ? curU : U[b]) - bv) / T)]);
2411
- let tot = ex.reduce((s, x) => s + x[1], 0), r = RNG() * tot, pickB = best; for (const [b, w] of ex) if ((r -= w) <= 0) { pickB = b; break; }
2412
- this.dwell = now + ORG.exg(TV('Br.dwellMu'), 1, TV('Br.dwellTau'));
2413
- if (pickB !== this.cur) this.pending = { b: pickB, why: whyOf(pickB) + (pickB !== best ? ', took a lower scored option this time' : ''), at: now + lat(0.6), look: this.causeOf(pickB) };
2414
- else this.done = false;
2415
- this.lastChoice = { at: now, U: Object.assign({}, U), cur: this.cur, curU, commit, T, probs: Object.fromEntries(ex.map(([b, w]) => [b, w / tot])), best, picked: pickB, path: 'sample' };
2416
- if (pickB !== this.cur) { const P = this.pending; P.kind = pickB !== best ? 'sampled' : 'top'; this.lastChoice.lat = P.at - now; P.ev = this.choiceEv(pickB, P.why, P.kind, P.at - now); }
2417
- }
2408
+ chooseShape();
2409
+ CHOOSE.dwellUntil = this.dwell; if (this.done) CHOOSE.markDone();
2410
+ const d = CHOOSE.updateWith(RNG, now, U, REACTIVE, this.forced && this.forced.until > now ? this.forced.b : undefined);
2411
+ this.dwell = CHOOSE.dwellUntil; this.done = CHOOSE.done;
2412
+ // react: something much better that cannot wait starts after a short heavy tailed latency, while the head already turns to it.
2413
+ // otherwise it chose only because the act is done or its dwell ran out: a sample, so the best option usually but not always wins
2414
+ if (!d.pending) return;
2415
+ CHOOSE.cancel();
2416
+ const b = d.pending.id, kind = d.reason === 'reactive' ? 'react' : d.reason;
2417
+ const P = this.pending = { b, why: whyOf(b) + (kind === 'sampled' ? ', took a lower scored option this time' : ''), at: d.pending.at, look: this.causeOf(b), kind };
2418
+ this.lastChoice = { at: now, U: Object.assign({}, U), cur: this.cur, best: d.best, picked: b, path: kind === 'react' || kind === 'forced' ? 'react' : 'sample', p: d.probability, lat: P.at - now };
2419
+ P.ev = this.choiceEv(b, P.why, kind, P.at - now);
2418
2420
  },
2419
2421
  // the sense event a choice answers: the newest sighting of the thing causeOf() turns the head to
2420
2422
  causeKey(b) { return ({ fetch: 'ball', chase: 'squirrel', greet: 'you', beg: 'you', playbow: 'you', obey: 'you', eat: 'bowl', treat: 'treat', sniff: 'scent', investigate: 'point' })[b] || null; },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hackbuild/agents-views",
3
- "version": "0.2.12",
3
+ "version": "0.2.13",
4
4
  "description": "Views that bind the agents packages to the hackbuild-ui class layer: the behaviour, utility and drive bars, the cues by acts associations table, the eye inset, and Yard, the dog simulator's stage and rack as one view. Each small view ships as a Vue component and as a custom element.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -49,7 +49,7 @@
49
49
  "@hackbuild/gait": "^0.1.0",
50
50
  "@hackbuild/tunables": "^0.1.0",
51
51
  "@hackbuild/senses": "0.1.5",
52
- "@hackbuild/drives": "0.1.6",
52
+ "@hackbuild/drives": "0.1.7",
53
53
  "@hackbuild/cameras": "^0.1.0",
54
54
  "@hackbuild/weights": "^0.1.0"
55
55
  },