@tamb/gamegrid
    Preparing search index...

    Function buildCoveragePath

    • 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.

      Parameters

      • matrix: Cell[][]

        Board to scan.

      • isWalkable: IsWalkable

        Which cells count as open.

      Returns Coord[]

      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]