minor cleanup

feature/modern-browsers
Inga 🏳‍🌈 1 month ago
parent 2d03fc4006
commit 945d4cea64
  1. 10
      src/lib/solver.spec.ts
  2. 4
      src/lib/tictactoe-rules.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<string, ExpectedOutcome>,
) => {
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<string, ExpectedOutcome>,
) => {
const allSolutions = computeAllSolutions(rows, columns, {
getBoardOutcome,
});
const allSolutions = computeAllSolutions(rows, columns, rules);
t.equal(allSolutions.size, expectedSolutionsCount);
t.matchStrict(
Object.fromEntries(allSolutions.entries()),

@ -87,3 +87,7 @@ export const getBoardOutcome: GameRules["getBoardOutcome"] = (board) => {
return CurrentOutcome.Draw;
};
export const rules: GameRules = {
getBoardOutcome,
};

Loading…
Cancel
Save