시작발표 - behavior tree
-
Upload
taewoo-kim -
Category
Education
-
view
2.546 -
download
0
Transcript of 시작발표 - behavior tree
Behavior Tree Overview
아꿈사 : http://cafe.naver.com/architect1김태우 : [email protected]
INDEX• Introduction
• FSM
• HFSM
• BTs
Introduction
Wish List
– Perfect designer supervision– AI behaves autonomously too
I want full
control...
...but not all the time!
Wish List
– Purposeful behaviors– Responds to events
The AI should be goal directed
...yet react to sudden
changes!
HierarchicalLogic
HFSM
PlannersHTN
ScriptingC++ Lua
Scripting: The Good
– Any computation possible– Widespread experience
I've done this for years!
Scripting: The Bad
– Difficult to introspect, analyze– Not accessible to many designers
What's planning?
HFSM: The Good
– Simple and intuitive– Full low-level reactive control
It's actually usable!
HFSM: The Bad
– Generally labor intensive– Not easy to build goal directed
It takes a lot of
work...
Planning: The Good
– Uses search for automation– Goal directed by default!
AI can solve many logic problems.
Planning: The Bad
– Integration of procedural code– Ignores control & execution
It's disconnected from the real
world?
HFSM
PlannersHTN
ScriptingC++ Lua
intuitivereactive
autonomouspurposeful
integratedflexible
Behavior Trees
Bang for Buck!
– Decision making over time– Control & monitoring execution
FSM
Abstract– 이론적으로 , FSM은 logic의 명확한 형태를 제공 – 실용적으로도 , FSM은 해결하려는 문제에 유용– A blessing and a curse
•처음엔 간단히 시작하지만 , •규모가 커지게 되면 문제가 생긴다
What is state?• FSM은 state라는 개념에 기반하는데 ,
state는 2 가지로 구성된다– Set of actions at the same time
•애니메이션 , 사운드 , 약간의 대기
– Set of transitions with conditional check•다음 state으로 언제 넘어갈 지를 결정
• State들은 정말 generic하고 robust하게
만들어 질 수 있다 .– 간단한 문제에 관해서는 좋은 편이다 . – 커다란 문제에 관해서는 더욱 확장성 있는 접근법이 필요하다 .
Idle CombatSelf-
preservation
Search
Flight
Idle CombatSelf-
preservation
Search
Flight
HFSM
Abstract• HFSM은 재사용 가능한 로직에 대한 약간의 도움을 제공
•디자인 절차는 non-HFSM과 매우 유사– state마다 로직을 구축한다 . transition들로
state들을 bottom up식으로 연결한다 . – 새로운 state들을 생성하는 동안 , transition들을 공유하기 위해 state들을 그룹화 한다 .
•이렇게 하면 , transition logic의 중복을 간단히 피할 수 있다 .
Super-States and Generalized Transitions
• Super-States == Groups of States
•이 super-states 역시 transition들을 소유이론적으로 중복 전이를 예방 가능– 전이를 각 상태 마다 개별적으로 적용시키지 말고 ,
super-states에 한 번만 적용시킴 – 이것을 generalized transitions라고 부름
• state들은 전형적으로 하나의 super-state에포함되어 , 폴더처럼 엄격한 계층을 가지게 됨
Behavior Trees
Abstract•게임 AI의 주 목적 중 하나는 로직을 편집하기 위해 간단하고 확장성있는 솔루션을 찾는 것
• FSM– 장점 : 정말 간단하다– 단점 : 큰 시스템에서는 state들 간에 재사용 가능한
transition들을 제공하기 위해 HFSM이 필요함• HFSM
– 장점 : 확장성 있는 로직을 만드는데 분명히 유용– 단점 : state들에 대해 어떤 모듈성도 제공하지 않음
•다양한 목적과 상황에 대한 로직을 제공하기 위해 state들을 재사용할 수 없음
State of Behaviors • state들의 모듈성을 증가
– encapsulating logic transparently
• state들이 독립 (self-contained) 되도록– state들에 대한 transition들을 제거
• No more 'states‘– 'transitions'가 없기 때문– 단지 실행하고 종료하는
behaviors 또는 action의 집합이 됨
A Programming Analogy •어떻게 behavior들을 차례로 배열할까 ?
– 각 연산은 successor에 대한 포인터 없음
– 대신에 , 연산들은 parent scope에서 삽입됨그리고 , parent scope의 의미에 따라 실행됨
– 연산 간의 transition들은 자동적으로 정의됨
Why Behavior Trees Work • BTs가 확장성 있게 구현된다면 매우 강력
– sequences와 selectors 같은 표준 합성의 제공
– custom decorators를 섞어 넣음
• sequences와 selectors의 간단한 BT를 FSM으로 변환 가능– FSM
• 개별적인 transition들에서 더 많은 제어를 제공
– BT• 로직이 모듈적이고 재사용이 쉽도록 만듬
BehaviorTrees
A Guard Dog's AI
Woof
patrol investigate attack
look aroundmove bite
Example
recursive decomposition
Leaves
– interface between AI and engine
Conditions
– actor state, meta-checks– collision, entity queries
Actions
– animation, sound– using objects, game logic
It's All About Tasks
– Latent computation– Succeed or Fail
Condition ActionCondition
Task
Building Complexity
branches manage the leaves
done using composite tasks
Sequences
keep going
bail out
Selectors
terminate
keep trying
Dynamic Behavior as Search
Behavior Language
– Standard & high-level composite tasks– Rather than custom low-level logic
So I implement concepts once, and
reuse them everywhere?
In Practice
Improving Your HFSM
Does this help me with my
state machine?
Improving Your HFSM– make it easy to build sequences– no need to (re)wire transitions– easier to build purposeful behaviors
Design Principles
That gives me some guidelines
to follow for editing all those
transitions!
Improving Your Scripts
How does that help me
with my scripts?
Improving Your Scripts– provide better dynamic error handling– by making it easy to build selectors
Software Patterns
It'll help me think about my scripts
on a higher-level.
Scalability
Remove Bottlenecks
– Custom logic takes time to code up..– Also much more likely to cause bugs
? ?Lua /FSM
Embrace Design Patterns– find common patterns– implement them as high-level tasks– it's much simpler and intuitive– helps designers mix and match
Decorator Tasks
“In object-oriented programming, the decorator pattern allows additional behavior to be added to an existing
method of an object without modifying the original code.”
original task
decorator filter
Decorating a Behavior
Bark,
woof pause wuf
multiple times,
ignoring voice failures,
no more often than every x seconds.
at most n times in total,
timer
counter
loop
wrapper
Incremental Development
– it's a modular script interpreter
These decorators can be
implemented as they are required.
Summary
HFSM
PlannersHTN
ScriptingC++ Lua
BT
intuitivereactive
autonomouspurposeful
integratedflexible
BT
tree editor
stacklanguage
full planning
That's All Folks!
References• AIGameDev
– http://aigamedev.com/open/articles/bt-overview/
• The Artificial Intelligence of Halo 2– http://electronics.howstuffworks.com/halo2-ai.htm
• Halo2 AI and Blah Blah– http://www.naimadgames.com/publications/gdc05/
gdc05.ppt
Lisence