@polycode-projects/the-mechanical-code-talker 5.0.2 → 5.0.4
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/worlds/manifest.json +9 -9
- package/corpus/worlds/shards/town-square-chapel.jsonl.gz +0 -0
- package/corpus/worlds/shards/town-square-market.jsonl.gz +0 -0
- package/corpus/worlds/shards/town-square.jsonl.gz +0 -0
- package/corpus/worlds/src/town-square-chapel.jsonl +1 -1
- package/corpus/worlds/src/town-square-market.jsonl +1 -1
- package/corpus/worlds/src/town-square.jsonl +1 -1
- package/data/mudiii-assets.json +35 -5
- package/package.json +1 -1
- package/src/adapters/memory/core.mjs +236 -18
- package/src/domain/ask-vocab.mjs +1 -1
- package/src/domain/ask.mjs +20 -10
- package/src/domain/game-config.mjs +10 -1
- package/src/domain/interpret/normalize.mjs +4 -0
- package/src/domain/memory/retraction.mjs +232 -0
- package/src/domain/p2p/sync-filter.mjs +9 -1
- package/src/domain/spider-fly-world.mjs +80 -35
- package/src/domain/syllogise.mjs +128 -75
- package/src/services/adventure-autoplay.mjs +2 -2
- package/src/services/adventure-viz.mjs +12 -7
- package/src/services/chat.mjs +42 -14
- package/src/services/mud-turn.mjs +1 -1
- package/src/services/mud-viz.mjs +11 -2
- package/src/services/mudiii-scene.mjs +199 -55
- package/src/services/mudiii-turn.mjs +82 -1
- package/src/services/mudiii-viz.mjs +17 -7
- package/src/services/p2p-room.mjs +130 -9
- package/src/services/predator-prey.mjs +524 -69
- package/src/services/spider-fly-turn.mjs +128 -56
- package/src/services/spider-fly-viz.mjs +65 -71
- package/src/services/world-teach.mjs +3 -3
- package/src/surfaces/web/adventure-browser-entry.mjs +12 -3
- package/src/surfaces/web/memory-ask-browser.bundle.js +118 -118
- package/src/surfaces/web/mud-browser-entry.mjs +10 -3
- package/src/surfaces/web/mudiii-browser-entry.mjs +3 -3
- package/src/surfaces/web/spider-fly-browser-entry.mjs +26 -22
- package/src/services/spider-fly.mjs +0 -943
|
@@ -44,7 +44,7 @@ import { waveFact, playedByFact, P2P_PREDICATES } from "../../domain/p2p/facts.m
|
|
|
44
44
|
import { relatedForTerm } from "../../domain/skos-view.mjs";
|
|
45
45
|
import { runMudTurn } from "../../services/mud-turn.mjs";
|
|
46
46
|
import { parseMudEditorText, planMudEditorSync } from "../../services/mud-editor.mjs";
|
|
47
|
-
import { mudSpeciesOf } from "../../domain/game-config.mjs";
|
|
47
|
+
import { mudSpeciesOf, DEFAULT_GAME_CONFIG } from "../../domain/game-config.mjs";
|
|
48
48
|
import { worldProvenanceTag } from "../../domain/worlds-pack.mjs";
|
|
49
49
|
import { resolveSpriteForClass, SPRITE_REGISTRY, classAncestorChain } from "../../domain/sprite-map.mjs";
|
|
50
50
|
import { resolveSpriteAsset } from "../../domain/sprite-templates.mjs";
|
|
@@ -70,8 +70,14 @@ import { graphAsk, enginePlan } from "./engine-surface.mjs";
|
|
|
70
70
|
* keyed by character id, each value `{ character, turn, autoplayTick,
|
|
71
71
|
* visitedRoomIds, turnsTaken, isOutOfPlay, outOfPlayReason }`. `snapshot()` is
|
|
72
72
|
* the one OMNISCIENT read this module exposes — the central world map's own
|
|
73
|
-
* data source, never a per-window one.
|
|
74
|
-
|
|
73
|
+
* data source, never a per-window one.
|
|
74
|
+
*
|
|
75
|
+
* `getTeachEnabled` (optional) is read fresh on every character's turn,
|
|
76
|
+
* never once at boot — the page's own teach checkbox, shared by every
|
|
77
|
+
* window since the flag is a property of the world, not of any one
|
|
78
|
+
* character. Defaults to always-off, DEFAULT_GAME_CONFIG.adventure.teach's
|
|
79
|
+
* own default. */
|
|
80
|
+
export async function createMudSession(worldPayload, { characters = [], epoch = 0, getTeachEnabled = () => false } = {}) {
|
|
75
81
|
const memoryDir = createInMemoryStore();
|
|
76
82
|
const tag = worldProvenanceTag(worldPayload.name);
|
|
77
83
|
const seedFacts = worldFactsForCast(worldPayload.facts, characters);
|
|
@@ -149,6 +155,7 @@ export async function createMudSession(worldPayload, { characters = [], epoch =
|
|
|
149
155
|
vocabHint: 'Try a world command ("dig north", "eat the carrot-1"), or ask "what food do you know about".',
|
|
150
156
|
buildExtraOptions: () => ({
|
|
151
157
|
actingSubject: character, planState: planHolder.state,
|
|
158
|
+
gameConfig: { ...DEFAULT_GAME_CONFIG, adventure: { ...DEFAULT_GAME_CONFIG.adventure, teach: getTeachEnabled() } },
|
|
152
159
|
}),
|
|
153
160
|
captureExtraState: async (result, state) => {
|
|
154
161
|
if ("planState" in result) planHolder.state = state.planState;
|
|
@@ -144,9 +144,9 @@ export async function createMudiiiSession(worldPayload, { agents = [], epoch = 0
|
|
|
144
144
|
|
|
145
145
|
/** ONE whole-world step (`runTownSquareTick`) — every live agent moves,
|
|
146
146
|
* the ecology pass runs, and the result names what happened this turn.
|
|
147
|
-
*
|
|
148
|
-
*
|
|
149
|
-
async function tick(
|
|
147
|
+
* The engine counts the turns; the result's own `turn` is what a page
|
|
148
|
+
* displays. */
|
|
149
|
+
async function tick() {
|
|
150
150
|
return runTownSquareTick(memoryDir, { layout });
|
|
151
151
|
}
|
|
152
152
|
|
|
@@ -9,10 +9,11 @@
|
|
|
9
9
|
// this game's rendering needs:
|
|
10
10
|
//
|
|
11
11
|
// - `session.tick()` runs ONE real engine turn directly
|
|
12
|
-
// (spider-fly.mjs's runSpiderFlyTick
|
|
13
|
-
//
|
|
14
|
-
//
|
|
15
|
-
//
|
|
12
|
+
// (spider-fly-turn.mjs's runSpiderFlyTick, which is the shared
|
|
13
|
+
// predator/prey engine bound to this board's cast), unmediated by chat
|
|
14
|
+
// text, so the page's own ticker gets back the structured
|
|
15
|
+
// `{ turn, agents, ecology }` shape it needs to redraw the board and the
|
|
16
|
+
// HUD's goal lines. This is the "page's ticker calls a turn" half.
|
|
16
17
|
// - `session.turn(line)` runs the FULL chat turn engine (chat.mjs's
|
|
17
18
|
// runTurn — the exact dispatch the CLI and the home page's own chat run,
|
|
18
19
|
// with the spider-fly lane already wired in), so the in-page chat dock
|
|
@@ -20,8 +21,8 @@
|
|
|
20
21
|
// bare "tick" command, and any ordinary fallthrough question ("where is
|
|
21
22
|
// the spider") exactly as the CLI does. This is the "chat dock runs
|
|
22
23
|
// runTurn" half.
|
|
23
|
-
// - `session.snapshot()` is a READ-ONLY fold (
|
|
24
|
-
//
|
|
24
|
+
// - `session.snapshot()` is a READ-ONLY fold (foldSpiderFlyState, no engine
|
|
25
|
+
// advance) so the page can resync agent
|
|
25
26
|
// positions after a CHAT-driven tick/address turn (whose reply is text,
|
|
26
27
|
// not the structured tick() shape) without double-advancing the turn.
|
|
27
28
|
// It carries no `.goal` — the chat reply text itself already narrates
|
|
@@ -39,10 +40,10 @@
|
|
|
39
40
|
// read or a registered fetch provider, neither of which this bundle carries):
|
|
40
41
|
// spider-fly-world.mjs's worldFactRows()/startSpiderFlyGame are already pure/
|
|
41
42
|
// in-memory, so the browser bootstraps the identical board directly from
|
|
42
|
-
// them. The world's rule rows (worldRuleRows) are skipped on purpose —
|
|
43
|
-
//
|
|
44
|
-
//
|
|
45
|
-
//
|
|
43
|
+
// them. The world's rule rows (worldRuleRows) are skipped on purpose — grid
|
|
44
|
+
// movement never reads them back (hand-written pathfinding over has-exit-*
|
|
45
|
+
// facts, not the taught action-rule DSL), so nothing here depends on them
|
|
46
|
+
// being loaded.
|
|
46
47
|
import { createTurnSession } from "./turn-session.mjs";
|
|
47
48
|
import { publishTmctSurface } from "./tmct-surface.mjs";
|
|
48
49
|
import { graphAsk, enginePlan } from "./engine-surface.mjs";
|
|
@@ -57,8 +58,11 @@ import {
|
|
|
57
58
|
worldFactRows, WORLD_NAME, WORLD_OPENING, cellId, parseCellId, DIRECTION_DELTA, visibleCells,
|
|
58
59
|
isLiveRenderableAgent, agentKindOf,
|
|
59
60
|
} from "../../domain/spider-fly-world.mjs";
|
|
60
|
-
import {
|
|
61
|
-
import {
|
|
61
|
+
import { DEFAULT_VISION_RADIUS } from "../../domain/agent-belief.mjs";
|
|
62
|
+
import {
|
|
63
|
+
foldSpiderFlyState, runSpiderFlyTick, spiderFlyBoard, startSpiderFlyGame, liveWebs,
|
|
64
|
+
pillsForSpiderFly, oneStepDirectionBetween,
|
|
65
|
+
} from "../../services/spider-fly-turn.mjs";
|
|
62
66
|
import { resolveSpriteForClass, SPRITE_REGISTRY } from "../../domain/sprite-map.mjs";
|
|
63
67
|
import { resolveSpriteAsset } from "../../domain/sprite-templates.mjs";
|
|
64
68
|
import { DEFAULT_GAME_CONFIG } from "../../domain/game-config.mjs";
|
|
@@ -82,12 +86,8 @@ export async function createSpiderFlySession({ flyCount = 1 } = {}) {
|
|
|
82
86
|
.filter((f) => f.predicate === "rdfs:subClassOf")
|
|
83
87
|
.map((f) => ({ subject: f.subject, predicate: f.predicate, object: f.object }));
|
|
84
88
|
|
|
85
|
-
|
|
86
|
-
const
|
|
87
|
-
for (const f of startFacts) {
|
|
88
|
-
if (f.predicate === "mgx:currently-in") initialAgents[f.subject] = { ...initialAgents[f.subject], cell: f.object };
|
|
89
|
-
else if (f.predicate === "mgx:mass") initialAgents[f.subject] = { ...initialAgents[f.subject], mass: Number(f.object) };
|
|
90
|
-
}
|
|
89
|
+
await startSpiderFlyGame(memoryDir, { flyCount });
|
|
90
|
+
const initialBoard = await spiderFlyBoard(memoryDir);
|
|
91
91
|
|
|
92
92
|
// The graph the chat dock's own ask() traverses. There is no code graph
|
|
93
93
|
// here, so it holds the LIVE BOARD instead: one individual per agent, classed
|
|
@@ -136,7 +136,7 @@ export async function createSpiderFlySession({ flyCount = 1 } = {}) {
|
|
|
136
136
|
memoryDir,
|
|
137
137
|
sessionId,
|
|
138
138
|
opening: WORLD_OPENING,
|
|
139
|
-
initial: { turn:
|
|
139
|
+
initial: { turn: initialBoard.turn, agents: initialBoard.agents, activeWebs: initialBoard.activeWebs },
|
|
140
140
|
taxonomyRows,
|
|
141
141
|
|
|
142
142
|
/** The board as a graph, as of the last refresh. Every tick moves the
|
|
@@ -149,8 +149,8 @@ export async function createSpiderFlySession({ flyCount = 1 } = {}) {
|
|
|
149
149
|
* positions and not last turn's, the same way a typed one does. */
|
|
150
150
|
refreshGraph: refreshWorldGraph,
|
|
151
151
|
|
|
152
|
-
/** Run one real engine turn directly. Returns
|
|
153
|
-
* { turn, agents, ecology } shape unmodified. */
|
|
152
|
+
/** Run one real engine turn directly. Returns the engine's own
|
|
153
|
+
* { turn, agents, ecology, activeWebs } shape unmodified. */
|
|
154
154
|
async tick() {
|
|
155
155
|
const result = await runSpiderFlyTick(memoryDir, { config });
|
|
156
156
|
turnSession.setPlanState({ spiderFly: { turn: result.turn } });
|
|
@@ -179,7 +179,11 @@ export async function createSpiderFlySession({ flyCount = 1 } = {}) {
|
|
|
179
179
|
if (!isLiveRenderableAgent(id, state)) continue;
|
|
180
180
|
agents[id] = { cell: place.cell, mass: state.mass.get(id)?.value ?? null };
|
|
181
181
|
}
|
|
182
|
-
return {
|
|
182
|
+
return {
|
|
183
|
+
turn: state.tickCount,
|
|
184
|
+
agents,
|
|
185
|
+
activeWebs: liveWebs(state.webs, state.tickCount, config.webDurationTurns),
|
|
186
|
+
};
|
|
183
187
|
},
|
|
184
188
|
|
|
185
189
|
/** The live spiderFly config this session's future tick()/turn() calls
|