Contenu connexe
Similaire à Behavior+tree+ai lite
Similaire à Behavior+tree+ai lite (20)
Behavior+tree+ai lite
- 1. Behavior Tree AI
AKara
akaras@163.com
http://blog.csdn.net/akara
http://t.sina.com.cn/akaras
- 2. 目录
• 常用方法
• Behavior Tree
• 原理
• 进阶
• 应用
• 总结
- 5. • 常用方法
• Behavior Tree
• 原理
• 进阶
• 应用
• 总结
- 6. if / else 神器
if visible: 优点:
if close: 这个可以承受
knife attack
elif flank: 缺点:
move
A:77倍可以承受不?
else:
B:可以
gun attack
A:...........
elif audible:
creep
- 8. 有限状态机 - Finite State Machine
关键字:
关键字:
• State
• Transition(Ev/Con)
经典设计: 1P + 3E
• Precondition
• Enter
• Excute
• Exit
- 10. <<FSM Age is OVER>>
Alex.J.C
• Unorthodox • Not Deliberative
• Low-Level • Concurrency Nightmares
• Logic is Limited • Scale Poorly
• Require Extensions • Labor Intensive
• Hard to Standardize • Industry is Moving On
http://aigamedev.com/open/articles/fsm-age-is-over/
难分解 / 低通用 / 难扩展 / 无层次 / 可预测 (FuSM)
- 11. 分层有限状态机 - Hierarchical Finite State Machine
关键字: SuperState
关键字:
<<Statecharts: A Visual Formalism for Complex Systems>> by D.Harel 1987
- 17. V1.5 of Halo BT AI
Halo guys incredibly helpful and open with sharing
detailed / pros / cons, this owes much to them.
- 19. BTs are a GREAT tool for decision taking:
Easier to Use, More info, Less Resource,
Rapid iteration, Coordinating AI easily
- 20. 800 NPCs full 24 hour schedules governing
their daily life , Each NPC is running a BT
— no dummy FSM's
- 21. Behavior Tree
• 2001: R.Geoff.Dromey 雏形
• 2003: Halo2使用(HFSM Like)
• 2005: Halo3改进
• 2006: Spore再改进
• 2007: Crysis / Crysis 2 协作式AI / BT Notation v1.0
• 2008-2009: AiGameDev (Alex.J.C) / MidWares / Libs
• 2010: Red Dead Redemption获BestNPC奖 / Halo: Reach
- 23. 初见BT:BOSS
初见BT
BT:
• 星期天,攻击男玩家;巡逻;巡逻一次原地休息每5分钟
- 24. 4 种结点 + 1 个规则
• 行为结点 - Action Node
• 条件结点 - Condition Node
• 装饰结点 - Decorator Node
• 组合结点 - Composite Node
• 结点执行后,向 父结点 返回:
成功(True)/失败(False)
- 27. (3) 装饰结点
• 结果取反 - Decorator NOT
• 次数限制 - Decorator Counter
• 强制循环 - Decorator Loop
• 时间限制 - Decorator Time
• GEEKS - Decorator GEEKS
AOP?
- 28. (3-1) 装饰结点 : 结果取反
• def execute(self):
return not self.children[0].execute()
- 29. (3-2) 装饰结点 : 次数限制
• def decorator(self):
self.counter += 1
return self.counter <= self.max_counter
• def execute(self):
if self.decorator(): return self.children[0].execute()
else: return False
- 30. (3-3) 装饰结点 : GEEKS
• def decorator(self):
print “GEEK”
Animation? Sound? Log?
• def execute(self):
self.decorator()
return self.children[0].execute()
- 31. (4) 组合结点
• 选择结点 - Selector Node
• 顺序结点 - Sequence Node
• 平行结点 - Parallel Node
- 32. (4-1) 组合结点 : 选择
• def execute(self):
for child in self.children:
if child.execute(): return True
return False
- 33. (4-2) 组合结点 : 顺序
• def execute(self):
for child in self.children:
if not child.execute(): return False
return True
- 34. (4-3) 组合结点 : 平行
• def execute(self):
for child in self.children:
run child.execute()
return True/False according to Policy
- 35. 现在我们可以
• 顺序
• 选择
• 平行
• 循环
• 条件
• 时限
• ……
- 36. 回看:BOSS
回看:BOSS
• 星期天,攻击男玩家;巡逻;巡逻一次原地休息每5分钟
- 39. 为何引入Blackboard?
为何引入Blackboard
Blackboard?
• 让Behavior Tree专注于决策执行
• 简化世界复杂性到Blackboard KV
• 易读取,易删改,易同步
• 叶结点间数据交互
• 使Behavior Tree与数据分离,甚至Dry-Run
- 42. 平行结点
• FailPolicy
– FAIL_ON_ALL
– FAIL_ON_ONE
• SuccPolicy
– SUCC_ON_ALL
– SUCC_ON_ONE
- 43. RUNNING态
RUNNING态
• Action不一定瞬间完成!
• 第三种返回
– True/False
– Running !
• 记录当前访问子结点索引
• 向上返回Running
• 下次运行行为树时,保证
跑到running结点
- 45. • 常用方法
• Behavior Tree
• 原理
• 进阶
• 应用
• 总结
- 46. 举一个U3同学的栗子
举一个U3
U3同学的栗子
• AI需求:
1. 从A移动到B
2. 如果发现10码内有敌人,怒吼,然后攻击它
3. 如果没有发现敌人,坐下,然后睡觉。
• Unreal3的延迟函数
- 52. • 常用方法
• Behavior Tree
• 原理
• 进阶
• 应用
• 总结
- 53. 策划赐词
• 解放——解放程序&策划
• 易用——图形化优势
• 不足——编辑器不足
• 期待——学习型AI
- 54. 优点
• 静态树 - Static Tree
Halo2 -> Halo3 : - Stimulus + Masks
• 可复用 - Reusable
内置结点(Com / Dec)给力,只编写外部结点(Con / Act)
• 可扩展 - Extendable
内置 (WRandSel / WRandSeq / Probability…),外部(积累)
- 55. 更重要的是
• 简单
• 直观
• 规范
• 流程优化
以前:策划文档(xls),程序翻译(成就感=0),愤怒的QC (鸭梨大)
现在:策划用BTE(所编即所玩);QC表示可以承受(Blackboard)
程序前期——写condition/action
程序后期——还要程序吗?