game-ai
できること
ゲームのキャラクターが何をするか、どう動くか、障害物を避けてどう経路を見つけるかを説明します。敵、番兵、集団で動くキャラクターを作るゲーム開発者向けです。
使う場面
- ✓敵の巡回、追跡、警備の動きを作っているとき。
- ✓キャラクターにステートマシン、ビヘイビアツリー、ステアリングのどれを使うか選ぶ必要があるとき。
- ✓敵が、プレイヤーにたどり着くために壁を避ける経路を見つける必要があるとき。
スキルのリンク
https://github.com/gamedev-skills/awesome-gamedev-agent-skills/blob/main/skills/disciplines/game-ai/SKILL.mdコピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。
使い方
いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。
貼り付け用メッセージ
Claude Code、Codex、Cursorの場合:プロジェクトのフォルダで実行するとスキルがインストールされます。
SKILL.mdをダウンロードして、エージェントのスキル用フォルダに入れてください。
AIへの頼み方の例
“警備役の敵に、巡回させ、私を見つけたら追いかけさせ、私が逃げたら持ち場に戻らせたいです。どのAIの方法を使うべきですか。”
毎週5つの新しいスキル。1分で読めます。
仕組み
エージェントは、状態が少ない場合は単純なステートマシン、優先度の多い行動が多い場合はビヘイビアツリー、段階的な選択には採点を推奨します。判断、動き、経路探索を分けて保つので、それぞれを変えやすくなります。
技術的な内容(元のSKILL.md)
作者による元のテキスト(英語)をGitHubからそのまま表示しています。
Game AI: decisions, steering, and pathfinding
Build believable NPC behavior from three separable layers: decide (what to do), steer (how to move there), and path (how to route around the map). Keep them decoupled — a behavior tree picks a target, the pathfinder produces waypoints, steering follows them. This skill teaches the engine-neutral algorithms; bind them to your engine via the related skills below.
When to use
- Use when implementing enemy/NPC logic: patrols, chase/flee, guard states, group movement, or "find a path to the player".
- Use to choose between an FSM (few clear states), a behavior tree (many reactive behaviors with priorities), or steering (smooth local movement).
- Use when integrating pathfinding: A* on a grid/graph, or driving an engine navmesh agent.
When not to use: for the engine's concrete navmesh/agent API and baking,
use unity-navmesh, unreal-behavior-trees, or Godot's NavigationAgent2D/3D
(see that engine skill). For movement/collision feel, use physics-tuning. For
spawning waves along lanes, see the tower-defense genre skill.
Core workflow
- Pick the decision model by complexity. 2–5 states with obvious transitions → FSM. Many behaviors, priorities, interruption, reuse → behavior tree. Continuous "how strongly do I want each option" → utility scoring.
- Separate decision from motion. The decision layer outputs an intent (target position, action). Steering or pathfinding turns intent into motion.
- Path on the right graph. Grid tiles, waypoint graph, or a baked navmesh. Fewer nodes = faster A*. Prefer the engine's navmesh for 3D; A* on a grid for tile games.
- Steer along the path, not straight to the goal — follow the next waypoint, advancing when close, so agents round corners.
- Recompute paths sparingly. Pathfind on a timer or when the goal moves a tile, not every frame. Cache the path; only the waypoint index advances.
- Verify by observation. Watch the agent: does it reach the goal, get stuck on corners, oscillate between states? Draw the path and current state on screen while tuning.
Patterns
1. Finite state machine (one state object, explicit transitions)
# Godot 4.7, one class per file.
# state.gd: each state is a small object with enter/update/exit.
class_name State extends RefCounted
func enter(_agent) -> void: pass
func update(_agent, _dt: float) -> State: return null # return a state to transition
func exit(_agent) -> void: pass
# chase.gd: returns Patrol when the player escapes sight range.
class_name Chase extends State
func update(agent, dt: float) -> State:
if not agent.can_see(agent.target):
return Patrol.new() # transition by returning the next state
agent.move_toward(agent.target.position, dt)
return null # null = stay in this state
# enemy.gd: the agent owns `current` and ticks it once per frame.
var current: State = Patrol.new() # call current.enter(self) in _ready()
func tick(dt: float) -> void:
var next := current.update(self, dt)
if next != null:
current.exit(self)
next.enter(self)
current = next
Keep transition logic inside states (or in a table), never as a growing pile
of if flags. One state owns one behavior; that is what keeps an FSM readable.
2. Behavior tree tick (composite nodes return a status)
# A node's tick() returns SUCCESS, FAILURE, or RUNNING (still working this frame).
enum Status { SUCCESS, FAILURE, RUNNING }
# Sequence: run children in order; stop at the first non-SUCCESS (logical AND).
func sequence_tick(children, agent, dt) -> int:
for child in children:
var s = child.tick(agent, dt)
if s != Status.SUCCESS:
return s # FAILURE or RUNNING short-circuits the sequence
return Status.SUCCESS
# Selector: try children until one succeeds or is RUNNING (logical OR / fallback).
func selector_tick(children, agent, dt) -> int:
for child in children:
var s = child.tick(agent, dt)
if s != Status.FAILURE:
return s # SUCCESS or RUNNING stops the search
return Status.FAILURE
A guard AI reads top-down: Selector[ Sequence[CanSeePlayer?, Chase], Patrol ]
— chase if visible, otherwise patrol. See references/behavior-trees.md for
leaf nodes, decorators (Inverter, Cooldown), and a
よくある質問
ステアリングとは何ですか?
目標に向かう、または集団で群れて動くような、なめらかなローカルの動きのことです。
エンジンの経路探索の仕組みも扱いますか?
エンジン自身のナビゲーションAPIは、関連するエンジンのスキルで扱われ、このスキルはそれを案内します。
A*は含まれますか?
はい。スキルはグリッドやグラフでの経路探索のA*を扱います。
詳細
作者による元の説明
Design NPC and enemy decision-making with finite state machines, behavior trees, steering behaviors, and A* pathfinding — engine-neutral algorithms that pair with the detected engine's navigation API. Use when building enemy AI, an FSM or behavior tree, steering/flocking, or pathfinding, or when the user mentions state machine, behavior tree, blackboard, A*, navmesh, seek, or patrol/chase.
人気
- GitHubのスター
- 6.6k
- ランキング
- #13796
- ライセンス
- Apache-2.0
- 更新日
- 2026/10/28
コメント
- …
このリポジトリの他のスキル
router
6.6kエージェントが、エンジンとタスクの種類を見分けて、依頼に合ったゲーム開発のスキルを選べるよう支援します。
ai-behavior-trees-utility-ai
6.6kエージェントが、優先度と点数によって行動を選ぶ、ゲームの敵やキャラクター向けのビヘイビアツリーとユーティリティAIのシステムを作れるよう支援します。
audio-design
6.6kエージェントが、オーディオバス、デシベルでの音量、会話中の音の抑え込み(ダッキング)、適応型の音楽、効果音のバリエーションなど、ゲームのサウンドのミキシングを教えます。
camera-systems
6.6kエージェントが、なめらかに追従し、レベルの内側に収まり、3Dで周回したり見回したりできるゲームのカメラを作れるよう支援します。
似ているスキル
diffs
394k編集内容の実際の共有可能な差分を、手書きの要約ではなく、ビューアーのリンクや画像ファイルとして作成するようエージェントを支援します。
coding-agent
394kCodex、Claude Code、OpenCodeに大きめのコーディング作業をバックグラウンドのワーカーとして渡し、その進捗を確認するようエージェントを支援します。
gh-issues
394kGitHubのイシューを探し、取り組むものを選び、修正を含むプルリクエストを開くようエージェントを支援します。レビューコメントへの対応も含みます。