LordXido commited on
Commit
e135b5d
·
verified ·
1 Parent(s): 9efd64b

Update engine.js

Browse files
Files changed (1) hide show
  1. engine.js +63 -6
engine.js CHANGED
@@ -1,6 +1,63 @@
1
- console.log("🧠 CodexWebVM Engine Active");
2
- window.onload = () => {
3
- const pulse = setInterval(() => {
4
- console.log("↻ Engine pulse... [Codex Runtime Simulation]");
5
- }, 2000);
6
- };
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ const logEl = document.getElementById("log");
2
+ const psiInput = document.getElementById("psiInput");
3
+ const svg = document.getElementById("svgEngine");
4
+
5
+ const log = msg => {
6
+ logEl.innerHTML += msg + "<br>";
7
+ logEl.scrollTop = logEl.scrollHeight;
8
+ };
9
+
10
+ // Initialize SVG Core + Nodes
11
+ function makeSVGElem(tag, attrs) {
12
+ const el = document.createElementNS("http://www.w3.org/2000/svg", tag);
13
+ for (let k in attrs) el.setAttribute(k, attrs[k]);
14
+ return el;
15
+ }
16
+
17
+ const core = makeSVGElem("circle", { cx: 0, cy: 0, r: 35, fill: "#00ffff" });
18
+ svg.appendChild(core);
19
+
20
+ const nodesGroup = document.createElementNS("http://www.w3.org/2000/svg", "g");
21
+ svg.appendChild(nodesGroup);
22
+
23
+ let nodes = [];
24
+ const NODE_COUNT = 14;
25
+ for (let i = 0; i < NODE_COUNT; i++) {
26
+ const node = makeSVGElem("circle", { r: 5, fill: "#00ffcc" });
27
+ nodesGroup.appendChild(node);
28
+ nodes.push(node);
29
+ }
30
+
31
+ let state = {
32
+ theta: 0,
33
+ iter: 0,
34
+ psiStrength: 1
35
+ };
36
+
37
+ function stepEngine() {
38
+ state.iter++;
39
+ state.theta += 0.015 * state.psiStrength;
40
+ const radius = 40 + 12 * Math.sin(state.theta);
41
+
42
+ core.setAttribute("r", 30 + 6 * Math.sin(state.iter * 0.05));
43
+
44
+ nodes.forEach((n, idx) => {
45
+ const angle = state.theta + (idx * 2 * Math.PI / nodes.length);
46
+ n.setAttribute("cx", Math.cos(angle) * radius);
47
+ n.setAttribute("cy", Math.sin(angle) * radius);
48
+ });
49
+ }
50
+
51
+ psiInput.addEventListener("keydown", e => {
52
+ if (e.key === "Enter") {
53
+ const psi = e.target.value.trim();
54
+ if (psi.length) {
55
+ state.psiStrength = Math.min(3, Math.max(0.5, psi.length * 0.1));
56
+ log(`Ψ(t) injected: "${psi}"`);
57
+ e.target.value = "";
58
+ }
59
+ }
60
+ });
61
+
62
+ setInterval(stepEngine, 40);
63
+ log("System online. Awaiting Ψ(t) …");