feat: add gameplay assists and variant generator
This commit is contained in:
@@ -1,6 +1,14 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { SAMPLE_PUZZLES } from "../../src/data/samples";
|
||||
import { solveExact, solveLogically } from "../../src/solver";
|
||||
import {
|
||||
CLASSIC_SAMPLE,
|
||||
SAMPLE_CATALOG,
|
||||
SAMPLE_PUZZLES,
|
||||
} from "../../src/data/samples";
|
||||
import {
|
||||
GENERATOR_VARIANTS,
|
||||
solveExact,
|
||||
solveLogically,
|
||||
} from "../../src/solver";
|
||||
|
||||
describe("bundled original samples", () => {
|
||||
it.each(SAMPLE_PUZZLES)("ships $title as a unique puzzle", (puzzle) => {
|
||||
@@ -10,6 +18,39 @@ describe("bundled original samples", () => {
|
||||
});
|
||||
|
||||
it("solves the generated classic with the supported logical techniques", () => {
|
||||
expect(solveLogically(SAMPLE_PUZZLES[0]).status).toBe("solved");
|
||||
expect(solveLogically(CLASSIC_SAMPLE).status).toBe("solved");
|
||||
});
|
||||
|
||||
it("provides a named example for every advertised generator variant", () => {
|
||||
expect(new Set(SAMPLE_CATALOG.map(({ id }) => id)).size).toBe(
|
||||
SAMPLE_CATALOG.length,
|
||||
);
|
||||
for (const { id } of GENERATOR_VARIANTS) {
|
||||
expect(SAMPLE_CATALOG.some((entry) => entry.id === id)).toBe(true);
|
||||
}
|
||||
});
|
||||
|
||||
it("also demonstrates every supported global chess/adjacency rule", () => {
|
||||
const constraintTypes = new Set(
|
||||
SAMPLE_PUZZLES.flatMap((puzzle) =>
|
||||
(puzzle.constraints ?? []).map(({ type }) => type),
|
||||
),
|
||||
);
|
||||
expect(constraintTypes).toEqual(
|
||||
new Set([
|
||||
"diagonal",
|
||||
"anti-knight",
|
||||
"anti-king",
|
||||
"non-consecutive",
|
||||
"killer-cage",
|
||||
"thermo",
|
||||
"arrow",
|
||||
"kropki",
|
||||
"xv",
|
||||
"inequality",
|
||||
"renban",
|
||||
"palindrome",
|
||||
]),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user