game-ai
Fungsinya
Skill ini menjelaskan cara membuat karakter game memutuskan apa yang harus dilakukan, cara bergerak, dan cara menemukan jalur di sekitar rintangan. Skill ini ditujukan untuk pengembang game yang membangun musuh, penjaga, atau kelompok karakter yang bergerak.
Kapan dipakai
- โSaat Anda membangun perilaku patroli, mengejar, atau berjaga untuk musuh.
- โSaat Anda perlu memilih antara state machine, behavior tree, atau steering untuk sebuah karakter.
- โSaat musuh harus menemukan jalur mengelilingi dinding untuk mencapai pemain.
Link skill
https://github.com/gamedev-skills/awesome-gamedev-agent-skills/blob/main/skills/disciplines/game-ai/SKILL.mdSalin lalu tempelkan ke AI Anda (Claude, ChatGPT, atau Cursor) dan minta AI mengikuti instruksinya.
Cara pakai
Cara paling mudah: salin pesan ini dan tempelkan ke AI Anda. AI akan membaca skill dan mengikuti instruksinya.
Pesan siap tempel
Untuk Claude Code, Codex, atau Cursor: jalankan di folder proyek, lalu skill langsung terpasang.
Unduh SKILL.md lalu taruh di folder skill agen Anda.
Contoh permintaan ke AI
โSaya ingin penjaga musuh saya berpatroli, mengejar saya saat dia melihat saya, dan kembali ke posnya saat saya kabur. Pendekatan AI mana yang sebaiknya saya pakai?โ
5 skill baru setiap minggu. 1 menit baca.
Cara kerjanya
Agent merekomendasikan state machine sederhana untuk beberapa state yang jelas, behavior tree untuk banyak perilaku berprioritas, atau scoring untuk pilihan bertingkat. Agent memisahkan keputusan, gerakan, dan pathfinding agar setiap bagian lebih mudah diubah.
Konten teknis (SKILL.md asli)
Teks asli dari pembuat, dalam bahasa Inggris, langsung dari 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
Pertanyaan umum
Apa itu steering?
Steering adalah gerakan lokal yang halus, seperti mengejar target atau bergerak bersama kelompok.
Apakah ini mencakup navigasi engine saya?
API navigasi bawaan engine dicakup oleh skill engine terkait, yang ditunjuk oleh skill ini.
Apakah A* termasuk?
Ya. Skill ini mencakup A* pada grid atau graf untuk mencari jalur.
Detail
Deskripsi asli dari pembuat
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.
Popularitas
- Bintang GitHub
- 6.6k
- Peringkat
- #13796
- Lisensi
- Apache-2.0
- Diperbarui
- 28/10/2026
Komentar
- โฆ
Skill lain dari repositori ini
router
6.6kMembantu agent Anda memilih skill pengembangan game yang tepat untuk setiap permintaan dengan mendeteksi engine Anda dan jenis tugas yang Anda perlukan.
ai-behavior-trees-utility-ai
6.6kMembantu agent Anda membangun behavior tree dan sistem utility AI untuk musuh dan karakter game yang memilih aksi berdasarkan prioritas dan skor.
audio-design
6.6kMengajari agent Anda cara mixing audio game: bus, volume dalam desibel, ducking di bawah dialog, musik adaptif, dan variasi efek suara.
camera-systems
6.6kMembantu agent Anda membangun kamera game yang mengikuti dengan halus, tetap berada di dalam level, dan dapat mengorbit atau melihat sekeliling dalam 3D.
Skill serupa
diffs
394kMemungkinkan agent Anda menghasilkan diff perubahan yang nyata dan dapat dibagikan sebagai tautan viewer atau file gambar, bukan ringkasan yang ditulis manual.
coding-agent
394kMembantu agent Anda menyerahkan pekerjaan pemrograman besar ke Codex, Claude Code, atau OpenCode di latar belakang, lalu memeriksa kemajuannya.
gh-issues
394kMembantu agent Anda menemukan issue GitHub, memilih yang dikerjakan, dan membuka pull request perbaikan, termasuk tindak lanjut komentar tinjauan.