Board to scan.
Which cells count as open.
Sweep order. Empty when the board is smaller than 3 by 3.
import { buildCoveragePath, walkableUnlessTypes } from "@tamb/gamegrid/npc";
const matrix = [
[{ type: "wall" }, { type: "wall" }, { type: "wall" }, { type: "wall" }, { type: "wall" }],
[{ type: "wall" }, { type: "floor" }, { type: "floor" }, { type: "floor" }, { type: "wall" }],
[{ type: "wall" }, { type: "floor" }, { type: "floor" }, { type: "floor" }, { type: "wall" }],
[{ type: "wall" }, { type: "floor" }, { type: "floor" }, { type: "floor" }, { type: "wall" }],
[{ type: "wall" }, { type: "wall" }, { type: "wall" }, { type: "wall" }, { type: "wall" }],
];
const sweep = buildCoveragePath(matrix, walkableUnlessTypes(["wall"]));
// [1, 1], [2, 1], [3, 1], [3, 2], [2, 2], [1, 2], [1, 3], [2, 3], [3, 3]
Interior open cells in a snake, left to right on odd rows and right to left on even rows. The border ring is left out so a sweep does not hug the wall.