@polycode-projects/the-mechanical-code-talker 5.0.28 → 5.0.30
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/corpus/conceptnet/README.md +85 -41
- package/corpus/conceptnet/commonsenseqa-seed.mjs +322 -0
- package/corpus/conceptnet/filter-dump.mjs +6 -1
- package/corpus/conceptnet/manifest.json +51 -0
- package/corpus/conceptnet/quality-filter.mjs +11 -0
- package/corpus/conceptnet/slice.jsonl +28365 -42942
- package/package.json +2 -2
- package/src/domain/agent-belief.mjs +33 -11
- package/src/domain/choice-question.mjs +125 -1
- package/src/domain/el-classify.mjs +16 -0
- package/src/domain/grammar/ace.mjs +66 -3
- package/src/domain/news-feed.mjs +30 -6
- package/src/domain/tableau.mjs +101 -14
- package/src/services/chat-page-viz.mjs +6 -3
- package/src/services/extensions.mjs +9 -2
- package/src/services/mudiii-turn.mjs +114 -3
- package/src/services/mudiii-viz.mjs +85 -1
- package/src/services/news-viz.mjs +2 -0
- package/src/services/news.mjs +3 -2
- package/src/services/predator-prey.mjs +77 -33
- package/src/surfaces/web/memory-ask-browser.bundle.js +132 -132
- package/src/surfaces/web/mudiii-browser-entry.mjs +13 -2
- package/src/surfaces/web/news-browser-entry.mjs +20 -1
- package/src/surfaces/web/planner-instances.mjs +64 -3
|
@@ -1157,42 +1157,34 @@ function itemsPayload(liveItemIds, { state, itemCellOf, roles, taken = null }) {
|
|
|
1157
1157
|
// ---- one tick --------------------------------------------------------------------
|
|
1158
1158
|
|
|
1159
1159
|
/**
|
|
1160
|
-
*
|
|
1161
|
-
*
|
|
1162
|
-
*
|
|
1163
|
-
*
|
|
1164
|
-
*
|
|
1165
|
-
*
|
|
1166
|
-
*
|
|
1167
|
-
*
|
|
1168
|
-
* `manualMoves` is the one place a visitor's own hand reaches the world:
|
|
1169
|
-
* `{ agentId: cellId }`, or `{ agentId: { cell, facing } }`, checked before
|
|
1170
|
-
* that agent's belief chain runs. A legal request moves the agent under the
|
|
1171
|
-
* `driven` rung; an illegal one is refused and that agent decides for itself
|
|
1172
|
-
* this turn, so a rejected press never freezes it. A driven turn spends a
|
|
1173
|
-
* turn like any other: the ecology pass runs, and every other agent decides
|
|
1174
|
-
* and moves in this same call.
|
|
1160
|
+
* The movement DECISION half of one tick, over `rows`/`state` as they stand
|
|
1161
|
+
* right now: fold nothing further, believe, and decide — for every live
|
|
1162
|
+
* predator and prey, exactly the rung, plan, goal, mood and belief a real
|
|
1163
|
+
* tick would assign it, with none of a tick's EFFECTS (no eating, no spawn,
|
|
1164
|
+
* no mass debit, no write). `runTownSquareTick` runs this and then applies
|
|
1165
|
+
* the effects; `agentOutlook` (mudiii-turn.mjs) runs the SAME derivation and
|
|
1166
|
+
* reads only the answers, so the two can never disagree about what an agent
|
|
1167
|
+
* currently believes or plans.
|
|
1175
1168
|
*
|
|
1176
|
-
* Returns
|
|
1177
|
-
*
|
|
1178
|
-
*
|
|
1179
|
-
*
|
|
1180
|
-
*
|
|
1181
|
-
*
|
|
1182
|
-
*
|
|
1183
|
-
*
|
|
1184
|
-
*
|
|
1185
|
-
* `
|
|
1186
|
-
*
|
|
1169
|
+
* Returns everything either caller needs to keep going: `{ lay, k, epoch,
|
|
1170
|
+
* stamp, agents, rungs, movementWrites, postMovePlacements, tickWebs,
|
|
1171
|
+
* traitRows, traitsOf, predators, prey, liveItemIds, foodIds, itemCellOf,
|
|
1172
|
+
* itemMassOf, beliefContext }`. `agents[id]` carries exactly the shape a tick
|
|
1173
|
+
* payload's own entry does before the ecology pass and mass debit finalise
|
|
1174
|
+
* it — `{ role, cell, facing, goal, mood, plan, mass: 0, belief }` — so
|
|
1175
|
+
* appending fields here would drift the tick's own frozen payload shape.
|
|
1176
|
+
* `beliefContext[id]` is `{ cell, candidates, opts, foodCandidates, foodOpts
|
|
1177
|
+
* }`, the exact inputs this agent's own belief snapshot was taken with —
|
|
1178
|
+
* `agentOutlook`'s own "how it knows" column reads it through
|
|
1179
|
+
* `beliefOriginOf`, off the same walk, so a panel's cell and its origin can
|
|
1180
|
+
* never drift apart either.
|
|
1187
1181
|
*/
|
|
1188
|
-
export
|
|
1189
|
-
layout,
|
|
1190
|
-
manualMoves = {},
|
|
1182
|
+
export function planTownSquareTurn(rows, state, {
|
|
1183
|
+
layout, config = DEFAULT_GAME_CONFIG.mudiii, roles = MUDIII_ROLES,
|
|
1184
|
+
toldFacts = [], manualMoves = {},
|
|
1191
1185
|
} = {}) {
|
|
1192
1186
|
const lay = typeof layout === "string" ? TOWN_SQUARE_LAYOUTS[layout] : layout;
|
|
1193
|
-
if (!lay) throw new Error(`
|
|
1194
|
-
const rows = readFactRows(await loadMemory(memoryDir));
|
|
1195
|
-
const state = foldTownSquareState(rows);
|
|
1187
|
+
if (!lay) throw new Error(`planTownSquareTurn: no such layout "${layout}"`);
|
|
1196
1188
|
const k = state.tickCount + 1;
|
|
1197
1189
|
const epoch = state.epoch;
|
|
1198
1190
|
const stamp = (base) => snapshotSubject(base, k, epoch);
|
|
@@ -1204,6 +1196,7 @@ export async function runTownSquareTick(memoryDir, {
|
|
|
1204
1196
|
const postMovePlacements = new Map();
|
|
1205
1197
|
const agents = {};
|
|
1206
1198
|
const rungs = {};
|
|
1199
|
+
const beliefContext = {};
|
|
1207
1200
|
|
|
1208
1201
|
const carriesPrey = config.carryPreyToWeb === true;
|
|
1209
1202
|
const buildsWebs = config.buildWebs === true;
|
|
@@ -1442,6 +1435,7 @@ export async function runTownSquareTick(memoryDir, {
|
|
|
1442
1435
|
}
|
|
1443
1436
|
|
|
1444
1437
|
const belief = beliefSnapshotFor(agentId, beliefCell, beliefCandidates, state, beliefOpts);
|
|
1438
|
+
const foodCandidates = foodVisionGated ? [] : beliefCandidates.filter((id) => foodIds.has(id));
|
|
1445
1439
|
// beliefSnapshotFor's one call covers every candidate, food included, so
|
|
1446
1440
|
// an ungated food call needs the food entries re-taken at the widened
|
|
1447
1441
|
// radius too — otherwise the panel would show a crumb null while the
|
|
@@ -1449,9 +1443,12 @@ export async function runTownSquareTick(memoryDir, {
|
|
|
1449
1443
|
// only: every key already exists from the call above, so this can never
|
|
1450
1444
|
// reorder the panel.
|
|
1451
1445
|
if (!foodVisionGated) {
|
|
1452
|
-
const foodCandidates = beliefCandidates.filter((id) => foodIds.has(id));
|
|
1453
1446
|
Object.assign(belief, beliefSnapshotFor(agentId, beliefCell, foodCandidates, state, foodBeliefOpts));
|
|
1454
1447
|
}
|
|
1448
|
+
// What a belief panel's own "how it knows" column re-derives per entry —
|
|
1449
|
+
// the exact cell and opts this agent's belief was just taken with, so
|
|
1450
|
+
// `beliefOriginOf` walks the identical rung `belief` did.
|
|
1451
|
+
beliefContext[agentId] = { cell: beliefCell, candidates: beliefCandidates, opts: beliefOpts, foodCandidates, foodOpts: foodBeliefOpts };
|
|
1455
1452
|
// A hand-picked facing beats the step it came with, which is what lets the
|
|
1456
1453
|
// page walk an agent backwards without spinning it round.
|
|
1457
1454
|
const facing = drivenFacing ?? plan[0] ?? restingFacing;
|
|
@@ -1464,6 +1461,53 @@ export async function runTownSquareTick(memoryDir, {
|
|
|
1464
1461
|
for (const id of predators) decide(id, "predator");
|
|
1465
1462
|
for (const id of prey) decide(id, "prey");
|
|
1466
1463
|
|
|
1464
|
+
return {
|
|
1465
|
+
lay, k, epoch, stamp, agents, rungs, movementWrites, postMovePlacements, tickWebs, traitRows, traitsOf,
|
|
1466
|
+
predators, prey, liveItemIds, foodIds, itemCellOf, itemMassOf, beliefContext,
|
|
1467
|
+
};
|
|
1468
|
+
}
|
|
1469
|
+
|
|
1470
|
+
/**
|
|
1471
|
+
* One full tick over `layout`: fold, believe, decide, move, run the ecology
|
|
1472
|
+
* pass, and append everything as this turn's stamped facts in a single write.
|
|
1473
|
+
*
|
|
1474
|
+
* Predators move before prey, and that ordering is load-bearing for replay: a
|
|
1475
|
+
* prey's belief is computed against the PRE-move predator positions (it reacts
|
|
1476
|
+
* to where the predator was when it looked), while eating resolves on the
|
|
1477
|
+
* post-move ones (it is caught where the predator actually ends up).
|
|
1478
|
+
*
|
|
1479
|
+
* `manualMoves` is the one place a visitor's own hand reaches the world:
|
|
1480
|
+
* `{ agentId: cellId }`, or `{ agentId: { cell, facing } }`, checked before
|
|
1481
|
+
* that agent's belief chain runs. A legal request moves the agent under the
|
|
1482
|
+
* `driven` rung; an illegal one is refused and that agent decides for itself
|
|
1483
|
+
* this turn, so a rejected press never freezes it. A driven turn spends a
|
|
1484
|
+
* turn like any other: the ecology pass runs, and every other agent decides
|
|
1485
|
+
* and moves in this same call.
|
|
1486
|
+
*
|
|
1487
|
+
* Returns `{ turn, epoch, agents, items, ecology, rungs, activeWebs, writes }`.
|
|
1488
|
+
* `agents` and `items` and `ecology` are the frozen render payload — see
|
|
1489
|
+
* townSquareTickPayload, which projects exactly those three plus the turn.
|
|
1490
|
+
* `rungs` is the decision each live agent reached this turn ("driven" for a
|
|
1491
|
+
* hand-driven move, then "chase", "evade", "forage", "wander", and —
|
|
1492
|
+
* on a cast that carries or spins webs —
|
|
1493
|
+
* "carry", "deliver", "carried", "trapped", "hold-web", "build-web"); an agent
|
|
1494
|
+
* that decided and then died still has a rung and no longer has an `agents`
|
|
1495
|
+
* entry, which is the difference between a decision and a survivor.
|
|
1496
|
+
* `activeWebs` is every unexpired predator-built web, empty on a board with
|
|
1497
|
+
* none.
|
|
1498
|
+
*/
|
|
1499
|
+
export async function runTownSquareTick(memoryDir, {
|
|
1500
|
+
layout, toldFacts = [], config = DEFAULT_GAME_CONFIG.mudiii, roles = MUDIII_ROLES,
|
|
1501
|
+
manualMoves = {},
|
|
1502
|
+
} = {}) {
|
|
1503
|
+
const rows = readFactRows(await loadMemory(memoryDir));
|
|
1504
|
+
const state = foldTownSquareState(rows);
|
|
1505
|
+
const {
|
|
1506
|
+
lay, k, epoch, stamp, agents, rungs, movementWrites, postMovePlacements, tickWebs, traitRows, traitsOf,
|
|
1507
|
+
predators, prey, liveItemIds, foodIds, itemCellOf, itemMassOf,
|
|
1508
|
+
} = planTownSquareTurn(rows, state, { layout, config, roles, toldFacts, manualMoves });
|
|
1509
|
+
const carriesPrey = config.carryPreyToWeb === true;
|
|
1510
|
+
|
|
1467
1511
|
const postMoveMass = new Map();
|
|
1468
1512
|
for (const id of [...predators, ...prey]) {
|
|
1469
1513
|
const role = agents[id].role;
|