Board, position, threats, and difficulty.
Inputs for chooseHiderAction. Leave taunt off unless the caller
has something to do with the "taunt" result.
OptionalcanTauntNow?: booleanCaller already applied its cooldown. Omitted means not ready.
Optionallegal?: Direction[]Steps the caller will accept. Omit to use every open neighbor. An empty list means the caller will not move, which is how a move limit is applied without this module knowing the rule.
Optionalrng?: () => numberOptionaltaunt?: booleanWhen omitted or false, the result is never "taunt".
Pass true to allow the taunt rolls.
"taunt", a direction, or null when the hider waits.
import { chooseHiderAction, walkableUnlessTypes } from "@tamb/gamegrid/npc";
const isWalkable = walkableUnlessTypes(["wall", "water"]);
const step = chooseHiderAction({
matrix,
isWalkable,
self: hider.coord,
threats: guards.map((guard) => guard.coord),
difficulty: "normal",
});
if (step && step !== "taunt") stepActor(hider, step);
import { chooseHiderAction, walkableUnlessTypes } from "@tamb/gamegrid/npc";
const action = chooseHiderAction({
matrix,
isWalkable: walkableUnlessTypes(["barrier"]),
self: hider.coord,
threats: seekerCoords,
difficulty: "smart",
canTauntNow: cooldownReady,
taunt: true,
});
import { chooseHiderAction, 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 action = chooseHiderAction({
matrix,
isWalkable: walkableUnlessTypes(["wall"]),
self: [1, 1],
threats: [[4, 1]],
difficulty: "smart",
canTauntNow: true,
taunt: true,
rng: () => 0,
});
// "taunt". Distance 3 is inside the smart radius, and the roll hits.
import { chooseHiderAction, 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 action = chooseHiderAction({
matrix,
isWalkable: walkableUnlessTypes(["wall"]),
self: [2, 1],
threats: [[4, 1]],
difficulty: "smart",
canTauntNow: true,
taunt: true,
rng: () => 0.5,
});
// "left". The roll missed, so the hider steps away from [4, 1].
import { chooseHiderAction, 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 action = chooseHiderAction({
matrix,
isWalkable: walkableUnlessTypes(["wall"]),
self: [2, 1],
threats: [[1, 1]],
difficulty: "normal",
});
// "right"
import { chooseHiderAction, 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 action = chooseHiderAction({
matrix,
isWalkable: walkableUnlessTypes(["wall"]),
self: [2, 1],
threats: [[1, 1]],
difficulty: "dumb",
rng: () => 0.9,
});
// null
import { chooseHiderAction, 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 action = chooseHiderAction({
matrix,
isWalkable: walkableUnlessTypes(["wall"]),
self: [2, 1],
threats: [[1, 1]],
difficulty: "normal",
legal: [],
});
// null
Decide a hider's next action: taunt, step away from the nearest threat, or wait.
tauntdefaults to false, so a caller that never passes it cannot receive"taunt". What a taunt does after this returns is the caller's game.