ai-behavior-trees-utility-ai
यह क्या करती है
यह गेम AI के दो तरह के फ़ैसले सिस्टम का कोड बनाती है: बिहेवियर ट्री और यूटिलिटी स्कोरिंग। यह उन गेम डेवलपर्स के लिए है जिन्हें दुश्मनों या किरदारों के ऐसे व्यवस्थित और भरोसेमंद फ़ैसले चाहिए।
कब इस्तेमाल करें
- ✓जब आप दुश्मनों या नॉन-प्लेयर किरदारों के लिए दोबारा इस्तेमाल होने वाला बिहेवियर ट्री बनाना चाहें।
- ✓जब आपके किरदार कई विकल्पों को तौलकर उस पल का सबसे अच्छा विकल्प चुनें।
- ✓जब आप तय करना चाहें कि दुश्मन एक कार्रवाई को दूसरी से कितनी मज़बूती से पसंद करे।
Skill का लिंक
https://github.com/gamedev-skills/awesome-gamedev-agent-skills/blob/main/skills/disciplines/ai-behavior-trees-utility-ai/SKILL.mdइसे कॉपी करके अपने AI (Claude, ChatGPT या Cursor) में पेस्ट करें और निर्देशों का पालन करने को कहें।
कैसे इस्तेमाल करें
सबसे आसान तरीका: मैसेज कॉपी करके अपने AI में पेस्ट करें। वह skill पढ़कर निर्देशों का पालन करेगा।
पेस्ट करने के लिए तैयार मैसेज
Claude Code, Codex या Cursor के लिए: प्रोजेक्ट फ़ोल्डर में चलाएँ और skill इंस्टॉल हो जाएगी।
SKILL.md डाउनलोड करें और अपने एजेंट के skills फ़ोल्डर में रखें।
AI से क्या माँगें: उदाहरण
“मैं चाहता हूँ कि मेरे दुश्मन बिहेवियर ट्री से गश्त करें और पीछा करें, और कौन सा हमला करना है यह यूटिलिटी स्कोर से चुनें।”
हर हफ़्ते 5 नई skills, 1 मिनट में पढ़ें।
यह कैसे काम करती है
एजेंट साझा डेटा के लिए ब्लैकबोर्ड, कार्रवाई और शर्त वाले लीफ़ नोड, और सीक्वेंस व सिलेक्टर जैसे कंपोज़िट नोड बनाता है। वह रिस्पॉन्स कर्व से हर कार्रवाई को स्कोर करने वाला यूटिलिटी इवैल्यूएटर भी बनाता है, और दोनों को जोड़ भी सकता है।
तकनीकी सामग्री (मूल SKILL.md)
लेखक का मूल टेक्स्ट, अंग्रेज़ी में, सीधे GitHub से।
Behavior Trees & Utility AI
Two complementary ways to structure NPC decision-making, plus how to combine them. A behavior tree (BT) expresses structured, prioritized, reactive logic as a tree that is "ticked" each step. Utility AI answers "how much do I want each option right now?" by scoring actions with normalized curves and picking the best. Ship believable agents by using a BT for structure and Utility AI where graded trade-offs matter.
This skill is the implementation companion to game-ai (which helps you choose between
FSM / BT / steering / pathfinding). Read game-ai to pick a model; read this to build the
runtime.
When to use
- Use to build a reusable BT runtime: a
Blackboard,Nodebase, action/condition leaves,Sequence/Selector/Parallelcomposites, and decorators (Inverter, Cooldown, Repeat). - Use to build a Utility AI decider: response curves, considerations, and an evaluator that scores and selects actions (max, softmax, or weighted-random for variety).
- Use to build hybrid AI — a BT whose leaf delegates the "which attack / which target" choice to a utility evaluator.
When not to use: to choose between FSM, BT, steering, or pathfinding, and for A*/navmesh
routing, use game-ai. For Unreal's asset-based BehaviorTree/Blackboard, BTTask/BTService
and AIController, use unreal-behavior-trees. For the navmesh agent that moves the NPC, use
unity-navmesh or the engine's navigation node.
Core workflow
- Pick the model. Structured, prioritized, interruptible behavior → BT. Continuous "score every option" decisions (targeting, needs, item choice) → Utility. Both → hybrid.
- Design the Blackboard first. One typed key/value store per agent is the shared memory that decouples nodes; leaves read/write it and never hold references to each other.
- Write leaves. Conditions return
Success/Failureimmediately; actions returnRunningacross frames until they finish. Keep leaves small and side-effect-explicit. - Compose.
Selector= OR/fallback (first non-failure wins);Sequence= AND (stop at first non-success);Parallelfor concurrent branches. Wrap with decorators for policy (invert, cooldown, repeat, force-success). - For Utility: enumerate considerations, map each raw fact through a normalized 0..1 curve, combine (weighted product with compensation, or weighted sum), then select the max — add hysteresis so agents don't flip-flop on ties.
- Tick deliberately. Tick the tree/evaluator once per decision step (often slower than
render). Preserve
Runningstate between ticks; verify by drawing the active path and the per-action scores on screen while tuning.
Architecture at a glance
A behavior tree evaluates top-down, left-to-right; each node returns a status up to its parent:
flowchart TD
Root["Selector (root)"] --> Combat["Sequence: Combat"]
Root --> Patrol["Action: Patrol"]
Combat --> See["Condition: CanSeePlayer?"]
Combat --> InRange{"Selector: Reach"}
Combat --> Attack["Action: Attack (Running)"]
InRange --> Close["Condition: InAttackRange?"]
InRange --> MoveTo["Action: MoveToPlayer (Running)"]
Utility AI is a scoring pipeline — every candidate action is scored, then one is selected:
facts (distance, health, ammo…)
│ each fact → a normalized 0..1 response curve (consideration)
▼
score(action) = weight · combine(consideration_1 … consideration_n) # product+compensation or sum
▼
select: argmax · or softmax / weighted-random for variety · + hysteresis to avoid jitter
Status is a three-value enum shared by every node — this is the contract that makes the tree composable:
public enum Status { Success, Failure, Running }
public abstract class Node
{
public abstract Status Tick(Blackboard bb, float dt);
public virtual void Reset() { } // called when a parent abandons this subtree
}
// Selector = fallback/OR: return the first child that is not Failure.
// `Current` (from Composite) remembers a Running child so the next tick resumes there.
public sealed class Selector : Composite
{
public override Status Tick(Blackboard bb, float dt)
{
for (; Current < Children.Count; Current++)
{
var s = Children[Current].Tick(bb, dt);
if (s == Status.Running) return Status.Running;
अक्सर पूछे जाने वाले सवाल
बिहेवियर ट्री और यूटिलिटी AI में क्या अंतर है?
बिहेवियर ट्री व्यवस्थित और प्राथमिकता वाले चरण देता है, जबकि यूटिलिटी AI हर विकल्प को स्कोर करके सबसे अच्छा चुनता है।
क्या मुझे एक ही सिस्टम चुनना होगा?
नहीं। स्किल एक हाइब्रिड भी कवर करती है, जिसमें बिहेवियर ट्री कुछ फ़ैसलों के लिए यूटिलिटी इवैल्यूएटर को बुलाता है।
क्या यह Unreal के बिल्ट-इन ट्री एसेट के लिए है?
नहीं। Unreal के एसेट-आधारित ट्री एक अलग Unreal स्किल में कवर होते हैं।
जानकारी
लेखक का मूल विवरण
Build a production behavior-tree runtime (Blackboard, action/condition leaves, sequence/selector/parallel composites, decorators) and a Utility AI system (response curves — linear, exponential, sigmoid, quadratic — considerations, and action evaluators), plus hybrid BT-drives-Utility agents. Use when implementing a reusable behavior-tree or utility-based decision system, or tuning enemy/NPC decisions beyond a simple FSM, or when the user mentions behavior tree, blackboard, decorator, selector, sequence, tick status, utility AI, response/scoring curve, or consideration. For choosing between FSM
लोकप्रियता
- GitHub स्टार
- 6.6k
- रैंकिंग में स्थान
- #13791
- लाइसेंस
- Apache-2.0
- अपडेट की गई
- 28/10/2026
कमेंट
- …
इस repository की और skills
router
6.6kयह आपके एजेंट को इंजन और काम के प्रकार को पहचानकर किसी अनुरोध के लिए सही गेम डेवलपमेंट स्किल चुनने में मदद करती है।
audio-design
6.6kआपके एजेंट को गेम ऑडियो मिक्सिंग सिखाती है: बस, डेसिबल में वॉल्यूम, डायलॉग में म्यूज़िक धीमा करना और साउंड इफ़ेक्ट की विविधता।
camera-systems
6.6kयह आपके एजेंट को ऐसे गेम कैमरा बनाने में मदद करती है जो सहजता से पीछा करें, लेवल के भीतर रहें, और 3D में घूम या देख सकें।
create-game-assets
6.6kयह आपके एजेंट को गेम आर्ट का एकसमान सेट योजना बनाने और जाँचने में मदद करती है, स्टाइल गाइड और स्प्राइट सूची से लेकर साइज़ और नामकरण के नियमों तक।
मिलती-जुलती skills
diffs
394kयह आपके एजेंट को बदलावों का असली diff बनाने देती है, जिसे व्यूअर लिंक या इमेज फ़ाइल के रूप में साझा किया जा सकता है, हाथ से लिखे सारांश के बजाय।
coding-agent
394kयह आपके एजेंट को बड़े कोडिंग काम Codex, Claude Code या OpenCode को बैकग्राउंड वर्कर के रूप में सौंपने, फिर उसकी प्रगति जांचने में मदद करती है।
gh-issues
394kयह आपके एजेंट को GitHub issues खोजने, उनमें से काम करने लायक चुनने, और सुधार के साथ pull requests खोलने में मदद करती है, जिसमें समीक्षा टिप्पणियों का फ़ॉलो-अप भी शामिल है।