- lessons 8 and 9 updated for the once-per-move rule, per-object negated conversion and the new ordering tests - tools/solve-spellgrid.mjs: breadth-first search over a SpellGrid level with the TypeScript reference; --never-rule and --naive - README, harness.md and the mentor skill know the new beat and module Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
24 lines
1.0 KiB
JavaScript
24 lines
1.0 KiB
JavaScript
import { test } from "node:test";
|
|
import assert from "node:assert/strict";
|
|
import { existsSync, readFileSync } from "node:fs";
|
|
import { join } from "node:path";
|
|
import { toolsDir } from "./helpers.mjs";
|
|
import { parseArgs } from "../solve-spellgrid.mjs";
|
|
|
|
test("solve_spellgrid_parses_args", () => {
|
|
assert.deepEqual(parseArgs([]), { level: "l1", dir: null, solver: [] });
|
|
assert.deepEqual(parseArgs(["l3", "--naive", "--max", "9", "--dir", "x", "--never-rule", "A IS B", "--all"]), {
|
|
level: "l3",
|
|
dir: "x",
|
|
solver: ["--naive", "--max", "9", "--never-rule", "A IS B", "--all"],
|
|
});
|
|
});
|
|
|
|
test("solve_spellgrid_solver_uses_only_the_harness", () => {
|
|
// The solver is copied into a staged reference: it may import the harness and nothing else of the engine.
|
|
const path = join(toolsDir, "solver", "solve.ts");
|
|
assert.ok(existsSync(path));
|
|
const imports = [...readFileSync(path, "utf8").matchAll(/from "([^"]+)"/g)].map((m) => m[1]);
|
|
assert.deepEqual(imports.sort(), ["./src/harness", "node:fs"]);
|
|
});
|