LordXido commited on
Commit
1aa2774
·
verified ·
1 Parent(s): a5c7121

Update web/app.js

Browse files
Files changed (1) hide show
  1. web/app.js +22 -7
web/app.js CHANGED
@@ -1,12 +1,27 @@
1
- async function runProgram() {
2
- const program = document.getElementById("program").value;
3
 
4
- const response = await fetch("/run", {
 
 
 
 
 
 
 
5
  method: "POST",
6
  headers: { "Content-Type": "application/json" },
7
- body: JSON.stringify({ program_hex: program })
8
  });
 
 
 
 
9
 
10
- const data = await response.json();
11
- document.getElementById("output").textContent = data.stdout || data.stderr;
12
- }
 
 
 
 
 
1
+ <hr>
2
+ <h3>World Simulator</h3>
3
 
4
+ <button onclick="initWorld()">Init World (50 Agents)</button>
5
+ <button onclick="stepWorld()">Step World</button>
6
+
7
+ <pre id="world"></pre>
8
+
9
+ <script>
10
+ async function initWorld() {
11
+ const res = await fetch("/world/init", {
12
  method: "POST",
13
  headers: { "Content-Type": "application/json" },
14
+ body: JSON.stringify({ agents: 50 })
15
  });
16
+ const data = await res.json();
17
+ document.getElementById("world").textContent =
18
+ JSON.stringify(data, null, 2);
19
+ }
20
 
21
+ async function stepWorld() {
22
+ const res = await fetch("/world/step", { method: "POST" });
23
+ const data = await res.json();
24
+ document.getElementById("world").textContent =
25
+ JSON.stringify(data, null, 2);
26
+ }
27
+ </script>