// Lets the autopilot play five seeded games of up to two minutes and writes the averages to // metrics.json, which the review pack shows beside canon's. import { writeFileSync } from "node:fs"; import { autopilot } from "../src/bot.js"; import { createGame, start, step } from "../src/game.js"; const seeds = [1, 2, 3, 4, 5]; let caught = 0; let seconds = 0; for (const seed of seeds) { const game = start(createGame(seed)); while (game.state === "play" && game.time < 120) step(game, autopilot(game)); caught += game.caught; seconds += game.time; } const metrics = { sparks_caught: { value: Math.round((caught / seeds.length) * 10) / 10, better: "higher" }, seconds_played: { value: Math.round((seconds / seeds.length) * 10) / 10, unit: "s", better: "higher" }, }; writeFileSync("metrics.json", JSON.stringify(metrics, null, 2) + "\n"); console.log(JSON.stringify(metrics));