Spaces:
Sleeping
Sleeping
Update web/app.js
Browse files- web/app.js +22 -7
web/app.js
CHANGED
|
@@ -1,12 +1,27 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
|
| 4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
method: "POST",
|
| 6 |
headers: { "Content-Type": "application/json" },
|
| 7 |
-
body: JSON.stringify({
|
| 8 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
-
|
| 11 |
-
|
| 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>
|