From 945d4cea64c3fcf7d278f25d764d1a1480eb422c Mon Sep 17 00:00:00 2001 From: Inga Date: Sun, 17 Nov 2024 00:38:42 +0000 Subject: [PATCH] minor cleanup --- src/lib/solver.spec.ts | 10 +++------- src/lib/tictactoe-rules.ts | 4 ++++ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/lib/solver.spec.ts b/src/lib/solver.spec.ts index 1dad996..234b94c 100644 --- a/src/lib/solver.spec.ts +++ b/src/lib/solver.spec.ts @@ -2,7 +2,7 @@ import t from "tap"; import { ExpectedOutcome, FinalOutcome, Player } from "./datatypes.ts"; import { computeAllSolutions, getPreferredNextOutcome } from "./solver.ts"; -import { getBoardOutcome } from "./tictactoe-rules.ts"; +import { rules } from "./tictactoe-rules.ts"; void t.test("getPreferredNextOutcome", async (t) => { const nextOutcomes: ExpectedOutcome[] = [ @@ -102,9 +102,7 @@ void t.test("computeAllSolutions", async (t) => { expectedSolutions: Record, ) => { t.matchOnlyStrict( - Object.fromEntries( - computeAllSolutions(rows, columns, { getBoardOutcome }).entries(), - ), + Object.fromEntries(computeAllSolutions(rows, columns, rules).entries()), expectedSolutions, ); }; @@ -115,9 +113,7 @@ void t.test("computeAllSolutions", async (t) => { expectedSolutionsCount: number, expectedSolutionsIncomplete: Record, ) => { - const allSolutions = computeAllSolutions(rows, columns, { - getBoardOutcome, - }); + const allSolutions = computeAllSolutions(rows, columns, rules); t.equal(allSolutions.size, expectedSolutionsCount); t.matchStrict( Object.fromEntries(allSolutions.entries()), diff --git a/src/lib/tictactoe-rules.ts b/src/lib/tictactoe-rules.ts index 31b79f1..9691de9 100644 --- a/src/lib/tictactoe-rules.ts +++ b/src/lib/tictactoe-rules.ts @@ -87,3 +87,7 @@ export const getBoardOutcome: GameRules["getBoardOutcome"] = (board) => { return CurrentOutcome.Draw; }; + +export const rules: GameRules = { + getBoardOutcome, +};