跳过主要内容
ANY
Skill免费GameSkill 出品 · 调优版

Game AI: FSM, Behavior Trees & Pathfinding

/game-ai

NPC and enemy decision-making with state machines, behavior trees, steering and A* pathfinding, paired with your engine's navigation API.

许可证
Apache-2.0
出品
GameSkill 出品
下载 ZIP

所属合集

Awesome Gamedev Agent Skills

77 portable SKILL.md skills across 12 engines (Godot, Unity, Unreal, Phaser, PixiJS, three.js, Bevy, pygame, LÖVE, Roblox, Defold, Ebitengine), with a router.

我们测过

在 Godot 4.7.2 上通过 34/34 项检查(2026-10-30):能触发、有可运行示例、有截图和自检清单、单一职责、中英文文档齐全。触发检查是把提示词和 skill 描述做匹配,不是真实 agent 运行。

测试报告

这个 skill 做什么

什么时候触发

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. …

GameSkill 测过的版本

GameSkill 调优版:skill 文件取自提交 19d93f97c9c1,按我们的 skill 流程加上可运行示例、测试报告、自检清单和中文指南。

下载测过的 ZIP(35 KB)路线图:玩法机制

协议:基于 gamedev-skills/awesome-gamedev-agent-skills(作者 gamedev-skills),协议 Apache-2.0。ZIP 保留协议文件(LICENSE, NOTICE),CHANGES.md 列出了 GameSkill 加的所有文件。

Game AI: FSM, Behavior Trees & Pathfinding

自检清单

  • 启发值要匹配移动方式:4 方向用曼哈顿,8 方向用 octile,不能高估 / Match the heuristic to allowed moves; never overestimate.
  • 转向要朝下一个路点,不是直接朝目标 / Steer to the next waypoint, not straight to the goal.
  • 路径按计时器或目标换格时重算,不要每帧算 / Repath on a timer or when the goal changes tile, not every frame.
  • 状态转换写在状态里,不要到处散 if state == / Keep transitions inside states, not scattered if checks.
  • 多帧动作的行为树叶子要返回 RUNNING,否则每帧重来 / Multi-frame BT leaves must return RUNNING.

中文指南

这个 skill 做什么

这个 skill 讲 NPC 和敌人的决策与移动:有限状态机(FSM)、行为树、转向行为(seek、arrive、flee、separation)和 A* 寻路,都是与引擎无关的算法,再配合引擎自己的导航 API 使用。

什么时候用

  • 写敌人的巡逻、追击、逃跑、搜索等状态逻辑
  • 在网格或路点图上做 A* 寻路,或驱动引擎的导航代理
  • 用 seek、arrive、flee、separation 做平滑移动和群体避让

怎么装

下载本页的 ZIP,把 game-ai/ 整个文件夹放进 agent 的 skills 文件夹:Claude Code 用 .claude/skills/,Codex、Gemini CLI、OpenCode 用 .agents/skills/,Cursor 用 .cursor/skills/,Copilot 用 .github/skills/,Windsurf 用 .windsurf/skills/,然后重启 agent。也可以直接对 agent 说:Install the skill from https://gameskill.dev/skills/game-ai/install.md

最小示例

gameskill/examples/ 里是一个 Godot 4 小场景:enemy_fsm.gd 管巡逻、追击、搜索状态,grid_path.gd 在网格上跑 A*,steering.gd 和 perception.gd 分别做转向和视野、听觉判断,main.gd 和 main.tscn 把它们接起来。tests/run_tests.gd 是检查,tests/screenshot.gd 渲染截图。

我们怎么测的

总分 34/34。在 Godot 4.7.2 无头模式下跑 22 项检查:A* 直线路径从起点出发、到终点结束,遇到墙会绕开且不穿墙,斜向路径正确;octile 启发值不超过 8 方向网格上的真实最短代价;seek 指向目标且受 max_force 限制,arrive 在远处全速、靠近减速,flee 远离威胁,separation 对对称位置互相抵消;感知上,锥形视野内能看到目标,背后和超出距离看不到,近处能听到、远处听不到;FSM 从巡逻开始,看到目标转追击,追击短暂保持,丢失目标转搜索,搜索超时回巡逻。初稿把“启发值不超过直线距离”当成可采纳性,这是错的;改成和 8 方向网格上的真实最短代价比较。结果在 gameskill/test-report.json。

和站内其他 skill 的区别

