Use when writing acceptance criteria for a task - express each as an observable Given/When/Then that QA can execute, including negative cases
日本語の概要は準備中です。原文の説明を表示しています。
Use when adding character/enemy/game-flow states or NPC behaviour - explicit transition tables instead of flag soup, hierarchical and pushdown machines, behaviour trees per engine, navmesh pathfinding, AI tick budgets, and table-driven tests.
インストールする前に、エージェントに与えられる指示の中身を確認できます。
Character controllers, enemies, menus and match flow are all state machines whether or not the code admits it. When they are written as a pile of booleans (isJumping, isAttacking, isStunned), illegal combinations become reachable and every new state touches every branch. Make the states and the legal transitions explicit, and test the table.
Core principle: One current state, an explicit list of (state, event) → next state, and enter/exit hooks. Anything not in the table cannot happen.
// ❌ flag soup: can be jumping AND stunned AND attacking; every rule checks every flag
if (input.attack && !this.isStunned && !this.isDead && (!this.isJumping || this.canAirAttack)) { ... }
// ✅ explicit states and transitions
type State = "idle" | "run" | "jump" | "attack" | "stunned" | "dead";
type Event = "move" | "stop" | "jump" | "land" | "attack" | "attackEnd" | "hit" | "recover" | "die";
const transitions: Record<State, Partial<Record<Event, State>>> = {
idle: { move: "run", jump: "jump", attack: "attack", hit: "stunned", die: "dead" },
run: { stop: "idle", jump: "jump", attack: "attack", hit: "stunned", die: "dead" },
jump: { land: "idle", hit: "stunned", die: "dead" },
attack: { attackEnd: "idle", hit: "stunned", die: "dead" },
stunned: { recover: "idle", die: "dead" },
dead: {},
};
export class Fsm {
constructor(public state: State, private hooks: Hooks) {}
send(e: Event): boolean {
const next = transitions[this.state][e];
if (!next) return false;
this.hooks.exit?.(this.state); this.state = next; this.hooks.enter?.(next);
return true;
}
}
The same shape in C# is an enum plus a Dictionary<(State, Event), State> built once; in GDScript a Dictionary of dictionaries or one node per state (godot-gdscript-patterns); in Unreal a UENUM with a switch, or StateTree for larger designs.
it.each([
["idle", "jump", "jump"], ["jump", "attack", "jump"], // no air attack in this design
["stunned", "move", "stunned"], ["dead", "recover", "dead"],
["attack", "hit", "stunned"],
])("%s + %s → %s", (from, ev, to) => {
const fsm = new Fsm(from as State, {});
fsm.send(ev as Event);
expect(fsm.state).toBe(to);
});
Cover every row that matters to the design plus the rejections ("dead ignores everything"). A new state lands with its rows in this test.
paused, pop back to exactly where play was.enter, on the simulation clock (game-loop-and-time).Reach for a behaviour tree when an NPC has many prioritised goals with conditions (patrol, investigate, chase, flee, heal). Use the one the repository already has:
| Engine | Built in / common |
|---|---|
| Unreal | Behavior Trees + Blackboard + EQS; StateTree for state-based logic |
| Unity | Behavior package (com.unity.behavior); third-party trees if already present |
| Godot | Addons such as LimboAI or Beehave; a node-based state machine for simple NPCs |
| Bevy | Crates such as big-brain (utility AI) or a hand-rolled tree |
| Web | A small hand-rolled tree, or the repository's library |
Rules either way: leaf actions are small and testable alone, the tree reads a blackboard instead of reaching into scene objects, conditions are cheap, and running actions can be aborted cleanly when a higher-priority branch wins. Utility AI (score each option, pick the best) suits needs-driven NPCs; keep its curves in data (data-driven-gameplay-design).
| Engine | Navmesh and agents |
|---|---|
| Unity | AI Navigation package: NavMeshSurface (bake), NavMeshAgent.SetDestination |
| Godot | NavigationRegion2D/3D + NavigationAgent2D/3D; query only after the navigation map has synced (wait one physics frame after load) |
| Unreal | NavMeshBoundsVolume, AAIController::MoveToLocation/MoveToActor, async path queries |
| Web | recast-navigation (WASM) or grid A* for 2D |
| Bevy | Crates such as vleue_navigator or oxidized_navigation |
Update branches instead of one table.enter.if (state == X) check outside the state machine that decides a transition.まだレビューはありません。使ってみた感想をお寄せください。
概要と使いどころ
Use when writing acceptance criteria for a task - express each as an observable Given/When/Then that QA can execute, including negative cases
日本語の概要は準備中です。原文の説明を表示しています。
Use when the diff adds or changes an endpoint, resolver, RPC, job or query that takes an object id, a role check, a request binding or a tenant filter - BOLA/IDOR, function-level authorization, mass assignment and tenant scoping
日本語の概要は準備中です。原文の説明を表示しています。
Use on every UI change - semantic HTML, labels for controls, keyboard-navigable dialogs/menus, visible focus, and never color as the only signal
日本語の概要は準備中です。原文の説明を表示しています。
Use when a task changes any screen, form, dialog, menu or control - Lighthouse/axe scan of the changed screens, a keyboard walk, and the thresholds that fail a task
日本語の概要は準備中です。原文の説明を表示しています。
How to work a task returned with review, QA or UAT findings. Use when a task is in need_revision or PR review comments are in your context.
日本語の概要は準備中です。原文の説明を表示しています。
Use when deciding whether a request needs an analiz task before implementation - the conditions that require the architect's analysis versus going straight to implementation
日本語の概要は準備中です。原文の説明を表示しています。