@tamb/gamegrid
    Preparing search index...

    Function walkableUnlessTypes

    • Walkability that blocks the given cell types and anything off the matrix. A game whose walls are "barrier" passes that name. A game whose walls are "wall" passes that instead. Types not in the list can be entered.

      Parameters

      • blocked: readonly string[]

        Cell type strings that cannot be entered.

      Returns IsWalkable

      A predicate for chooseHiderAction, chooseSeekerStep, and the search helpers.

      import { walkableUnlessTypes } from "@tamb/gamegrid/npc";

      const matrix = [
      [
      { type: "floor" },
      { type: "wall" },
      ],
      [
      { type: "water" },
      { type: "floor" },
      ],
      ];
      const isWalkable = walkableUnlessTypes(["wall", "water"]);
      isWalkable(matrix, 0, 0); // floor
      isWalkable(matrix, 1, 0); // wall, blocked
      isWalkable(matrix, 1, 1); // floor
      isWalkable(matrix, -1, 0); // false, off the board
      isWalkable(matrix, 0, 2); // false, no such row
      import { walkableUnlessTypes } from "@tamb/gamegrid/npc";

      const isWalkable = walkableUnlessTypes(["barrier"]);
      const matrix = [[{ type: "open" }, { type: "barrier" }]];
      isWalkable(matrix, 0, 0); // true
      isWalkable(matrix, 1, 0); // false