/
docNemo
/
tactic-hack-core
Обзор
Документация
Войти
/
docNemo
/
tactic-hack-core
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
main
src/deduction.test.ts
44 строки
2 KB
neo
Implement rules engine: geometry, placement, attack reducer, replay, projection, deduction, protocol types
19 июл 2026, 00:03
19 июл 2026, 00:03
d1403fb
Код
Авторство
О чём код?
import { describe, expect, it } from "vitest"; import { computeDashedLines } from "./deduction.js"; import { OpenedCell } from "./types.js"; describe("computeDashedLines", () => { it("цифра полностью объяснена — пунктир по остальным осям", () => { // (9,9) с цифрой 1; уничтоженный корабль (4,9) в том же столбце const opened: OpenedCell[] = [{ cell: { row: 9, col: 9 }, digit: 1 }]; const result = computeDashedLines(opened, [{ row: 4, col: 9 }]); expect(result).toEqual([ { cell: { row: 9, col: 9 }, axes: ["horizontal", "diagonalUp", "diagonalDown"], }, ]); }); it("цифра объяснена не полностью — пунктира нет", () => { const opened: OpenedCell[] = [{ cell: { row: 9, col: 9 }, digit: 2 }]; expect(computeDashedLines(opened, [{ row: 4, col: 9 }])).toEqual([]); }); it("цифра 0 — пунктир по всем 4 осям сразу", () => { const opened: OpenedCell[] = [{ cell: { row: 5, col: 0 }, digit: 0 }]; expect(computeDashedLines(opened, [])).toEqual([ { cell: { row: 5, col: 0 }, axes: ["horizontal", "vertical", "diagonalUp", "diagonalDown"], }, ]); }); it("цифра 4 полностью раскрыта — пунктирных осей не остаётся", () => { // клетка (5,5), 4 уничтоженных корабля на всех её осях const opened: OpenedCell[] = [{ cell: { row: 5, col: 5 }, digit: 4 }]; const revealed = [ { row: 5, col: 0 }, // горизонталь { row: 0, col: 5 }, // вертикаль { row: 2, col: 8 }, // восходящая диагональ (r+c=10) { row: 8, col: 8 }, // нисходящая диагональ (r-c=0) ]; expect(computeDashedLines(opened, revealed)).toEqual([]); }); });