├── .gitignore
├── CHANGES
├── LICENSE
├── README.md
├── bower.json
├── build
├── Gruntfile.js
├── LICENSE
├── README.rst
├── createjsTheme
│ ├── assets
│ │ ├── css
│ │ │ ├── main.css
│ │ │ └── yui-cssgrids-min.css
│ │ ├── docs-icon-EaselJS2.png
│ │ ├── docs-icon.png
│ │ ├── favicon.ico
│ │ ├── js
│ │ │ └── yui-source.js
│ │ └── logo.png
│ ├── layouts
│ │ ├── main.handlebars
│ │ └── xhr.handlebars
│ ├── partials
│ │ ├── attrs.handlebars
│ │ ├── classes.handlebars
│ │ ├── events.handlebars
│ │ ├── files.handlebars
│ │ ├── index.handlebars
│ │ ├── method.handlebars
│ │ ├── module.handlebars
│ │ ├── options.handlebars
│ │ ├── props.handlebars
│ │ └── sidebar.handlebars
│ └── theme.json
├── files.json
├── package.json
└── path.js
├── docs
└── behavior3js.0.1.0.zip
├── libs
├── b3core.0.1.0.js
├── b3core.0.1.0.min.js
├── b3core.0.1.0.zip
├── behavior3-0.2.0dev.js
└── behavior3-0.2.0dev.min.js
├── package.json
├── src
├── actions
│ ├── Error.js
│ ├── Failer.js
│ ├── Runner.js
│ ├── Succeeder.js
│ └── Wait.js
├── b3.js
├── composites
│ ├── MemPriority.js
│ ├── MemSequence.js
│ ├── Priority.js
│ └── Sequence.js
├── core
│ ├── Action.js
│ ├── BaseNode.js
│ ├── BehaviorTree.js
│ ├── Blackboard.js
│ ├── Composite.js
│ ├── Condition.js
│ ├── Decorator.js
│ └── Tick.js
└── decorators
│ ├── Inverter.js
│ ├── Limiter.js
│ ├── MaxTime.js
│ ├── RepeatUntilFailure.js
│ ├── RepeatUntilSuccess.js
│ └── Repeater.js
└── tests
├── chai.js
├── mocha.css
├── mocha.js
├── sinon-chai.js
├── sinon.js
├── tests.html
└── tests
├── actions
├── Error.js
├── Failer.js
├── Runner.js
├── Succeeder.js
└── Wait.js
├── composites
├── MemPriority.js
├── MemSequence.js
├── Priority.js
└── Sequence.js
├── core
├── Action.js
├── BaseNode.js
├── BehaviorTree-Serialization.js
├── BehaviorTree.js
├── Blackboard.js
├── Composite.js
├── Condition.js
├── Decorator.js
└── Tick.js
└── decorators
├── Inverter.js
├── Limiter.js
├── MaxTime.js
├── RepeatUntilFailure.js
├── RepeatUntilSuccess.js
└── Repeater.js
/.gitignore:
--------------------------------------------------------------------------------
1 | # Logs
2 | logs
3 | *.log
4 |
5 | # Runtime data
6 | pids
7 | *.pid
8 | *.seed
9 |
10 | # Directory for instrumented libs generated by jscoverage/JSCover
11 | lib-cov
12 |
13 | # Coverage directory used by tools like istanbul
14 | coverage
15 |
16 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
17 | .grunt
18 |
19 | # Compiled binary addons (http://nodejs.org/api/addons.html)
20 | build/Release
21 |
22 | # Dependency directory
23 | # Commenting this out is preferred by some people, see
24 | # https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git-
25 | node_modules
26 |
27 | # Users Environment Variables
28 | .lock-wscript
29 |
30 | # IDE configurations
31 | .idea
32 |
33 | # --------------
34 | docs/behavior3js
35 | libs/b3editor*
36 | libs/b3view*
37 |
--------------------------------------------------------------------------------
/CHANGES:
--------------------------------------------------------------------------------
1 | Version [NEXT]
2 | ==============
3 |
4 | [core]
5 | - add: BehaviorTree now dump with custom_node property (see #9).
6 | - fix: tests working again.
7 | - mod: parameters are readonly now, so properties are used as initialization
8 | argument instead (see #10).
9 |
10 | [editor]
11 | - mod: editor has its own repository now (see https://github.com/renatopp/behavior3editor).
12 |
13 |
14 | Version 0.1.0 [Out 27, 2014]
15 | ============================
16 |
17 | - initial release.
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2014 Renato de Pontes Pereira
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
23 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # BEHAVIOR3JS (MOVED)
2 |
3 | This projects has been moved to
4 |
5 | - http://github.com/behavior3/behavior3js
6 |
7 | Consult our site to know more
8 |
9 | - http://behavior3.com
10 |
--------------------------------------------------------------------------------
/bower.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "behavior3js",
3 | "version": "0.1.0",
4 | "homepage": "https://github.com/renatopp/behavior3js",
5 | "authors": [
6 | {"name":"Renato Pereira", "email":"renato.ppontes@gmail.com", "homepage":"http://guineashots.com"},
7 | {"name":"Davis Marques"}
8 | ],
9 | "description": "Behavior tree library",
10 | "license": "MIT",
11 | "keywords": ["behavior", "tree", "behavior tree", "behavior3", "b3", "ai",
12 | "artificial intelligence"],
13 | "main": [ "libs/b3core.0.1.0.min.js" ],
14 | "ignore": [
15 | "node_modules",
16 | "bower_components",
17 | "build",
18 | "docs",
19 | "src",
20 | "tests",
21 | "tools",
22 | "examples"
23 | ]
24 | }
25 |
--------------------------------------------------------------------------------
/build/Gruntfile.js:
--------------------------------------------------------------------------------
1 | module.exports = function(grunt) {
2 |
3 | var files = grunt.file.readJSON('files.json');
4 | var projectFiles = [];
5 |
6 | // Project configuration.
7 | grunt.initConfig({
8 | pkg: grunt.file.readJSON('package.json'),
9 | concat: {
10 | options: {
11 | separator: ''
12 | },
13 | dist: {
14 | src: [],
15 | dest: '../libs/<%= project %>-<%= pkg.version %>.js',
16 | }
17 | },
18 | uglify: {
19 | options: {
20 | banner: '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n',
21 | },
22 | build: {
23 | src: '../libs/<%= project %>-<%= pkg.version %>.js',
24 | dest: '../libs/<%= project %>-<%= pkg.version %>.min.js'
25 | }
26 | },
27 | yuidoc: {
28 | compile: {
29 | name: '<%= pkg.name %>',
30 | version: '<%= pkg.version %>',
31 | description: '<%= pkg.description %>',
32 | url: '<%= pkg.url %>',
33 | logo: '<%= pkg.logo %>',
34 | options: {
35 | paths: ['../src'],
36 | outdir: '../docs/behavior3js/',
37 | linkNatives: true,
38 | attributesEmit: true,
39 | selleck: true,
40 | helpers: ["../build/path.js"],
41 | themedir: "createjsTheme/"
42 | }
43 | }
44 | },
45 | compress: {
46 | build: {
47 | options: {
48 | mode:'zip',
49 | archive:'../docs/<%= project %>-<%= pkg.version %>.zip'
50 | },
51 | files: [
52 | {expand:true, src:'**', cwd:'../docs/behavior3js'}
53 | ]
54 | }
55 | },
56 | });
57 |
58 | // Load the plugin that provides the "uglify" task.
59 | grunt.loadNpmTasks('grunt-contrib-concat');
60 | grunt.loadNpmTasks('grunt-contrib-uglify');
61 | grunt.loadNpmTasks('grunt-contrib-yuidoc');
62 | grunt.loadNpmTasks('grunt-contrib-compress');
63 |
64 | // DOCS
65 | grunt.registerTask('_docs', function() {
66 | grunt.config.set('project', 'behavior3js');
67 | });
68 |
69 | // CORE
70 | grunt.registerTask('_core', function() {
71 | grunt.config.set('project', 'behavior3');
72 | grunt.config.set('concat.dist.src', files['core_source']);
73 | });
74 |
75 | // Default task(s).
76 | grunt.registerTask('docs', ['_docs', 'yuidoc', 'compress']);
77 | grunt.registerTask('build', ['_core', 'concat', 'uglify']);
78 |
79 | };
--------------------------------------------------------------------------------
/build/LICENSE:
--------------------------------------------------------------------------------
1 | /*!
2 | * @license <%= pkg.name %>
3 | *
4 | * Copyright (c) 2014 Renato de Pontes Pereira.
5 | *
6 | * Distributed under the terms of the MIT license.
7 | * http://www.opensource.org/licenses/mit-license.html
8 | *
9 | * This notice shall be included in all copies or substantial portions of the Software.
10 | */
--------------------------------------------------------------------------------
/build/README.rst:
--------------------------------------------------------------------------------
1 | Use to build::
2 |
3 | npm install
4 | grunt core
5 |
--------------------------------------------------------------------------------
/build/createjsTheme/assets/css/yui-cssgrids-min.css:
--------------------------------------------------------------------------------
1 | .yui3-g{letter-spacing:-0.31em;*letter-spacing:normal;word-spacing:-0.43em}.yui3-u{display:inline-block;zoom:1;*display:inline;letter-spacing:normal;word-spacing:normal;vertical-align:top}.yui3-u-1,.yui3-u-1-2,.yui3-u-1-3,.yui3-u-2-3,.yui3-u-1-4,.yui3-u-3-4,.yui3-u-1-5,.yui3-u-2-5,.yui3-u-3-5,.yui3-u-4-5,.yui3-u-1-6,.yui3-u-5-6,.yui3-u-1-8,.yui3-u-3-8,.yui3-u-5-8,.yui3-u-7-8,.yui3-u-1-12,.yui3-u-5-12,.yui3-u-7-12,.yui3-u-11-12,.yui3-u-1-24,.yui3-u-5-24,.yui3-u-7-24,.yui3-u-11-24,.yui3-u-13-24,.yui3-u-17-24,.yui3-u-19-24,.yui3-u-23-24{display:inline-block;zoom:1;*display:inline;letter-spacing:normal;word-spacing:normal;vertical-align:top}.yui3-u-1{display:block}.yui3-u-1-2{width:50%}.yui3-u-1-3{width:33.33333%}.yui3-u-2-3{width:66.66666%}.yui3-u-1-4{width:25%}.yui3-u-3-4{width:75%}.yui3-u-1-5{width:20%}.yui3-u-2-5{width:40%}.yui3-u-3-5{width:60%}.yui3-u-4-5{width:80%}.yui3-u-1-6{width:16.656%}.yui3-u-5-6{width:83.33%}.yui3-u-1-8{width:12.5%}.yui3-u-3-8{width:37.5%}.yui3-u-5-8{width:62.5%}.yui3-u-7-8{width:87.5%}.yui3-u-1-12{width:8.3333%}.yui3-u-5-12{width:41.6666%}.yui3-u-7-12{width:58.3333%}.yui3-u-11-12{width:91.6666%}.yui3-u-1-24{width:4.1666%}.yui3-u-5-24{width:20.8333%}.yui3-u-7-24{width:29.1666%}.yui3-u-11-24{width:45.8333%}.yui3-u-13-24{width:54.1666%}.yui3-u-17-24{width:70.8333%}.yui3-u-19-24{width:79.1666%}.yui3-u-23-24{width:95.8333%}#yui3-css-stamp.cssgrids{display:none}.yui3-widget-hidden{display:none}.yui3-widget-content{overflow:hidden}.yui3-widget-content-expanded{-moz-box-sizing:border-box;-webkit-box-sizing:border-box;-ms-box-sizing:border-box;box-sizing:border-box;height:100%}.yui3-widget-tmp-forcesize{overflow:hidden !important}#yui3-css-stamp.skin-sam-widget-base{display:none}.yui3-tab-panel{display:none}.yui3-tab-panel-selected{display:block}.yui3-tabview-list,.yui3-tab{margin:0;padding:0;list-style:none}.yui3-tabview{position:relative}.yui3-tabview,.yui3-tabview-list,.yui3-tabview-panel,.yui3-tab,.yui3-tab-panel{zoom:1}.yui3-tab{display:inline-block;*display:inline;vertical-align:bottom;cursor:pointer}.yui3-tab-label{display:block;display:inline-block;padding:6px 10px;position:relative;text-decoration:none;vertical-align:bottom}.yui3-skin-sam .yui3-tabview-list{border:solid #2647a0;border-width:0 0 5px;zoom:1}.yui3-skin-sam .yui3-tab{margin:0 .2em 0 0;padding:1px 0 0;zoom:1}.yui3-skin-sam .yui3-tab-selected{margin-bottom:-1px}.yui3-skin-sam .yui3-tab-label{background:#d8d8d8 url(http://yui.yahooapis.com/3.10.1/build/assets/skins/sam/sprite.png) repeat-x;border:solid #a3a3a3;border-width:1px 1px 0 1px;color:#000;cursor:pointer;font-size:85%;padding:.3em .75em;text-decoration:none}.yui3-skin-sam .yui3-tab-label:hover,.yui3-skin-sam .yui3-tab-label:focus{background:#bfdaff url(http://yui.yahooapis.com/3.10.1/build/assets/skins/sam/sprite.png) repeat-x left -1300px;outline:0}.yui3-skin-sam .yui3-tab-selected .yui3-tab-label,.yui3-skin-sam .yui3-tab-selected .yui3-tab-label:focus,.yui3-skin-sam .yui3-tab-selected .yui3-tab-label:hover{background:#2647a0 url(http://yui.yahooapis.com/3.10.1/build/assets/skins/sam/sprite.png) repeat-x left -1400px;color:#fff}.yui3-skin-sam .yui3-tab-selected .yui3-tab-label{padding:.4em .75em}.yui3-skin-sam .yui3-tab-selected .yui3-tab-label{border-color:#243356}.yui3-skin-sam .yui3-tabview-panel{background:#edf5ff}.yui3-skin-sam .yui3-tabview-panel{border:1px solid gray;border-top-color:#243356;padding:.25em .5em}#yui3-css-stamp.skin-sam-tabview{display:none}
--------------------------------------------------------------------------------
/build/createjsTheme/assets/docs-icon-EaselJS2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/renatopp/behavior3js/4212a70fabc2813c78c1fe21f09ad7ceed149217/build/createjsTheme/assets/docs-icon-EaselJS2.png
--------------------------------------------------------------------------------
/build/createjsTheme/assets/docs-icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/renatopp/behavior3js/4212a70fabc2813c78c1fe21f09ad7ceed149217/build/createjsTheme/assets/docs-icon.png
--------------------------------------------------------------------------------
/build/createjsTheme/assets/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/renatopp/behavior3js/4212a70fabc2813c78c1fe21f09ad7ceed149217/build/createjsTheme/assets/favicon.ico
--------------------------------------------------------------------------------
/build/createjsTheme/assets/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/renatopp/behavior3js/4212a70fabc2813c78c1fe21f09ad7ceed149217/build/createjsTheme/assets/logo.png
--------------------------------------------------------------------------------
/build/createjsTheme/layouts/main.handlebars:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 | {{projectName}} v{{projectVersion}} API Documentation : {{name}}
11 |
12 |
13 |
14 |
15 |
27 |
28 |
29 |
30 |
33 |
34 |
35 | {{>options}}
36 |
37 |
38 |
39 | {{>layout_content}}
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
--------------------------------------------------------------------------------
/build/createjsTheme/layouts/xhr.handlebars:
--------------------------------------------------------------------------------
1 |
8 |
--------------------------------------------------------------------------------
/build/createjsTheme/partials/attrs.handlebars:
--------------------------------------------------------------------------------
1 |
2 |
{{! For backwards compatibility }}
3 |
{{name}}
4 |
{{#crossLink type}}{{/crossLink}}
5 |
6 | {{#if deprecated}}
7 |
deprecated
8 | {{/if}}
9 |
10 | {{#if access}}
11 |
{{access}}
12 | {{/if}}
13 |
14 | {{#if final}}
15 |
final
16 | {{/if}}
17 |
18 | {{#if static}}
19 |
static
20 | {{/if}}
21 |
22 | {{#if optional}}
23 |
optional
24 | {{/if}}
25 |
26 | {{#if required}}
27 |
required
28 | {{/if}}
29 |
30 | {{#if readonly}}
31 |
readonly
32 | {{/if}}
33 |
34 |
70 |
71 |
72 | {{{attrDescription}}}
73 |
74 |
75 | {{#if default}}
76 |
Default: {{default}}
77 | {{/if}}
78 |
79 | {{#if emit}}
80 |
81 |
Fires event {{name}}Change
82 |
83 |
84 | Fires when the value for the configuration attribute `{{{name}}}` is
85 | changed. You can listen for the event using the `on` method if you
86 | wish to be notified before the attribute's value has changed, or
87 | using the `after` method if you wish to be notified after the
88 | attribute's value has changed.
89 |
90 |
91 |
92 |
Parameters:
93 |
94 |
128 |
129 |
130 | {{/if}}
131 |
132 | {{#example}}
133 |
134 |
Example:
135 |
136 |
137 | {{{.}}}
138 |
139 |
140 | {{/example}}
141 |
142 |
--------------------------------------------------------------------------------
/build/createjsTheme/partials/classes.handlebars:
--------------------------------------------------------------------------------
1 | {{name}} Class
2 |
39 |
40 | {{#if deprecated}}
41 |
42 |
43 | {{#if deprecationMessage}}
44 | Deprecated: {{deprecationMessage}}
45 | {{else}}
46 | This class is deprecated.
47 | {{/if}}
48 |
49 |
50 | {{/if}}
51 |
52 |
53 | {{{classDescription}}}
54 |
55 |
56 | {{#is_constructor}}
57 |
58 |
Constructor
59 | {{>method}}
60 |
61 | {{/is_constructor}}
62 |
63 |
64 |
65 | Index
66 |
67 | {{#if methods}}
68 | Methods
69 | {{/if}}
70 | {{#if properties}}
71 | Properties
72 | {{/if}}
73 | {{#if attrs}}
74 | Attributes
75 | {{/if}}
76 | {{#if events}}
77 | Events
78 | {{/if}}
79 |
80 |
81 |
82 |
83 |
Item Index
84 |
85 | {{#if methods}}
86 |
87 |
Methods
88 |
89 |
90 | {{#methods}}
91 |
92 | {{name}}
93 |
94 | {{#if static}}
95 | static
96 | {{/if}}
97 | {{#if deprecated}}
98 | deprecated
99 | {{/if}}
100 |
101 | {{/methods}}
102 |
103 |
104 | {{/if}}
105 |
106 | {{#if properties}}
107 |
108 |
Properties
109 |
110 |
111 | {{#properties}}
112 |
113 | {{name}}
114 |
115 | {{#if static}}
116 | static
117 | {{/if}}
118 | {{#if deprecated}}
119 | deprecated
120 | {{/if}}
121 |
122 | {{/properties}}
123 |
124 |
125 | {{/if}}
126 |
127 | {{#if attrs}}
128 |
129 |
Attributes
130 |
131 |
132 | {{#attrs}}
133 |
134 | {{name}}
135 |
136 | {{/attrs}}
137 |
138 |
139 | {{/if}}
140 |
141 | {{#if events}}
142 |
143 |
Events
144 |
145 |
146 | {{#events}}
147 |
148 | {{name}}
149 |
150 | {{#if static}}
151 | static
152 | {{/if}}
153 | {{#if deprecated}}
154 | deprecated
155 | {{/if}}
156 |
157 | {{/events}}
158 |
159 |
160 | {{/if}}
161 |
162 |
163 | {{#if methods}}
164 |
165 |
Methods
166 |
167 | {{#methods}}
168 | {{>method}}
169 | {{/methods}}
170 |
171 | {{/if}}
172 |
173 | {{#if properties}}
174 |
175 |
Properties
176 |
177 | {{#properties}}
178 | {{>props}}
179 | {{/properties}}
180 |
181 | {{/if}}
182 |
183 | {{#if attrs}}
184 |
185 |
Attributes
186 |
187 | {{#attrs}}
188 | {{>attrs}}
189 | {{/attrs}}
190 |
191 | {{/if}}
192 |
193 | {{#if events}}
194 |
195 |
Events
196 |
197 | {{#events}}
198 | {{>events}}
199 | {{/events}}
200 |
201 | {{/if}}
202 |
203 |
204 |
--------------------------------------------------------------------------------
/build/createjsTheme/partials/events.handlebars:
--------------------------------------------------------------------------------
1 |
2 |
{{name}}
3 |
{{#crossLink type}}{{/crossLink}}
4 |
5 | {{#if deprecated}}
6 |
deprecated
7 | {{/if}}
8 |
9 | {{#if access}}
10 |
{{access}}
11 | {{/if}}
12 |
13 | {{#if final}}
14 |
final
15 | {{/if}}
16 |
17 | {{#if static}}
18 |
static
19 | {{/if}}
20 |
21 |
57 |
58 |
59 | {{{eventDescription}}}
60 |
61 |
62 | {{#if params}}
63 |
64 |
Event Payload:
65 |
66 |
124 |
125 | {{/if}}
126 |
127 |
128 | {{#example}}
129 |
130 |
Example:
131 |
132 |
133 | {{{.}}}
134 |
135 |
136 | {{/example}}
137 |
138 |
--------------------------------------------------------------------------------
/build/createjsTheme/partials/files.handlebars:
--------------------------------------------------------------------------------
1 |
4 | File:{{#path name}} {{/path}}
5 |
6 |
7 |
8 | {{fileData}}
9 |
10 |
11 |
--------------------------------------------------------------------------------
/build/createjsTheme/partials/index.handlebars:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/build/createjsTheme/partials/method.handlebars:
--------------------------------------------------------------------------------
1 |
2 |
{{name}}
3 |
4 | {{#if params}}
5 |
6 |
(
7 | {{#params}}
8 |
9 | {{#if optional}}
10 | [{{name}}{{#if optdefault}}={{optdefault}}{{/if}}]
11 | {{else}}
12 | {{name}}
13 | {{/if}}
14 |
15 | {{/params}}
16 | )
17 |
18 | {{else}}
19 |
()
20 | {{/if}}
21 |
22 | {{#if return}}
23 |
24 | {{#crossLink returnType}}{{/crossLink}}
25 |
26 | {{/if}}
27 |
28 | {{#if deprecated}}
29 |
deprecated
30 | {{/if}}
31 |
32 | {{#if access}}
33 |
{{access}}
34 | {{/if}}
35 |
36 | {{#if final}}
37 |
final
38 | {{/if}}
39 |
40 | {{#if static}}
41 |
static
42 | {{/if}}
43 |
44 | {{#if chainable}}
45 |
chainable
46 | {{/if}}
47 |
48 | {{#if async}}
49 |
async
50 | {{/if}}
51 |
52 |
89 |
90 |
91 | {{{methodDescription}}}
92 |
93 |
94 | {{#if params}}
95 |
96 |
Parameters:
97 |
98 |
162 |
163 | {{/if}}
164 |
165 | {{#return}}
166 |
167 |
Returns:
168 |
169 |
170 | {{#if description}}
171 | {{#if type}}
172 | {{#crossLink type}}{{/crossLink}} :
173 | {{/if}}
174 | {{{description}}}
175 | {{else}}
176 | {{#if type}}
177 | {{#crossLink type}}{{/crossLink}} :
178 | {{/if}}
179 | {{/if}}
180 |
181 |
182 | {{/return}}
183 |
184 | {{#example}}
185 |
186 |
Example:
187 |
188 |
189 | {{{.}}}
190 |
191 |
192 | {{/example}}
193 |
194 |
--------------------------------------------------------------------------------
/build/createjsTheme/partials/module.handlebars:
--------------------------------------------------------------------------------
1 | {{name}} Module
2 |
30 |
31 | {{#if deprecated}}
32 |
33 |
34 | {{#if deprecationMessage}}
35 | Deprecated: {{deprecationMessage}}
36 | {{else}}
37 | This module is deprecated.
38 | {{/if}}
39 |
40 |
41 | {{/if}}
42 |
43 |
44 | {{{moduleDescription}}}
45 |
46 |
47 | {{#example}}
48 |
49 |
Example:
50 |
51 | {{{.}}}
52 |
53 |
54 | {{/example}}
55 |
56 |
57 |
58 | {{#if moduleClasses}}
59 |
This module provides the following classes:
60 |
61 |
70 | {{/if}}
71 |
72 |
73 |
74 | {{#if subModules}}
75 |
This module is a rollup of the following modules:
76 |
77 |
90 | {{/if}}
91 |
92 |
93 |
--------------------------------------------------------------------------------
/build/createjsTheme/partials/options.handlebars:
--------------------------------------------------------------------------------
1 |
2 | Show:
3 |
4 |
5 | Inherited
6 |
7 |
8 |
9 |
10 | Protected
11 |
12 |
13 |
14 |
15 | Private
16 |
17 |
18 |
19 | Deprecated
20 |
21 |
22 |
--------------------------------------------------------------------------------
/build/createjsTheme/partials/props.handlebars:
--------------------------------------------------------------------------------
1 |
2 |
{{name}}
3 |
{{#crossLink type}}{{/crossLink}}
4 |
5 | {{#if deprecated}}
6 |
deprecated
7 | {{/if}}
8 |
9 | {{#if access}}
10 |
{{access}}
11 | {{/if}}
12 |
13 | {{#if final}}
14 |
final
15 | {{/if}}
16 |
17 | {{#if static}}
18 |
static
19 | {{/if}}
20 |
21 |
57 |
58 |
59 | {{{propertyDescription}}}
60 |
61 |
62 | {{#if default}}
63 |
Default: {{default}}
64 | {{/if}}
65 |
66 | {{#example}}
67 |
68 |
Example:
69 |
70 |
71 | {{{.}}}
72 |
73 |
74 | {{/example}}
75 |
76 | {{#if subprops}}
77 |
Sub-properties:
78 |
79 |
118 | {{/if}}
119 |
120 |
--------------------------------------------------------------------------------
/build/createjsTheme/partials/sidebar.handlebars:
--------------------------------------------------------------------------------
1 |
2 |
APIs
3 |
4 |
7 |
8 |
9 |
10 |
11 |
12 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/build/createjsTheme/theme.json:
--------------------------------------------------------------------------------
1 | {
2 | "yuiGridsUrl": "../assets/css/yui-cssgrids-min.css",
3 | "yuiSeedUrl": "../assets/js/yui-source.js"
4 | }
5 |
--------------------------------------------------------------------------------
/build/files.json:
--------------------------------------------------------------------------------
1 | {
2 | "core_source": [
3 | "../src/b3.js",
4 | "../src/core/Blackboard.js",
5 | "../src/core/Tick.js",
6 | "../src/core/BehaviorTree.js",
7 | "../src/core/BaseNode.js",
8 | "../src/core/Action.js",
9 | "../src/core/Composite.js",
10 | "../src/core/Decorator.js",
11 | "../src/core/Condition.js",
12 | "../src/composites/Sequence.js",
13 | "../src/composites/Priority.js",
14 | "../src/composites/MemSequence.js",
15 | "../src/composites/MemPriority.js",
16 | "../src/decorators/Inverter.js",
17 | "../src/decorators/Limiter.js",
18 | "../src/decorators/MaxTime.js",
19 | "../src/decorators/Repeater.js",
20 | "../src/decorators/RepeatUntilFailure.js",
21 | "../src/decorators/RepeatUntilSuccess.js",
22 | "../src/actions/Error.js",
23 | "../src/actions/Failer.js",
24 | "../src/actions/Runner.js",
25 | "../src/actions/Succeeder.js",
26 | "../src/actions/Wait.js"
27 | ],
28 | "view_source": [
29 | "../tools/viewer/b3view/View.js",
30 | "../tools/viewer/b3view/data/options.js",
31 | "../tools/viewer/b3view/data/theme_default.js",
32 | "../tools/viewer/b3view/data/theme_dark.js",
33 | "../tools/viewer/b3view/data/theme_light.js",
34 | "../tools/viewer/b3view/draw/shapes.js",
35 | "../tools/viewer/b3view/draw/symbols.js",
36 | "../tools/viewer/b3view/entities/Block.js",
37 | "../tools/viewer/b3view/entities/Connection.js",
38 | "../tools/viewer/b3view/utils/Organizer.js",
39 | "../tools/viewer/b3view/utils/Root.js",
40 | "../tools/viewer/b3view/utils/SettingsManager.js",
41 | "../tools/viewer/b3view/utils/UI.js"
42 | ],
43 | "editor_source": [
44 | "../tools/editor/js/jquery-2.1.1.min.js",
45 | "../tools/editor/js/jquery.ui.min.js",
46 | "../tools/editor/js/easel.min.js",
47 | "../tools/editor/js/creatine-0.2.0dev.min.js",
48 | "../tools/editor/js/font.opensans.js",
49 | "../tools/editor/js/foundation.min.js",
50 | "../tools/editor/js/nano-scroll.js",
51 | "../tools/editor/js/collapsable.js",
52 | "../tools/editor/js/keymaster.js",
53 | "../tools/editor/js/notify.min.js",
54 | "../tools/editor/app/app.js",
55 | "../tools/editor/app/helpers.js",
56 | "../tools/editor/app/events.js",
57 | "../tools/editor/b3editor/Editor.js",
58 | "../tools/editor/b3editor/data/options.js",
59 | "../tools/editor/b3editor/data/shortcuts.js",
60 | "../tools/editor/b3editor/entities/SelectionBox.js",
61 | "../tools/editor/b3editor/systems/CameraSystem.js",
62 | "../tools/editor/b3editor/systems/ConnectionSystem.js",
63 | "../tools/editor/b3editor/systems/DragSystem.js",
64 | "../tools/editor/b3editor/systems/FactorySystem.js",
65 | "../tools/editor/b3editor/systems/SelectionSystem.js",
66 | "../tools/editor/b3editor/utils/UI.js"
67 | ],
68 | "editor_html": [
69 | "../tools/editor/app/views/canvas.html",
70 | "../tools/editor/app/views/left.html",
71 | "../tools/editor/app/views/menu.html",
72 | "../tools/editor/app/views/modal_addnode.html",
73 | "../tools/editor/app/views/modal_editnode.html",
74 | "../tools/editor/app/views/modal_exporttree.html",
75 | "../tools/editor/app/views/modal_importtree.html",
76 | "../tools/editor/app/views/modal_newtree.html",
77 | "../tools/editor/app/views/modal_firsttime.html",
78 | "../tools/editor/app/views/right.html"
79 | ],
80 | "editor_css": [
81 | "../tools/editor/css/normalize.css",
82 | "../tools/editor/css/foundation.min.css",
83 | "../tools/editor/css/nano-scroll.css",
84 | "../tools/editor/css/editor.css"
85 | ]
86 | }
--------------------------------------------------------------------------------
/build/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "Behavior3JS",
3 | "version": "0.2.0dev",
4 | "description": "Behavior3JS",
5 | "url": "http://behaviorjs.guineashots.com",
6 | "logo": "assets/logo.png",
7 | "devDependencies": {
8 | "grunt": "~0.4.1",
9 | "grunt-contrib-concat":"~0.3.0",
10 | "grunt-contrib-uglify": "~0.2.1",
11 | "grunt-contrib-compress": "~0.5.0",
12 | "grunt-contrib-yuidoc": "~0.4.0"
13 | },
14 | "engine": "node >= 0.10.22"
15 | }
--------------------------------------------------------------------------------
/build/path.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | path: function(str) {
3 | return str;//.substr(str.lastIndexOf("/")+1);
4 | }
5 | }
--------------------------------------------------------------------------------
/docs/behavior3js.0.1.0.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/renatopp/behavior3js/4212a70fabc2813c78c1fe21f09ad7ceed149217/docs/behavior3js.0.1.0.zip
--------------------------------------------------------------------------------
/libs/b3core.0.1.0.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/renatopp/behavior3js/4212a70fabc2813c78c1fe21f09ad7ceed149217/libs/b3core.0.1.0.zip
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "behavior3js",
3 | "version": "0.1.0",
4 | "description": "A behavior tree library for JavaScript",
5 | "main": "libs/b3core.0.1.0.min.js",
6 | "directories": {
7 | "doc": "docs",
8 | "example": "examples",
9 | "test": "tests"
10 | },
11 | "scripts": {
12 | "test": "echo \"Error: no test specified\" && exit 1"
13 | },
14 | "repository": {
15 | "type": "git",
16 | "url": "git://github.com/renatopp/behavior3js.git"
17 | },
18 | "keywords": [
19 | "behavior",
20 | "tree",
21 | "behavior",
22 | "tree",
23 | "ai",
24 | "artificial intelligence",
25 | "behavior3",
26 | "b3"
27 | ],
28 | "author": "Renato Pereira (http://guineashots.com/)",
29 | "license": "MIT",
30 | "bugs": {
31 | "url": "https://github.com/renatopp/behavior3js/issues"
32 | },
33 | "homepage": "https://github.com/renatopp/behavior3js"
34 | }
35 |
--------------------------------------------------------------------------------
/src/actions/Error.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Error
3 | *
4 | * Copyright (c) 2014 Renato de Pontes Pereira.
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to
8 | * deal in the Software without restriction, including without limitation the
9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10 | * sell copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
22 | * IN THE SOFTWARE.
23 | **/
24 |
25 | /**
26 | * @module Behavior3JS
27 | **/
28 |
29 | // namespace:
30 | this.b3 = this.b3 || {};
31 |
32 | (function() {
33 | "use strict";
34 |
35 | /**
36 | * This action node returns `ERROR` always.
37 | *
38 | * @class Error
39 | * @extends Action
40 | **/
41 | var Error = b3.Class(b3.Action);
42 |
43 | var p = Error.prototype;
44 |
45 | /**
46 | * Node name. Default to `Error`.
47 | *
48 | * @property name
49 | * @type {String}
50 | * @readonly
51 | **/
52 | p.name = 'Error';
53 |
54 | /**
55 | * Tick method.
56 | *
57 | * @method tick
58 | * @param {b3.Tick} tick A tick instance.
59 | * @returns {Constant} Always return `b3.ERROR`.
60 | **/
61 | p.tick = function(tick) {
62 | return b3.ERROR;
63 | }
64 |
65 | b3.Error = Error;
66 |
67 | })();
--------------------------------------------------------------------------------
/src/actions/Failer.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Failer
3 | *
4 | * Copyright (c) 2014 Renato de Pontes Pereira.
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to
8 | * deal in the Software without restriction, including without limitation the
9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10 | * sell copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
22 | * IN THE SOFTWARE.
23 | **/
24 |
25 | /**
26 | * @module Behavior3JS
27 | **/
28 |
29 | // namespace:
30 | this.b3 = this.b3 || {};
31 |
32 | (function() {
33 | "use strict";
34 |
35 | /**
36 | * This action node returns `FAILURE` always.
37 | *
38 | * @class Failer
39 | * @extends Action
40 | **/
41 | var Failer = b3.Class(b3.Action);
42 |
43 | var p = Failer.prototype;
44 |
45 | /**
46 | * Node name. Default to `Failer`.
47 | *
48 | * @property name
49 | * @type {String}
50 | * @readonly
51 | **/
52 | p.name = 'Failer';
53 |
54 | /**
55 | * Tick method.
56 | *
57 | * @method tick
58 | * @param {b3.Tick} tick A tick instance.
59 | * @returns {Constant} Always return `b3.FAILURE`.
60 | **/
61 | p.tick = function(tick) {
62 | return b3.FAILURE;
63 | }
64 |
65 | b3.Failer = Failer;
66 |
67 | })();
--------------------------------------------------------------------------------
/src/actions/Runner.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Runner
3 | *
4 | * Copyright (c) 2014 Renato de Pontes Pereira.
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to
8 | * deal in the Software without restriction, including without limitation the
9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10 | * sell copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
22 | * IN THE SOFTWARE.
23 | **/
24 |
25 | /**
26 | * @module Behavior3JS
27 | **/
28 |
29 | // namespace:
30 | this.b3 = this.b3 || {};
31 |
32 | (function() {
33 | "use strict";
34 |
35 | /**
36 | * This action node returns RUNNING always.
37 | *
38 | * @class Runner
39 | * @extends Action
40 | **/
41 | var Runner = b3.Class(b3.Action);
42 |
43 | var p = Runner.prototype;
44 |
45 | /**
46 | * Node name. Default to `Runner`.
47 | *
48 | * @property name
49 | * @type {String}
50 | * @readonly
51 | **/
52 | p.name = 'Runner';
53 |
54 | /**
55 | * Tick method.
56 | *
57 | * @method tick
58 | * @param {b3.Tick} tick A tick instance.
59 | * @returns {Constant} Always return `b3.RUNNING`.
60 | **/
61 | p.tick = function(tick) {
62 | return b3.RUNNING;
63 | }
64 |
65 | b3.Runner = Runner;
66 |
67 | })();
--------------------------------------------------------------------------------
/src/actions/Succeeder.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Succeeder
3 | *
4 | * Copyright (c) 2014 Renato de Pontes Pereira.
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to
8 | * deal in the Software without restriction, including without limitation the
9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10 | * sell copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
22 | * IN THE SOFTWARE.
23 | **/
24 |
25 | /**
26 | * @module Behavior3JS
27 | **/
28 |
29 | // namespace:
30 | this.b3 = this.b3 || {};
31 |
32 | (function() {
33 | "use strict";
34 |
35 | /**
36 | * This action node returns `SUCCESS` always.
37 | *
38 | * @class Succeeder
39 | * @extends Action
40 | **/
41 | var Succeeder = b3.Class(b3.Action);
42 |
43 | var p = Succeeder.prototype;
44 |
45 | /**
46 | * Node name. Default to `Succeeder`.
47 | *
48 | * @property name
49 | * @type String
50 | * @readonly
51 | **/
52 | p.name = 'Succeeder';
53 |
54 | /**
55 | * Tick method.
56 | *
57 | * @method tick
58 | * @param {b3.Tick} tick A tick instance.
59 | * @returns {Constant} Always return `b3.SUCCESS`.
60 | **/
61 | p.tick = function(tick) {
62 | return b3.SUCCESS;
63 | }
64 |
65 | b3.Succeeder = Succeeder;
66 |
67 | })();
--------------------------------------------------------------------------------
/src/actions/Wait.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Wait
3 | *
4 | * Copyright (c) 2014 Renato de Pontes Pereira.
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to
8 | * deal in the Software without restriction, including without limitation the
9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10 | * sell copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
22 | * IN THE SOFTWARE.
23 | **/
24 |
25 | /**
26 | * @module Behavior3JS
27 | **/
28 |
29 | // namespace:
30 | this.b3 = this.b3 || {};
31 |
32 | (function() {
33 | "use strict";
34 |
35 | /**
36 | * Wait a few seconds.
37 | *
38 | * @class Wait
39 | * @extends Action
40 | **/
41 | var Wait = b3.Class(b3.Action);
42 |
43 | var p = Wait.prototype;
44 |
45 | /**
46 | * Node name. Default to `Wait`.
47 | *
48 | * @property name
49 | * @type {String}
50 | * @readonly
51 | **/
52 | p.name = 'Wait';
53 |
54 | /**
55 | * Node title. Default to `Wait XXms`. Used in Editor.
56 | *
57 | * @property title
58 | * @type {String}
59 | * @readonly
60 | **/
61 | p.title = 'Wait ms';
62 |
63 | /**
64 | * Node parameters.
65 | *
66 | * @property parameters
67 | * @type {String}
68 | * @readonly
69 | **/
70 | p.parameters = {'milliseconds': 0};
71 |
72 | p.__Action_initialize = p.initialize;
73 | /**
74 | * Initialization method.
75 | *
76 | * Settings parameters:
77 | *
78 | * - **milliseconds** (*Integer*) Maximum time, in milliseconds, a child
79 | * can execute.
80 | *
81 | * @method initialize
82 | * @param {Object} settings Object with parameters.
83 | * @constructor
84 | **/
85 | p.initialize = function(settings) {
86 | settings = settings || {};
87 |
88 | this.__Action_initialize();
89 |
90 | this.endTime = settings.milliseconds || 0;
91 | }
92 |
93 | /**
94 | * Open method.
95 | *
96 | * @method open
97 | * @param {Tick} tick A tick instance.
98 | **/
99 | p.open = function(tick) {
100 | var startTime = (new Date()).getTime();
101 | tick.blackboard.set('startTime', startTime, tick.tree.id, this.id);
102 | }
103 |
104 | /**
105 | * Tick method.
106 | *
107 | * @method tick
108 | * @param {Tick} tick A tick instance.
109 | * @returns {Constant} A state constant.
110 | **/
111 | p.tick = function(tick) {
112 | var currTime = (new Date()).getTime();
113 | var startTime = tick.blackboard.get('startTime', tick.tree.id, this.id);
114 |
115 | if (currTime - startTime > this.endTime) {
116 | return b3.SUCCESS;
117 | }
118 |
119 | return b3.RUNNING;
120 | }
121 |
122 | b3.Wait = Wait;
123 |
124 | })();
--------------------------------------------------------------------------------
/src/b3.js:
--------------------------------------------------------------------------------
1 | /**
2 | * b3
3 | *
4 | * Copyright (c) 2014 Renato de Pontes Pereira.
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to
8 | * deal in the Software without restriction, including without limitation the
9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10 | * sell copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
22 | * IN THE SOFTWARE.
23 | **/
24 |
25 | this.b3 = this.b3 || {};
26 |
27 | /**
28 | * Behavior3JS
29 | * ===========
30 | *
31 | * * * *
32 | *
33 | * **Behavior3JS** is a Behavior Tree library written in JavaScript. It
34 | * provides structures and algorithms that assist you in the task of creating
35 | * intelligent agents for your game or application. Check it out some features
36 | * of Behavior3JS:
37 | *
38 | * - Based on the work of (Marzinotto et al., 2014), in which they propose a
39 | * **formal**, **consistent** and **general** definition of Behavior Trees;
40 | * - **Optimized to control multiple agents**: you can use a single behavior
41 | * tree instance to handle hundreds of agents;
42 | * - It was **designed to load and save trees in a JSON format**, in order to
43 | * use, edit and test it in multiple environments, tools and languages;
44 | * - A **cool visual editor** which you can access online;
45 | * - Several **composite, decorator and action nodes** available within the
46 | * library. You still can define your own nodes, including composites and
47 | * decorators;
48 | * - **Completely free**, the core module and the visual editor are all published
49 | * under the MIT License, which means that you can use them for your open source
50 | * and commercial projects;
51 | * - **Lightweight**, only 11.5KB!
52 | *
53 | * Visit http://behavior3js.guineashots.com to know more!
54 | *
55 | *
56 | * Core Classes and Functions
57 | * --------------------------
58 | *
59 | * This library include the following core structures...
60 | *
61 | * **Public:**
62 | *
63 | * - **BehaviorTree**: the structure that represents a Behavior Tree;
64 | * - **Blackboard**: represents a "memory" in an agent and is required to to
65 | * run a `BehaviorTree`;
66 | * - **Composite**: base class for all composite nodes;
67 | * - **Decorator**: base class for all decorator nodes;
68 | * - **Action**: base class for all action nodes;
69 | * - **Condition**: base class for all condition nodes;
70 | *
71 | * **Internal:**
72 | *
73 | *
74 | * - **Tick**: used as container and tracking object through the tree during
75 | * the tick signal;
76 | * - **BaseNode**: the base class that provide all common node features;
77 | *
78 | * *Some classes are used internally on Behavior3JS, but you may need to access
79 | * its functionalities eventually, specially the `Tick` object.*
80 | *
81 | *
82 | * Nodes Included
83 | * --------------
84 | *
85 | * **Composite Nodes**:
86 | *
87 | * - Sequence;
88 | * - Priority;
89 | * - MemSequence;
90 | * - MemPriority;
91 | *
92 | *
93 | * **Decorators**:
94 | *
95 | * - Inverter;
96 | * - Limiter
97 | * - MaxTime;
98 | * - Repeater;
99 | * - RepeaterUntilFailure;
100 | * - RepeaterUntilSuccess;
101 | *
102 | *
103 | * **Actions**:
104 | *
105 | * - Succeeder;
106 | * - Failer;
107 | * - Error;
108 | * - Runner;
109 | * - Wait.
110 | *
111 | * @module Behavior3JS
112 | * @main Behavior3JS
113 | **/
114 |
115 | (function() {
116 | "use strict";
117 |
118 | /**
119 | * List of all constants in Behavior3JS.
120 | *
121 | * @class Constants
122 | **/
123 |
124 | /**
125 | * Version of the library.
126 | *
127 | * @property VERSION
128 | * @type {String}
129 | */
130 | b3.VERSION = '0.1.0';
131 |
132 | /**
133 | * Returned when a criterion has been met by a condition node or an action node
134 | * has been completed successfully.
135 | *
136 | * @property SUCCESS
137 | * @type {Integer}
138 | */
139 | b3.SUCCESS = 1;
140 |
141 | /**
142 | * Returned when a criterion has not been met by a condition node or an action
143 | * node could not finish its execution for any reason.
144 | *
145 | * @property FAILURE
146 | * @type {Integer}
147 | */
148 | b3.FAILURE = 2;
149 |
150 | /**
151 | * Returned when an action node has been initialized but is still waiting the
152 | * its resolution.
153 | *
154 | * @property FAILURE
155 | * @type {Integer}
156 | */
157 | b3.RUNNING = 3;
158 |
159 | /**
160 | * Returned when some unexpected error happened in the tree, probably by a
161 | * programming error (trying to verify an undefined variable). Its use depends
162 | * on the final implementation of the leaf nodes.
163 | *
164 | * @property ERROR
165 | * @type {Integer}
166 | */
167 | b3.ERROR = 4;
168 |
169 |
170 | /**
171 | * Describes the node category as Composite.
172 | *
173 | * @property COMPOSITE
174 | * @type {String}
175 | */
176 | b3.COMPOSITE = 'composite';
177 |
178 | /**
179 | * Describes the node category as Decorator.
180 | *
181 | * @property DECORATOR
182 | * @type {String}
183 | */
184 | b3.DECORATOR = 'decorator';
185 |
186 | /**
187 | * Describes the node category as Action.
188 | *
189 | * @property ACTION
190 | * @type {String}
191 | */
192 | b3.ACTION = 'action';
193 |
194 | /**
195 | * Describes the node category as Condition.
196 | *
197 | * @property CONDITION
198 | * @type {String}
199 | */
200 | b3.CONDITION = 'condition';
201 |
202 |
203 | /**
204 | * List of internal and helper functions in Behavior3JS.
205 | *
206 | * @class Utils
207 | **/
208 |
209 |
210 | /**
211 | * This function is used to create unique IDs for trees and nodes.
212 | *
213 | * (consult http://www.ietf.org/rfc/rfc4122.txt).
214 | *
215 | * @method createUUID
216 | * @return {String} A unique ID.
217 | **/
218 | b3.createUUID = function() {
219 | var s = [];
220 | var hexDigits = "0123456789abcdef";
221 | for (var i = 0; i < 36; i++) {
222 | s[i] = hexDigits.substr(Math.floor(Math.random() * 0x10), 1);
223 | }
224 | // bits 12-15 of the time_hi_and_version field to 0010
225 | s[14] = "4";
226 |
227 | // bits 6-7 of the clock_seq_hi_and_reserved to 01
228 | s[19] = hexDigits.substr((s[19] & 0x3) | 0x8, 1);
229 |
230 | s[8] = s[13] = s[18] = s[23] = "-";
231 |
232 | var uuid = s.join("");
233 | return uuid;
234 | }
235 |
236 | /**
237 | * Class is a meta-factory function to create classes in JavaScript. It is a
238 | * shortcut for the CreateJS syntax style. By default, the class created by
239 | * this function have an initialize function (the constructor). Optionally, you
240 | * can specify the inheritance by passing another class as parameter.
241 | *
242 | * By default, all classes created using this function, may receives only a
243 | * settings parameter as argument. This pattern is commonly used by jQuery and
244 | * its plugins.
245 | *
246 | * Usage
247 | * -----
248 | *
249 | * // Creating a simple class
250 | * var BaseClass = b3.Class();
251 | *
252 | * // Using inheritance
253 | * var ChildClass = b3.Class(BaseClass);
254 | *
255 | * // Defining the constructor
256 | * ChildClass.prototype.initialize = function(settings) { ... }
257 | *
258 | * @method Class
259 | * @param {Object} [baseClass] The super class.
260 | * @return {Object} A new class.
261 | **/
262 | b3.Class = function(baseClass) {
263 | // create a new class
264 | var cls = function(params) {
265 | this.initialize(params);
266 | };
267 |
268 | // if base class is provided, inherit
269 | if (baseClass) {
270 | cls.prototype = Object.create(baseClass.prototype);
271 | cls.prototype.constructor = cls;
272 | }
273 |
274 | // create initialize if does not exist on baseClass
275 | if(!cls.prototype.initialize) {
276 | cls.prototype.initialize = function() {};
277 | }
278 |
279 | return cls;
280 | }
281 |
282 | })();
--------------------------------------------------------------------------------
/src/composites/MemPriority.js:
--------------------------------------------------------------------------------
1 | /**
2 | * MemPriority
3 | *
4 | * Copyright (c) 2014 Renato de Pontes Pereira.
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to
8 | * deal in the Software without restriction, including without limitation the
9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10 | * sell copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
22 | * IN THE SOFTWARE.
23 | **/
24 |
25 | /**
26 | * @module Behavior3JS
27 | **/
28 |
29 | // namespace:
30 | this.b3 = this.b3 || {};
31 |
32 | (function() {
33 | "use strict";
34 |
35 | /**
36 | * MemPriority is similar to Priority node, but when a child returns a
37 | * `RUNNING` state, its index is recorded and in the next tick the, MemPriority
38 | * calls the child recorded directly, without calling previous children again.
39 | *
40 | * @class MemPriority
41 | * @extends Composite
42 | **/
43 | var MemPriority = b3.Class(b3.Composite);
44 |
45 | var p = MemPriority.prototype;
46 |
47 | /**
48 | * Node name. Default to `MemPriority`.
49 | *
50 | * @property name
51 | * @type {String}
52 | * @readonly
53 | **/
54 | p.name = 'MemPriority';
55 |
56 | /**
57 | * Open method.
58 | *
59 | * @method open
60 | * @param {b3.Tick} tick A tick instance.
61 | **/
62 | p.open = function(tick) {
63 | tick.blackboard.set('runningChild', 0, tick.tree.id, this.id);
64 | }
65 |
66 | /**
67 | * Tick method.
68 | *
69 | * @method tick
70 | * @param {b3.Tick} tick A tick instance.
71 | * @returns {Constant} A state constant.
72 | **/
73 | p.tick = function(tick) {
74 | var child = tick.blackboard.get('runningChild', tick.tree.id, this.id);
75 | for (var i=child; i this.maxTime) {
128 | return b3.FAILURE;
129 | }
130 |
131 | return status;
132 | };
133 |
134 | b3.MaxTime = MaxTime;
135 |
136 | })();
--------------------------------------------------------------------------------
/src/decorators/RepeatUntilFailure.js:
--------------------------------------------------------------------------------
1 | /**
2 | * RepeatUntilFailure
3 | *
4 | * Copyright (c) 2014 Renato de Pontes Pereira.
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to
8 | * deal in the Software without restriction, including without limitation the
9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10 | * sell copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
22 | * IN THE SOFTWARE.
23 | **/
24 |
25 | /**
26 | * @module Behavior3JS
27 | **/
28 |
29 | // namespace:
30 | this.b3 = this.b3 || {};
31 |
32 | (function() {
33 | "use strict";
34 |
35 | /**
36 | * RepeatUntilFailure is a decorator that repeats the tick signal until the
37 | * node child returns `FAILURE`, `RUNNING` or `ERROR`. Optionally, a maximum
38 | * number of repetitions can be defined.
39 | *
40 | * @class RepeatUntilFailure
41 | * @extends Decorator
42 | **/
43 | var RepeatUntilFailure = b3.Class(b3.Decorator);
44 |
45 | var p = RepeatUntilFailure.prototype;
46 |
47 | /**
48 | * Node name. Default to `RepeatUntilFailure`.
49 | *
50 | * @property name
51 | * @type {String}
52 | * @readonly
53 | **/
54 | p.name = 'RepeatUntilFailure';
55 |
56 | /**
57 | * Node title. Default to `Repeat Until Failure`.
58 | *
59 | * @property title
60 | * @type {String}
61 | * @readonly
62 | **/
63 | p.title = 'Repeat Until Failure';
64 |
65 | /**
66 | * Node parameters.
67 | *
68 | * @property parameters
69 | * @type {String}
70 | * @readonly
71 | **/
72 | p.parameters = {'maxLoop': -1};
73 |
74 | p.__Decorator_initialize = p.initialize;
75 | /**
76 | * Initialization method.
77 | *
78 | * Settings parameters:
79 | *
80 | * - **maxLoop** (*Integer*) Maximum number of repetitions. Default to -1
81 | * (infinite).
82 | * - **child** (*BaseNode*) The child node.
83 | *
84 | * @method initialize
85 | * @param {Object} settings Object with parameters.
86 | * @constructor
87 | **/
88 | p.initialize = function(settings) {
89 | settings = settings || {};
90 |
91 | this.__Decorator_initialize(settings);
92 |
93 | this.maxLoop = settings.maxLoop || -1;
94 | }
95 |
96 | /**
97 | * Open method.
98 | *
99 | * @method open
100 | * @param {Tick} tick A tick instance.
101 | **/
102 | p.open = function(tick) {
103 | tick.blackboard.set('i', 0, tick.tree.id, this.id);
104 | }
105 |
106 | /**
107 | * Tick method.
108 | *
109 | * @method tick
110 | * @param {Tick} tick A tick instance.
111 | * @returns {Constant} A state constant.
112 | **/
113 | p.tick = function(tick) {
114 | if (!this.child) {
115 | return b3.ERROR;
116 | }
117 |
118 | var i = tick.blackboard.get('i', tick.tree.id, this.id);
119 |
120 | while (this.maxLoop < 0 || i < this.maxLoop) {
121 | var status = this.child._execute(tick);
122 |
123 | if (status == b3.SUCCESS)
124 | i++;
125 | else
126 | break;
127 | }
128 |
129 | var i = tick.blackboard.set('i', i, tick.tree.id, this.id);
130 | return status;
131 | }
132 |
133 | b3.RepeatUntilFailure = RepeatUntilFailure;
134 |
135 | })();
--------------------------------------------------------------------------------
/src/decorators/RepeatUntilSuccess.js:
--------------------------------------------------------------------------------
1 | /**
2 | * RepeatUntilSuccess
3 | *
4 | * Copyright (c) 2014 Renato de Pontes Pereira.
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to
8 | * deal in the Software without restriction, including without limitation the
9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10 | * sell copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
22 | * IN THE SOFTWARE.
23 | **/
24 |
25 | /**
26 | * @module Behavior3JS
27 | **/
28 |
29 | // namespace:
30 | this.b3 = this.b3 || {};
31 |
32 | (function() {
33 | "use strict";
34 |
35 | /**
36 | * RepeatUntilSuccess is a decorator that repeats the tick signal until the
37 | * node child returns `SUCCESS`, `RUNNING` or `ERROR`. Optionally, a maximum
38 | * number of repetitions can be defined.
39 | *
40 | * @class RepeatUntilSuccess
41 | * @extends Decorator
42 | **/
43 | var RepeatUntilSuccess = b3.Class(b3.Decorator);
44 |
45 | var p = RepeatUntilSuccess.prototype;
46 |
47 | /**
48 | * Node name. Default to `RepeatUntilSuccess`.
49 | *
50 | * @property name
51 | * @type {String}
52 | * @readonly
53 | **/
54 | p.name = 'RepeatUntilSuccess';
55 |
56 | /**
57 | * Node title. Default to `Repeat Until Success`.
58 | *
59 | * @property title
60 | * @type {String}
61 | * @readonly
62 | **/
63 | p.title = 'Repeat Until Success';
64 |
65 | /**
66 | * Node parameters.
67 | *
68 | * @property parameters
69 | * @type {String}
70 | * @readonly
71 | **/
72 | p.parameters = {'maxLoop': -1};
73 |
74 | p.__Decorator_initialize = p.initialize;
75 | /**
76 | * Initialization method.
77 | *
78 | * Settings parameters:
79 | *
80 | * - **maxLoop** (*Integer*) Maximum number of repetitions. Default to -1
81 | * (infinite).
82 | * - **child** (*BaseNode*) The child node.
83 | *
84 | * @method initialize
85 | * @param {Object} settings Object with parameters.
86 | * @constructor
87 | **/
88 | p.initialize = function(settings) {
89 | settings = settings || {};
90 |
91 | this.__Decorator_initialize(settings);
92 |
93 | this.maxLoop = settings.maxLoop || -1;
94 | }
95 |
96 | /**
97 | * Open method.
98 | *
99 | * @method open
100 | * @param {Tick} tick A tick instance.
101 | **/
102 | p.open = function(tick) {
103 | tick.blackboard.set('i', 0, tick.tree.id, this.id);
104 | }
105 |
106 | /**
107 | * Tick method.
108 | *
109 | * @method tick
110 | * @param {Tick} tick A tick instance.
111 | * @returns {Constant} A state constant.
112 | **/
113 | p.tick = function(tick) {
114 | if (!this.child) {
115 | return b3.ERROR;
116 | }
117 |
118 | var i = tick.blackboard.get('i', tick.tree.id, this.id);
119 |
120 | while (this.maxLoop < 0 || i < this.maxLoop) {
121 | var status = this.child._execute(tick);
122 |
123 | if (status == b3.FAILURE)
124 | i++;
125 | else
126 | break;
127 | }
128 |
129 | var i = tick.blackboard.set('i', i, tick.tree.id, this.id);
130 | return status;
131 | }
132 |
133 | b3.RepeatUntilSuccess = RepeatUntilSuccess;
134 |
135 | })();
--------------------------------------------------------------------------------
/src/decorators/Repeater.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Repeater
3 | *
4 | * Copyright (c) 2014 Renato de Pontes Pereira.
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to
8 | * deal in the Software without restriction, including without limitation the
9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10 | * sell copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
22 | * IN THE SOFTWARE.
23 | **/
24 |
25 | /**
26 | * @module Behavior3JS
27 | **/
28 |
29 | // namespace:
30 | this.b3 = this.b3 || {};
31 |
32 | (function() {
33 | "use strict";
34 |
35 | /**
36 | * Repeater is a decorator that repeats the tick signal until the child node
37 | * return `RUNNING` or `ERROR`. Optionally, a maximum number of repetitions
38 | * can be defined.
39 | *
40 | * @class Repeater
41 | * @extends Decorator
42 | **/
43 | var Repeater = b3.Class(b3.Decorator);
44 |
45 | var p = Repeater.prototype;
46 |
47 | /**
48 | * Node name. Default to `Repeater`.
49 | *
50 | * @property name
51 | * @type {String}
52 | * @readonly
53 | **/
54 | p.name = 'Repeater';
55 |
56 | /**
57 | * Node title. Default to `Repeat XXx`. Used in Editor.
58 | *
59 | * @property title
60 | * @type {String}
61 | * @readonly
62 | **/
63 | p.title = 'Repeat x';
64 |
65 | /**
66 | * Node parameters.
67 | *
68 | * @property parameters
69 | * @type {String}
70 | * @readonly
71 | **/
72 | p.parameters = {'maxLoop': -1};
73 |
74 | p.__Decorator_initialize = p.initialize;
75 | /**
76 | * Initialization method.
77 | *
78 | * Settings parameters:
79 | *
80 | * - **maxLoop** (*Integer*) Maximum number of repetitions. Default to -1
81 | * (infinite).
82 | * - **child** (*BaseNode*) The child node.
83 | *
84 | * @method initialize
85 | * @param {Object} settings Object with parameters.
86 | * @constructor
87 | **/
88 | p.initialize = function(settings) {
89 | settings = settings || {};
90 |
91 | this.__Decorator_initialize(settings);
92 |
93 | this.maxLoop = settings.maxLoop || -1;
94 | };
95 |
96 | /**
97 | * Open method.
98 | *
99 | * @method open
100 | * @param {Tick} tick A tick instance.
101 | **/
102 | p.open = function(tick) {
103 | tick.blackboard.set('i', 0, tick.tree.id, this.id);
104 | };
105 |
106 | /**
107 | * Tick method.
108 | *
109 | * @method tick
110 | * @param {Tick} tick A tick instance.
111 | **/
112 | p.tick = function(tick) {
113 | if (!this.child) {
114 | return b3.ERROR;
115 | }
116 |
117 | var i = tick.blackboard.get('i', tick.tree.id, this.id);
118 | var status = b3.SUCCESS;
119 |
120 | while (this.maxLoop < 0 || i < this.maxLoop) {
121 | status = this.child._execute(tick);
122 |
123 | if (status == b3.SUCCESS || status == b3.FAILURE)
124 | i++;
125 | else
126 | break;
127 | }
128 |
129 | i = tick.blackboard.set('i', i, tick.tree.id, this.id);
130 | return status;
131 | };
132 |
133 | b3.Repeater = Repeater;
134 |
135 | })();
--------------------------------------------------------------------------------
/tests/mocha.css:
--------------------------------------------------------------------------------
1 | @charset "utf-8";
2 |
3 | body {
4 | font: 20px/1.5 "Helvetica Neue", Helvetica, Arial, sans-serif;
5 | padding: 0px 50px;
6 | }
7 |
8 | #mocha ul, #mocha li {
9 | margin: 0;
10 | padding: 0;
11 | }
12 |
13 | #mocha ul {
14 | list-style: none;
15 | }
16 |
17 | #mocha h1, #mocha h2 {
18 | margin: 0;
19 | }
20 |
21 | #mocha h1 {
22 | margin-top: 15px;
23 | font-size: 1em;
24 | font-weight: 200;
25 | }
26 |
27 | #mocha h1 a {
28 | text-decoration: none;
29 | color: inherit;
30 | }
31 |
32 | #mocha h1 a:hover {
33 | text-decoration: underline;
34 | }
35 |
36 | #mocha .suite .suite h1 {
37 | margin-top: 0;
38 | font-size: .8em;
39 | }
40 |
41 | .hidden {
42 | display: none;
43 | }
44 |
45 | #mocha h2 {
46 | font-size: 12px;
47 | font-weight: normal;
48 | cursor: pointer;
49 | }
50 |
51 | #mocha .suite {
52 | margin-left: 15px;
53 | }
54 |
55 | #mocha .test {
56 | margin-left: 15px;
57 | overflow: hidden;
58 | }
59 |
60 | #mocha .test.pending:hover h2::after {
61 | content: '(pending)';
62 | font-family: arial;
63 | }
64 |
65 | #mocha .test.pass.medium .duration {
66 | background: #C09853;
67 | }
68 |
69 | #mocha .test.pass.slow .duration {
70 | background: #B94A48;
71 | }
72 |
73 | #mocha .test.pass::before {
74 | content: '✓';
75 | font-size: 12px;
76 | display: block;
77 | float: left;
78 | margin-right: 5px;
79 | color: #00d6b2;
80 | }
81 |
82 | #mocha .test.pass .duration {
83 | font-size: 9px;
84 | margin-left: 5px;
85 | padding: 2px 5px;
86 | color: white;
87 | -webkit-box-shadow: inset 0 1px 1px rgba(0,0,0,.2);
88 | -moz-box-shadow: inset 0 1px 1px rgba(0,0,0,.2);
89 | box-shadow: inset 0 1px 1px rgba(0,0,0,.2);
90 | -webkit-border-radius: 5px;
91 | -moz-border-radius: 5px;
92 | -ms-border-radius: 5px;
93 | -o-border-radius: 5px;
94 | border-radius: 5px;
95 | }
96 |
97 | #mocha .test.pass.fast .duration {
98 | display: none;
99 | }
100 |
101 | #mocha .test.pending {
102 | color: #0b97c4;
103 | }
104 |
105 | #mocha .test.pending::before {
106 | content: '◦';
107 | color: #0b97c4;
108 | }
109 |
110 | #mocha .test.fail {
111 | color: #c00;
112 | }
113 |
114 | #mocha .test.fail pre {
115 | color: black;
116 | }
117 |
118 | #mocha .test.fail::before {
119 | content: '✖';
120 | font-size: 12px;
121 | display: block;
122 | float: left;
123 | margin-right: 5px;
124 | color: #c00;
125 | }
126 |
127 | #mocha .test pre.error {
128 | color: #c00;
129 | max-height: 300px;
130 | overflow: auto;
131 | }
132 |
133 | #mocha .test pre {
134 | display: block;
135 | float: left;
136 | clear: left;
137 | font: 12px/1.5 monaco, monospace;
138 | margin: 5px;
139 | padding: 15px;
140 | border: 1px solid #eee;
141 | border-bottom-color: #ddd;
142 | -webkit-border-radius: 3px;
143 | -webkit-box-shadow: 0 1px 3px #eee;
144 | -moz-border-radius: 3px;
145 | -moz-box-shadow: 0 1px 3px #eee;
146 | }
147 |
148 | #mocha .test h2 {
149 | position: relative;
150 | }
151 |
152 | #mocha .test a.replay {
153 | position: absolute;
154 | top: 3px;
155 | right: 0;
156 | text-decoration: none;
157 | vertical-align: middle;
158 | display: block;
159 | width: 15px;
160 | height: 15px;
161 | line-height: 15px;
162 | text-align: center;
163 | background: #eee;
164 | font-size: 15px;
165 | -moz-border-radius: 15px;
166 | border-radius: 15px;
167 | -webkit-transition: opacity 200ms;
168 | -moz-transition: opacity 200ms;
169 | transition: opacity 200ms;
170 | opacity: 0.3;
171 | color: #888;
172 | }
173 |
174 | #mocha .test:hover a.replay {
175 | opacity: 1;
176 | }
177 |
178 | #mocha-report.pass .test.fail {
179 | display: none;
180 | }
181 |
182 | #mocha-report.fail .test.pass {
183 | display: none;
184 | }
185 |
186 | #mocha-error {
187 | color: #c00;
188 | font-size: 1.5 em;
189 | font-weight: 100;
190 | letter-spacing: 1px;
191 | }
192 |
193 | #mocha-stats {
194 | position: fixed;
195 | top: 15px;
196 | left: 10px;
197 | background: #D2D2D2;
198 | border: 1px solid #999;
199 | text-align: center;
200 | padding: 5px 0px;
201 | width: 55px;
202 | font-size: 12px;
203 | margin: 0;
204 | color: #333;
205 | }
206 |
207 | #mocha-stats .progress {
208 | /*float: lef;*/
209 | /*padding-top: 15;*/
210 | }
211 |
212 | #mocha-stats em {
213 | color: #000;
214 | font-weight: bold;
215 | }
216 |
217 | #mocha-stats a {
218 | text-decoration: none;
219 | color: inherit;
220 | }
221 |
222 | #mocha-stats a:hover {
223 | border-bottom: 1px solid #333;
224 | }
225 |
226 | #mocha-stats li {
227 | display: inline-block;
228 | margin: 0 0px;
229 | list-style: none;
230 | padding: 5px;
231 | }
232 | #mocha-stats li:first-child {
233 | padding-top: 10px;
234 | }
235 | #mocha-stats li:last-child {
236 | padding-bottom: 10px;
237 | }
238 |
239 | code .comment { color: #ddd }
240 | code .init { color: #2F6FAD }
241 | code .string { color: #5890AD }
242 | code .keyword { color: #8A6343 }
243 | code .number { color: #2F6FAD }
244 |
--------------------------------------------------------------------------------
/tests/sinon-chai.js:
--------------------------------------------------------------------------------
1 | (function (sinonChai) {
2 | "use strict";
3 |
4 | // Module systems magic dance.
5 |
6 | if (typeof require === "function" && typeof exports === "object" && typeof module === "object") {
7 | // NodeJS
8 | module.exports = sinonChai;
9 | } else if (typeof define === "function" && define.amd) {
10 | // AMD
11 | define(function () {
12 | return sinonChai;
13 | });
14 | } else {
15 | // Other environment (usually
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
128 |