Spaces:
Running
Running
Update main.js
Browse files
main.js
CHANGED
|
@@ -2,7 +2,6 @@
|
|
| 2 |
// CodexReality3D v9-HA MAIN ENGINE
|
| 3 |
// ===============================
|
| 4 |
|
| 5 |
-
// ---- Imports ----
|
| 6 |
import { initWorld, updateWorld, renderWorld } from "./world.js";
|
| 7 |
import { spawnAgent, updateAgents } from "./agents.js";
|
| 8 |
import { loadURL } from "./web.js";
|
|
@@ -28,52 +27,48 @@ function print(msg) {
|
|
| 28 |
log.scrollTop = log.scrollHeight;
|
| 29 |
}
|
| 30 |
|
| 31 |
-
// ---- Core Parameters ----
|
| 32 |
-
let Psi = 0.
|
| 33 |
-
let sigma = 0.
|
| 34 |
let running = true;
|
| 35 |
|
| 36 |
-
// ----
|
| 37 |
initWorld();
|
| 38 |
print("CodexReality3D v9-HA ONLINE");
|
| 39 |
-
print("World initialized");
|
| 40 |
print("Type `help` or natural language");
|
| 41 |
|
| 42 |
// ---- Intent Parsing ----
|
| 43 |
function parseIntent(text) {
|
| 44 |
const t = text.toLowerCase();
|
| 45 |
|
| 46 |
-
if (t.startsWith("open") || t.startsWith("browse"))
|
| 47 |
return { type: "web", url: text.split(" ").pop() };
|
| 48 |
-
}
|
| 49 |
|
| 50 |
-
if (t.includes("spawn"))
|
| 51 |
return { type: "agent" };
|
| 52 |
-
}
|
| 53 |
|
| 54 |
-
if (t.includes("brighter"))
|
| 55 |
-
return { type: "inject", value: Psi + 0.
|
| 56 |
-
}
|
| 57 |
|
| 58 |
-
if (t.includes("
|
|
|
|
|
|
|
|
|
|
| 59 |
return { type: "pause" };
|
| 60 |
-
}
|
| 61 |
|
| 62 |
-
if (t.includes("resume"))
|
| 63 |
return { type: "resume" };
|
| 64 |
-
}
|
| 65 |
|
| 66 |
-
if (t === "help")
|
| 67 |
return { type: "help" };
|
| 68 |
-
}
|
| 69 |
|
| 70 |
return { type: "llm", text };
|
| 71 |
}
|
| 72 |
|
| 73 |
-
// ----
|
| 74 |
async function route(intent) {
|
| 75 |
switch (intent.type) {
|
| 76 |
-
|
| 77 |
case "web":
|
| 78 |
print("Opening web → " + intent.url);
|
| 79 |
loadURL(intent.url);
|
|
@@ -86,7 +81,7 @@ async function route(intent) {
|
|
| 86 |
|
| 87 |
case "inject":
|
| 88 |
Psi = intent.value;
|
| 89 |
-
print("Ψ
|
| 90 |
break;
|
| 91 |
|
| 92 |
case "pause":
|
|
@@ -103,7 +98,7 @@ async function route(intent) {
|
|
| 103 |
print("Commands:");
|
| 104 |
print(" open <url>");
|
| 105 |
print(" spawn agent");
|
| 106 |
-
print("
|
| 107 |
print(" pause / resume");
|
| 108 |
break;
|
| 109 |
|
|
@@ -114,7 +109,7 @@ async function route(intent) {
|
|
| 114 |
}
|
| 115 |
}
|
| 116 |
|
| 117 |
-
// ---- Input
|
| 118 |
input.addEventListener("keydown", e => {
|
| 119 |
if (e.key === "Enter") {
|
| 120 |
const text = input.value.trim();
|
|
@@ -131,7 +126,6 @@ function loop() {
|
|
| 131 |
updateWorld(Psi, sigma);
|
| 132 |
updateAgents();
|
| 133 |
}
|
| 134 |
-
|
| 135 |
renderWorld(ctx, canvas);
|
| 136 |
requestAnimationFrame(loop);
|
| 137 |
}
|
|
|
|
| 2 |
// CodexReality3D v9-HA MAIN ENGINE
|
| 3 |
// ===============================
|
| 4 |
|
|
|
|
| 5 |
import { initWorld, updateWorld, renderWorld } from "./world.js";
|
| 6 |
import { spawnAgent, updateAgents } from "./agents.js";
|
| 7 |
import { loadURL } from "./web.js";
|
|
|
|
| 27 |
log.scrollTop = log.scrollHeight;
|
| 28 |
}
|
| 29 |
|
| 30 |
+
// ---- Core Parameters (STABLE) ----
|
| 31 |
+
let Psi = 0.03; // Intent injection (low, stable)
|
| 32 |
+
let sigma = 0.15; // Diffusion strength
|
| 33 |
let running = true;
|
| 34 |
|
| 35 |
+
// ---- Init ----
|
| 36 |
initWorld();
|
| 37 |
print("CodexReality3D v9-HA ONLINE");
|
| 38 |
+
print("World initialized (stable)");
|
| 39 |
print("Type `help` or natural language");
|
| 40 |
|
| 41 |
// ---- Intent Parsing ----
|
| 42 |
function parseIntent(text) {
|
| 43 |
const t = text.toLowerCase();
|
| 44 |
|
| 45 |
+
if (t.startsWith("open") || t.startsWith("browse"))
|
| 46 |
return { type: "web", url: text.split(" ").pop() };
|
|
|
|
| 47 |
|
| 48 |
+
if (t.includes("spawn"))
|
| 49 |
return { type: "agent" };
|
|
|
|
| 50 |
|
| 51 |
+
if (t.includes("brighter"))
|
| 52 |
+
return { type: "inject", value: Psi + 0.01 };
|
|
|
|
| 53 |
|
| 54 |
+
if (t.includes("dimmer"))
|
| 55 |
+
return { type: "inject", value: Math.max(0.001, Psi - 0.01) };
|
| 56 |
+
|
| 57 |
+
if (t.includes("pause"))
|
| 58 |
return { type: "pause" };
|
|
|
|
| 59 |
|
| 60 |
+
if (t.includes("resume"))
|
| 61 |
return { type: "resume" };
|
|
|
|
| 62 |
|
| 63 |
+
if (t === "help")
|
| 64 |
return { type: "help" };
|
|
|
|
| 65 |
|
| 66 |
return { type: "llm", text };
|
| 67 |
}
|
| 68 |
|
| 69 |
+
// ---- Router ----
|
| 70 |
async function route(intent) {
|
| 71 |
switch (intent.type) {
|
|
|
|
| 72 |
case "web":
|
| 73 |
print("Opening web → " + intent.url);
|
| 74 |
loadURL(intent.url);
|
|
|
|
| 81 |
|
| 82 |
case "inject":
|
| 83 |
Psi = intent.value;
|
| 84 |
+
print("Ψ = " + Psi.toFixed(3));
|
| 85 |
break;
|
| 86 |
|
| 87 |
case "pause":
|
|
|
|
| 98 |
print("Commands:");
|
| 99 |
print(" open <url>");
|
| 100 |
print(" spawn agent");
|
| 101 |
+
print(" brighter / dimmer");
|
| 102 |
print(" pause / resume");
|
| 103 |
break;
|
| 104 |
|
|
|
|
| 109 |
}
|
| 110 |
}
|
| 111 |
|
| 112 |
+
// ---- Input ----
|
| 113 |
input.addEventListener("keydown", e => {
|
| 114 |
if (e.key === "Enter") {
|
| 115 |
const text = input.value.trim();
|
|
|
|
| 126 |
updateWorld(Psi, sigma);
|
| 127 |
updateAgents();
|
| 128 |
}
|
|
|
|
| 129 |
renderWorld(ctx, canvas);
|
| 130 |
requestAnimationFrame(loop);
|
| 131 |
}
|