站内的 ai-behavior-trees-utility-ai 讲行为树和效用评分;这个 skill 讲 FSM、A* 寻路、转向和感知,我们的示例也只测这几部分。

搭配

  • ai-behavior-trees-utility-ai:行为树和效用评分的深入设计
  • fps-shooter:射击游戏里的敌人 AI 组合
  • tower-defense:塔防里沿路移动的敌人

安装

告诉你的 AI

Install the skill from https://gameskill.dev/skills/game-ai/install.md

GameSkill 测过的版本

测过的版本装到 .claude/skills/
mkdir -p .claude/skills
curl -fsSL https://gameskill.dev/dl/skills/game-ai.zip -o /tmp/gameskill-game-ai.zip
unzip -oq /tmp/gameskill-game-ai.zip -d .claude/skills
rm /tmp/gameskill-game-ai.zip

包含内容

  • Worked steps: Finite state machine; Behavior tree tick; Steering: seek and arrive; A* heuristic must not overestimate
  • A pitfalls section with the mistakes to avoid
  • Bundled 2 reference docs the agent reads when needed

适合

  • Building enemy AI, an FSM or behavior tree, steering/flocking, or pathfinding

试试这条提示词

提示词
Make my enemies patrol, spot the player and chase them with A* pathfinding.

关于这个 Skill

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.

From the game-ai SKILL.md in gamedev-skills/awesome-gamedev-agent-skills.

What's inside

  • Finite state machine (one state object, explicit transitions)
  • Behavior tree tick (composite nodes return a status)
  • Steering: seek and arrive (smooth, frame-rate independent)
  • A* heuristic must not overestimate (or paths stop being shortest)

常见问题

同赛道 PRO 商业源码$8.25/mo

肉鸽战斗与首领套件 Roguelike Combat & Boss Kit

拆自《招式武林》的 6 大战斗与首领商业内核(同步交付 JS/TS + Godot 4 .gd + Unity .cs 三端源码):Boss 半血变身三段锁血、防守表现分动态怒气、确定性双通道暴击、丝血反杀暗箱、破防状态机与正向遗物总线,附可玩 60fps Canvas 沙盒。

  • EP28 Boss 变身锁血:单次门槛、45 血硬卡、送盾绝不回血 + 换招升级
  • EP27 防守表现分怒气 + EP26 确定性双通道暴击(告别 55.2% 连黑 5 次)

基于 gamedev-skills/awesome-gamedev-agent-skills (作者 gamedev-skills,协议 Apache-2.0)。ZIP 里保留原作者的 LICENSE 和 NOTICE,ATTRIBUTION.md 和 CHANGES.md 写明来源提交和 GameSkill 加的内容。

搭配使用

作者标注的相关 Skills,或更适合相邻任务的 Skills。

Awesome Gamedev Agent Skills 中的更多 Skills

查看全部 44 个

相似 skills

Agent Sprite Forge
GDT
Skill
4.9k

Agent Sprite Forge

Five agent skills that turn one approved character still into a game-ready sprite set: one image-to-video clip per action, then deterministic Python tools key, register, loop, retime, palette-lock and export it for Godot, Aseprite and the web. Also maps, tiles and code-drawn art.

GodotWeb (Phaser / Three.js)Engine-agnosticClaude Code · Codex
earshot
ANY
Skill
GameSkill 出品

earshot: ears for coding agents (judge, find, time-align and make game sound on CPU)

Let an agent hear: rank sound-effect candidates against a description, find the clean trim in a long recording, tell real recordings from code-synthesised sound, check that every hit lands on its picture cut, and render effects from a bank of 252 code-made sounds. Runs locally on CPU with two open audio models (~1.1 GB, downloaded once); no API key needed.

Engine-agnosticClaude Code · Codex +3
One Sentence to Game
WEB
Skill
GameSkill 出品

One Sentence to Game (prompt, iterate, check)

A GameSkill original for any model: a round-1 prompt that turns one sentence into a small finished browser game, a one-change-per-round loop with a creation log, a reusable spec template, and a headless checker that reports console errors, blank frames and dead controls as PASS or FAIL. It does not promise one-shot.

Web (Phaser / Three.js)Engine-agnosticClaude Code · Codex +2
Playtest Report
ANY
Skill
GameSkill 出品

Playtest Report (Claude Code Game Studios)

Structured playtest report template, or turn existing playtest notes into structured feedback.

Engine-agnostic来自 Claude Code Game Studios