@hackbuild/agents-views 0.2.11 → 0.2.12
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/dist/yard/scope.js +21 -13
- package/package.json +2 -2
package/dist/yard/scope.js
CHANGED
|
@@ -2073,7 +2073,7 @@ const brain = {
|
|
|
2073
2073
|
d: { hunger: 0.35, fatigue: 0.15, play: 0.5, social: 0.4, curiosity: 0.5, prey: 0 },
|
|
2074
2074
|
util: {}, goal: null, goalT: 0, cmd: null, trial: null, sayT: 0, line: '...',
|
|
2075
2075
|
W: {}, N: {}, al: {}, offer: {}, trace: [], mem: [], imp: 0, visits: new Map(), barkT: 0, startle: 0, sleepWake: 0,
|
|
2076
|
-
bond: 0.5, Sp: 0.25, stage: 'awake',
|
|
2076
|
+
bond: 0.5, Sp: 0.25, stage: 'awake', hyp: [], pending: null, dwell: 0, done: false, begRel: { n: 2, ok: 1 }, prevD: {}, negT: -99,
|
|
2077
2077
|
speedMul() { return (this.cur === 'sleep' ? 0.6 : 1) * (1 - this.d.fatigue * 0.35) * (this.v < -0.3 ? 0.85 : 1) * (ON('L.organic') ? 1 + 0.08 * PT('activity') : 1); },
|
|
2078
2078
|
init() {
|
|
2079
2079
|
const saved = store.get('W', null);
|
|
@@ -2103,7 +2103,7 @@ const brain = {
|
|
|
2103
2103
|
this.cur = b; this.t = 0; this.sub = ''; this.subT = 0; this.done = false; this.say(pick(LINES[b] || ['...']), 2.6);
|
|
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
|
-
if (prev === 'sleep') { this.stage = 'awake'; if (dog.org) dog.org.rem = 0; }
|
|
2106
|
+
if (prev === 'sleep') { this.stage = 'awake'; SLEEP.wakeUp(); if (dog.org) dog.org.rem = 0; }
|
|
2107
2107
|
this.dwell = now + (ON('L.noise') ? ORG.exg(TV('Br.dwellMu'), 1, TV('Br.dwellTau')) : 6);
|
|
2108
2108
|
}
|
|
2109
2109
|
},
|
|
@@ -2124,7 +2124,7 @@ const brain = {
|
|
|
2124
2124
|
{ const az = wrapA(Math.atan2(pos.x - dog.pos.x, pos.z - dog.pos.z) - dog.yaw); this.lastHeard = { type, loud, az, t: now };
|
|
2125
2125
|
const lt = (this.heardT || (this.heardT = {}))[type]; if (loud >= 0.2 && !(lt > now - 1.5)) { this.heardT[type] = now; this.evHeard = EV.emit({ agent: 'dog', kind: 'sense', sense: 'ear', text: 'heard a ' + type + ', loudness ' + loud.toFixed(2) + ', ' + Math.abs(az * 180 / Math.PI).toFixed(0) + ' deg ' + (az >= 0 ? 'left' : 'right') }); } }
|
|
2126
2126
|
// sleepers wake to loud sounds more easily in light sleep and REM than in deep NREM
|
|
2127
|
-
if (this.cur === 'sleep') {
|
|
2127
|
+
if (this.cur === 'sleep') { if (loud < SLEEP.wakeThreshold()) return; this.wake('woken by a ' + type); }
|
|
2128
2128
|
const react = ON('L.organic') ? 0.75 - 0.08 * PT('reactivity') : 0.75;
|
|
2129
2129
|
if (loud > react) { this.startle = 0.6; this.a = clamp(this.a + 0.35, 0, 1); dog.hop = 0.03; dog.earPerk = 1; }
|
|
2130
2130
|
if (type !== 'bounce' || !ball.held) {
|
|
@@ -2249,6 +2249,11 @@ const DRIVES = new HDRIVE.Drives({ hunger: 1, fatigue: 1, play: 0.8, social: 0.9
|
|
|
2249
2249
|
const fullDrives = (h) => { const o = {}; for (const k of DRIVE_KEYS) o[k] = h[k] || 0; return o; };
|
|
2250
2250
|
const driveShape = () => DRIVES.setShape(TV('Br.driveN'), TV('Br.driveM'), TV('Br.gain'));
|
|
2251
2251
|
ENV.dispose(() => DRIVES.free());
|
|
2252
|
+
// the stage machine of one sleep (onset, nrem, rem, brief wake) from the library, stepped on the yard's
|
|
2253
|
+
// own random stream so every draw keeps its place; its seed draw is a constant, never the sim stream
|
|
2254
|
+
const SLEEP = new HDRIVE.Sleep({ rng: () => 0.5 });
|
|
2255
|
+
const sleepShape = () => SLEEP.configure({ nrem: TV('S.nrem'), rem: TV('S.rem'), wake: TV('S.wake') });
|
|
2256
|
+
ENV.dispose(() => SLEEP.free());
|
|
2252
2257
|
Object.assign(brain, {
|
|
2253
2258
|
memory(id) { const p = percepts[id]; return p && p.seen > -1e8 ? p : null; },
|
|
2254
2259
|
driveD(h) { driveShape(); return DRIVES.distance(fullDrives(h)); },
|
|
@@ -2639,19 +2644,22 @@ function sleepRun(B, dt) {
|
|
|
2639
2644
|
B.sub = 'goto'; B.stage = 'goto'; B.subT = 0;
|
|
2640
2645
|
}
|
|
2641
2646
|
if (B.sub === 'goto') { motor.mode = 'goto'; motor.target.copy(B.spot); motor.speed = 1.1; motor.stopDist = 0.25; lookForward(0.2); if (motor.done) { B.sub = 'circle'; B.subT = 0; B.turns = RNG() < 0.4 ? (RNG() < 0.19 ? 2 : 1) : 0; } return; }
|
|
2642
|
-
if (B.sub === 'circle') { motor.mode = B.turns ? 'turn' : 'stop'; motor.turnRate = 2.2; B.subT += dt; lookForward(0.3); if (B.subT > B.turns * 2.9 * (NG.active ? 1.4 : 1) + 0.3) { if (ball && ball.held) setHeld(ball, false); B.sub = 'lie';
|
|
2643
|
-
motor.mode = 'stop'; P.down = 1;
|
|
2647
|
+
if (B.sub === 'circle') { motor.mode = B.turns ? 'turn' : 'stop'; motor.turnRate = 2.2; B.subT += dt; lookForward(0.3); if (B.subT > B.turns * 2.9 * (NG.active ? 1.4 : 1) + 0.3) { if (ball && ball.held) setHeld(ball, false); B.sub = 'lie'; sleepShape(); SLEEP.lieDownWith(RNG, now - B.negT < 120); B.stage = SLEEP.stage; } return; }
|
|
2648
|
+
motor.mode = 'stop'; P.down = 1;
|
|
2644
2649
|
const neg = now - B.negT < 180; // after a bad experience: faster onset, more REM (Kis 2017)
|
|
2645
|
-
|
|
2646
|
-
|
|
2647
|
-
|
|
2648
|
-
|
|
2650
|
+
// each stage poses the dog with the time it will have reached, then the library's machine steps
|
|
2651
|
+
const s0 = SLEEP.stage, st = SLEEP.stageT + gm;
|
|
2652
|
+
if (s0 === 'onset' || s0 === 'wake') lookSalientSoft();
|
|
2653
|
+
else if (s0 === 'nrem') { dog.head.tYaw = 0.5; dog.head.tPitch = 0.62; dog.head.tRoll = 0.15; O.rem = 0; }
|
|
2654
|
+
else if (s0 === 'rem') {
|
|
2655
|
+
dog.head.tYaw = 0.5; dog.head.tPitch = 0.62; O.rem = ss(0, 0.3, st) * 0.8;
|
|
2649
2656
|
if (RNG() < dt * 0.2) { if (RNG() < 0.5) whine(dog.root.position); B.say(pick(['wf', 'mm', 'zzz', '...wuf']), 1.4); }
|
|
2650
|
-
if (B.stageT > B.stageDur) { O.rem = 0; B.stageT = 0; if (RNG() < TV('S.wake')) { B.stage = 'wake'; B.stageDur = ORG.exg(0.6, 0.2, 0.6); } else { B.stage = 'nrem'; B.stageDur = ORG.exg(TV('S.nrem'), 0.8, TV('S.nrem') * 0.6); } }
|
|
2651
|
-
} else if (B.stage === 'wake') {
|
|
2652
|
-
lookSalientSoft();
|
|
2653
|
-
if (B.stageT > B.stageDur) { const sleepy = 0.8 * B.Sp + 0.5 * (B.circ ?? 0.3); if (sleepy < 0.45) { B.wake('slept enough'); return; } B.stage = 'nrem'; B.stageT = 0; B.stageDur = ORG.exg(TV('S.nrem'), 0.8, TV('S.nrem') * 0.6); }
|
|
2654
2657
|
}
|
|
2658
|
+
sleepShape(); SLEEP.pressure = B.Sp;
|
|
2659
|
+
if (SLEEP.stepWith(RNG, gm, B.circ ?? 0.3, neg)) { B.wake('slept enough'); return; }
|
|
2660
|
+
if (s0 === 'rem' && SLEEP.stage !== 'rem') O.rem = 0;
|
|
2661
|
+
// a dog that reached its spot with L.sleep off never lay down in the machine: its stage stays as it was
|
|
2662
|
+
if (SLEEP.stage !== 'awake') B.stage = SLEEP.stage;
|
|
2655
2663
|
if (RNG() < dt * 0.1 && B.stage === 'nrem') B.say(pick(LINES.sleep), 2.5);
|
|
2656
2664
|
B.hypT = (B.hypT || 0) + dt; if (B.hypT > 0.5) { B.hypT = 0; B.hyp.push(B.stage); if (B.hyp.length > 160) B.hyp.shift(); }
|
|
2657
2665
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hackbuild/agents-views",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.12",
|
|
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.
|
|
52
|
+
"@hackbuild/drives": "0.1.6",
|
|
53
53
|
"@hackbuild/cameras": "^0.1.0",
|
|
54
54
|
"@hackbuild/weights": "^0.1.0"
|
|
55
55
|
},
|