@tamb/gamegrid
    Preparing search index...

    Module npc

    Hider and seeker decisions for @tamb/gamegrid/npc. The caller owns the board, the actors, and the move. These functions return a direction, or "taunt" when the caller passed taunt: true. Keep one NpcMemory per seeker and pass that same object every tick.

    import {
    chooseHiderAction,
    chooseSeekerStep,
    createNpcMemory,
    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 memory = createNpcMemory();

    const seekerStep = chooseSeekerStep({
    matrix,
    isWalkable,
    self: [1, 1],
    visibleQuarry: [{ id: "hider", coord: [3, 1] }],
    isQuarryActive: (id) => id === "hider",
    memory,
    difficulty: "smart",
    });
    // "right". Toward the hider.

    const hiderAction = chooseHiderAction({
    matrix,
    isWalkable,
    self: [3, 1],
    threats: [[1, 1]],
    difficulty: "normal",
    });
    // "right". Away from the seeker.
    Cell
    HiderActionArgs
    NpcMemory
    SeekerStepArgs
    Coord
    Difficulty
    Direction
    IsWalkable
    bfsFarthestStep
    bfsNextStep
    buildCoveragePath
    chooseHiderAction
    chooseSeekerStep
    createNpcMemory
    listOpenCells
    walkableUnlessTypes