Spaces:
Running
Running
Download tools/run_headless.mjs from MacroSwan/CablePilot: direct link, hf CLI and curl.
- Browser
- Download file 1.02 kB
-
https://huggingface.co/spaces/MacroSwan/CablePilot/resolve/main/tools/run_headless.mjs
- Command line
-
hf download hf://spaces/MacroSwan/CablePilot/tools/run_headless.mjs
-
curl -L -o run_headless.mjs https://huggingface.co/spaces/MacroSwan/CablePilot/resolve/main/tools/run_headless.mjs
1.02 kB
| // node tools/run_headless.mjs [seconds] : run the mission without a page and print what happened (the smoke test). | |
| import { readFileSync } from "node:fs"; | |
| import { loadModel } from "../core/model.js"; | |
| import { Mission } from "../core/mission.js"; | |
| const secs = +(process.argv[2] || 120); | |
| const m = loadModel(JSON.parse(readFileSync(new URL("../core/model.json", import.meta.url)))); | |
| const mis = new Mission(m, 0); | |
| let f, last = ""; | |
| const t0 = performance.now(); | |
| while (mis.t < secs) { | |
| f = mis.step(); | |
| const ev = f.stats.events.at(-1); | |
| if (ev && JSON.stringify(ev) !== last) { last = JSON.stringify(ev); console.log(`${ev.t.toFixed(1).padStart(6)} s ${ev.what}`); } | |
| if (f.toys.every(t => t.state === "delivered")) break; | |
| } | |
| const wall = (performance.now() - t0) / 1000; | |
| console.log(`\n${f.stats.delivered}/${f.toys.length} toys in ${f.t.toFixed(0)} s simulated, ${wall.toFixed(1)} s wall` + | |
| ` | ${f.stats.msPerPlan.toFixed(0)} ms per plan | furniture contact ticks ${f.stats.contacts} | phase ${f.phase}`); | |