40. IF ( 前置宣言文 ) then (後置宣言文)
ルールベース意思決定
Rule-based Decision Making
ルール
ここでは、この形式の制御文をルールと言います。
もちろん、IF ( … IF (.... IF… ) ) ) のような入れ子構造の制御文も
ルールベースと呼びますが、
ルールベースと言えば、基本的には、ルールを一つの単位として、
意思決定を行う、という意味です。
41. 推論エンジン
A B C D E
T F F F F
T T F F F
T T F T F
T T T T F
T T T T T
F T T T T
F F F T T
……………………………
……………………………
…………………
T: True F: False
ID 0 : IF A THEN B
ID 1 : IF A && D THEN C
ID 3 : IF C THEN E
ID 4 : IF B THEN D
ID .. :
ID 4 : IF E THEN ~A
ルール内の条件部がtrueの時、そのルールが発火する(fired)
すると言います。発火したルールの宣言文は true となり、また
それが別のルールを発火させます。
発火をくり返して、true/False
が変化して行く様子
42. ルール制御
ID 0 : IF …. THEN …
ID 1 : IF …. THEN …
ID 3 : IF …. THEN ….
ID 4 : IF …. THEN …
ID .. :
ID 5 : IF …. THEN …
Priority: 3
Priority: 1
Priority: 4
Priority: 5
Priority: 2
ルールに固定、あるいは変動プライオリティ(優先度)をつけて制御を行う。
あるいはランダムにルールをピックアップする場合もある。戦略思考、キャラク
ターの挙動などでよく使われる。
Priority: -
制御
ルール= IF ( 行動条件文 ) then (動作命令文)
43. (例) ルール制御
ID 0 : IF …. THEN …
ID 1 : IF …. THEN …
ID 3 : IF …. THEN ….
ID 4 : IF …. THEN …
ID .. :
ID 5 : IF …. THEN …
Priority: 3
Priority: 1
Priority: 4
Priority: 5
Priority: 2
或いは、状況判断思考によってルールを振り分ける。
戦略思考、キャラクターの挙動などでよく使われる。
Priority: -
制御
思考
ルール= IF ( 行動条件文 ) then (動作命令文)
44. 応用可能性例
http://gomibako.symphonic-net.com/vote.cgi?genre=act_b&rating=9
ID 0 : IF (敵確認) THEN (逆方向)
ID 1 : IF (誰もいない) THEN (ランダムウォーク)
ID 2 : IF (フルーツ発見) THEN (フルーツゲット)
ID 3 : IF (パワー発見) THEN (パワーゲット)
ID 0 : IF (敵強い) THEN (サンダガ)
ID 1 : IF (自分弱い) THEN (弱い敵に攻撃)
ID 2 : IF (HP<20) THEN (ケアル)
ID 3 : IF (パワー発見) THEN (パワーゲット)
こうなっているというのではなくて、こういうふうに応用できる例
パックマンなど
RPGなど
45. The Sims 3 における応用
街全体をソーシャルにシミュレーションして人との関係を楽しむゲーム。
たくさんのAIを「人間らしく」制御しなければならない。
特徴付けにプロダクションルールを採用。
Richard Evans, "Modeling Individual Personalities in The Sims 3", GDC 2011
http://www.gdcvault.com/play/1012450/Modeling-Individual-Personalities-in-The
94. The Game
• Spec Ops: The Line – AAA Third-Person Shooter for Xbox 360, PS3, PC
• We are Daniel Kollmann and Jörg Reisig ( YAGER Development / Berlin )
95. Behavior Trees in SOTL
Summary:
• No separation between Evaluation and Execution
• Parallel processing of nodes
• Loops and decorators
• Synchronization points for groups
• Events drive the evaluation, reactive
96. Behavior Trees in SOTL
• No separation between Evaluation and Execution
Evaluation aborts currently executed action
No Evaluation while an action is being executed
Composite
Condition
Actions
98. Behavior Trees in SOTL
• Parallel processing of nodes
Stack can have multiple top nodes
All children of a parallel are updated one after another Run in parallel
100. Behavior Trees in SOTL
• Loops
Loops keep triggering their child until a certain
condition is met.
• Decorators
Decorators are active as long as their child
is running.
Keep pushing the child
Apply effect/buff
104. • Events and impulses
Any node in the stack can be the target of an event. When the event fires the
tree jumps back to that node.
An impulse checks if a certain event was fired not long ago. If an impulse is not
active, it is completely ignored and does not return any result.
Behavior Trees in SOTL
Jump here
Do this
106. Behavior Trees in SOTL
• Events and impulses
Events can also be blocked
in a branch.
Jump here
Do not react to any following need for cover
Do this
108. Behavior Trees in SOTL
Final conclusion ....
• The event system always aborts active nodes even when not doing
anything. Being able to specify some conditions would be nice.
• Parallels sort of allow you to create your own behaviour nodes, instead
have no parallels and build biggers nodes.
• Gates are really useful if used in the right places. For more complex stuff
rather do a dedicated node.