@tamb/gamegrid
    Preparing search index...

    Interface NpcMemory

    Search state for one NPC, kept by the caller and passed on every tick. Field names are readable on purpose: saved games in Hide and Seek use a different short-key object, and the adapter copies between the two.

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

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

    chooseSeekerStep({
    matrix,
    isWalkable: walkableUnlessTypes(["wall"]),
    self: [1, 1],
    visibleQuarry: [{ id: "hider", coord: [4, 1] }],
    isQuarryActive: () => true,
    memory,
    difficulty: "smart",
    });

    memory.visited.has("1,1"); // true
    memory.lastSeen; // [4, 1]
    memory.lastSeenId; // "hider"
    memory.ttl; // 12
    interface NpcMemory {
        coverageCells: Coord[];
        coverageIndex: number;
        heading: Direction | null;
        investigating: boolean;
        lastSeen: Coord | null;
        lastSeenId: string | null;
        lure: Coord | null;
        overlapSince: number | null;
        ttl: number;
        visited: Set<string>;
    }
    Index
    coverageCells: Coord[]

    Sweep order. Empty until the first coverage decision fills it.

    coverageIndex: number
    heading: Direction | null

    Direction the quarry was moving when last seen.

    investigating: boolean

    True once the NPC has reached the last-seen cell and is searching around it.

    lastSeen: Coord | null

    Last cell where a quarry was seen.

    lastSeenId: string | null

    Id of that quarry, when the caller had one.

    lure: Coord | null

    Cell the NPC is walking toward because the caller passed it as a lure.

    overlapSince: number | null

    Clock time when this seeker started waiting on a quarry in the same cell. Null when it is not waiting. Set only while SeekerStepArgs.pauseOnOverlapMs is positive.

    ttl: number

    Ticks left before the sighting is forgotten.

    visited: Set<string>

    Cells already stepped on, as "x,y".