Board the walk is planned on.
Which cells may be entered.
Start coordinate.
Coordinate to move away from.
The first direction, or null when no step exists.
import { bfsFarthestStep, 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: "floor" }],
[{ type: "wall" }, { type: "wall" }, { type: "wall" }, { type: "wall" }, { type: "wall" }],
];
const isWalkable = walkableUnlessTypes(["wall"]);
const away = bfsFarthestStep(matrix, isWalkable, [2, 1], [1, 1]);
// "right". [4, 1] is the open cell farthest from the threat at [1, 1].
First step of a walk that ends on a cell as far from
avoidas the board allows.