• Stars
    star
    265
  • Rank 153,758 (Top 4 %)
  • Language
    C#
  • Created about 10 years ago
  • Updated almost 10 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

专为Unity3D打造的AI行为树

Unity3DAIBehaviorTree

This is AI BehaviorTree for Unity3d

专为Unity3D打造的AI行为树,包括ai编辑器
相关的博客文章地址为: http://www.luzexi.com/unity3d%E8%A1%8C%E4%B8%BA%E6%A0%91%E7%B3%BB%E7%BB%9F%E7%BC%96%E7%A8%8B%E5%AE%9E%E7%8E%B0/


![github](https://github.com/luzexi/Unity3DAIBehaviorTree/blob/master/img.png "编辑器")

行为树(Behavior Tree)具有如下的特性:

它只有4大类型的Node:

  • Composite Node
  • Decorator Node
  • Condition Node
  • Action Node

任何Node被执行后,必须向其Parent Node报告执行结果:成功 / 失败。
这简单的成功 / 失败汇报原则被很巧妙地用于控制整棵树的决策方向。

———————————————————————

先看Composite Node,其实它按复合性质还可以细分为3种:
* Selector Node
当执行本类型Node时,它将从begin到end迭代执行自己的Child Node:
如遇到一个Child Node执行后返回True,那停止迭代,
本Node向自己的Parent Node也返回True;否则所有Child Node都返回False,
那本Node向自己的Parent Node返回False。

* Sequence Node
当执行本类型Node时,它将从begin到end迭代执行自己的Child Node:
如遇到一个Child Node执行后返回False,那停止迭代,
本Node向自己的Parent Node也返回False;否则所有Child Node都返回True,
那本Node向自己的Parent Node返回True。

* Parallel Node
并发执行它的所有Child Node。
而向Parent Node返回的值和Parallel Node所采取的具体策略相关:
Parallel Selector Node: 一False则返回False,全True才返回True。
Parallel Sequence Node: 一True则返回True,全False才返回False。
Parallel Hybird Node: 指定数量的Child Node返回True或False后才决定结果。

Parallel Node提供了并发,提高性能。
不需要像Selector/Sequence那样预判哪个Child Node应摆前,哪个应摆后,
常见情况是:
(1)用于并行多棵Action子树。
(2)在Parallel Node下挂一棵子树,并挂上多个Condition Node,
以提供实时性和性能。
Parallel Node增加性能和方便性的同时,也增加实现和维护复杂度。

PS:上面的Selector/Sequence准确来说是Liner Selector/Liner Sequence。
AI术语中称为strictly-order:按既定先后顺序迭代。

Selector和Sequence可以进一步提供非线性迭代的加权随机变种。
Weight Random Selector提供每次执行不同的First True Child Node的可能。
Weight Random Sequence则提供每次不同的迭代顺序。
AI术语中称为partial-order,能使AI避免总出现可预期的结果。

———————————————————————

再看Decorator Node,它的功能正如它的字面意思:它将它的Child Node执行
后返回的结果值做额外处理后,再返回给它的Parent Node。很有些AOP的味道。

比如Decorator Not/Decorator FailUtil/Decorator Counter/Decorator Time…
更geek的有Decorator Log/Decorator Ani/Decorator Nothing…

———————————————————————

然后是很直白的Condition Node,它仅当满足Condition时返回True。

———————————————————————

最后看Action Node,它完成具体的一次(或一个step)的行为,视需求返回值。
而当行为需要分step/Node间进行时,可引入Blackboard进行简单数据交互。

———————————————————————

整棵行为树中,只有Condition Node和Action Node才能成为Leaf Node,而也
只有Leaf Node才是需要特别定制的Node;Composite Node和Decorator Node均
用于控制行为树中的决策走向。(所以有些资料中也统称Condition Node和Action
Node为Behavior Node,而Composite Node和Decorator Node为Decider Node。)

更强大的是可以加入Stimulus和Impulse,通过Precondition来判断masks开关。

通过上述的各种Nodes几乎可以实现所有的决策控制:if, while, and, or,
not, counter, time, random, weight random, util…

———————————————————————

更多Unity3D内容请访问: http://www.luzexi.com

More Repositories

1

Unity3DGameResource

Unity3D assetbundle resources API
C#
150
star
2

Unity3DNavMesh

为Unity3d打造的NavMesh
C#
112
star
3

xls2lua

A script to convert xls or xlsx to lua files.
Python
95
star
4

Unity3DuGUI-Toolkit

In Unity3D 5.3.2+ , the uGUI has not enough compontent to build GUI system. So this repository can improve it .
C#
69
star
5

Unity3DCharacterEffectEditor

Unity3D role skill effect editor can make character skill in editor including animation, effect and hit box.
C#
39
star
6

Unity3DNetwork-http

Unity3D的http网络层封装
C#
27
star
7

Unity3DMapEditor

Map Editor for unity3d. It can place NPC , Monster , and Building . It will generate a data file to record the map infomation.
C#
26
star
8

Unity3DUtil

Unity3D game project develop util
C#
21
star
9

Unity3dToBeLeader

《Unity3D高级编程进阶主程》错误上报点
21
star
10

Unity3DMVC

专为unity3d打造的MVC架构
C#
19
star
11

Unity3DTable

Unity3D table data parse about csv , xml , json , ini .
C#
19
star
12

Unity3DWebView

Unity3DWebView 网页调用与回调
Objective-C
17
star
13

Unity3DSocket

Unity3D Socket (TCP)
C#
16
star
14

Unity3DEncrypt

Unity3D Encrypt and Decrypt data .
C#
15
star
15

Unity3DItemSystem

Unity3D物品通用系统
C#
14
star
16

Unity3DCharacterCustomization

专门Unity3d打造的角色换装系统
C#
14
star
17

MinGW

MinGW just for building windows library
C++
13
star
18

Unity3DRuntimeDebug

Unity3D RuntimeDebug can show debug information in Android , iOS , and all of the platform.
C#
12
star
19

Unity3DMemoryCompare

Unity3D memory compare every frame in editor
C#
12
star
20

Unity3DFSM

为Unity3D打造的角色渲染和行为有限状态机。
C#
11
star
21

Unity3DWaypointPathfinding

Unity3D waypoint pathfinding system
C#
11
star
22

blog

www.luzexi.com
HTML
9
star
23

version_update

Php generate json file to display which file have to update.
PHP
9
star
24

Game-BraveKingdoms

It is a single-player-game made by unity3d and It use lua to program.
C#
7
star
25

xls2csv

xls to csv
Python
6
star
26

pomelo-unityclient-socket-demo

pomelo-unityclient-socket-demo
C#
6
star
27

Unity3D-UDP

UDP for Unity3D
C#
5
star
28

Unity3D-symbol

Unity3D tool. Can open or close symbol in unity3d.
C#
5
star
29

Unity3DZone

Unity3D区域物体裁剪--大型区域中对非必要物体采取不渲染或者不运行处理
5
star
30

Unity3DPlatformSDK

It is good to access many sdk.So you will not to take more time to check it.
C#
3
star
31

Unity3DAdvertisement

Unity3D 广告插件
Objective-C
2
star
32

kdm-client

kids daily mission
C#
2
star
33

Unity3DPushMessage

为Unity3D打造的推送封装
C#
2
star
34

freeradius-server-session-limit

The FreeRADIUS Server for vpn authorize and counting. Focus on session counting.
C
2
star
35

one_and_one

1加1连连看html5游戏
C++
2
star
36

Unity3D-DocClean

Unity3D4.6+ Documents load slowly in china because of the google font . This Repository can fix the problem.
Shell
2
star
37

Unity3DSublime2Project

It will generator sublime2 project in unity3d.And in the project , it will ignore the files or folders which you want. So you can use sublime2 to code faster.
C#
1
star
38

jekyll-relate

jekyll relate template
HTML
1
star
39

translate

translate
1
star
40

Unity3DWeiboShare

Unity3d新浪微博分享sdk插件
Objective-C
1
star