Skip to content

Commit

Permalink
Merge pull request #72 from nikkorn/#62
Browse files Browse the repository at this point in the history
Added 'random' function as tree option for use by 'wait' nodes
  • Loading branch information
nikkorn committed Feb 4, 2023
2 parents 1178c00 + 36909f6 commit d1bf549
Show file tree
Hide file tree
Showing 13 changed files with 659 additions and 154 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ The `BehaviourTree` constructor can take an options object as an argument, the p
| Option |Type | Description |
| :--------------------|:- |:- |
| getDeltaTime |() => number| A function returning a delta time in seconds that is used to calculate the elapsed duration of any `wait` nodes. If this function is not defined then `Date().getTime()` is used instead by default. |
| random |() => number| A function returning a floating-point number between 0 (inclusive) and 1 (exclusive). If defined, this function is used to source a pseudo-random number to use in the selection of active children for any `lotto` nodes. If not defined then `Math.random` will be used instead by default. This function can be useful in seeding all random numbers used in the running of a tree instance to make any behaviour completely deterministic. |

# Nodes

Expand Down
7 changes: 6 additions & 1 deletion dist/behaviourTreeOptions.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,13 @@
*/
export interface BehaviourTreeOptions {
/**
* Gets the delta time to use in seconds.
* Gets a delta time in seconds that is used to calculate the elapsed duration of any wait nodes.
* @returns The delta time to use in seconds.
*/
getDeltaTime?(): number;
/**
* Gets a pseudo-random floating-point number between 0 (inclusive) and 1 (exclusive) for use in the selection of active children for any lotto nodes.
* @returns A floating-point number between 0 (inclusive) and 1 (exclusive)
*/
random?(): number;
}
272 changes: 240 additions & 32 deletions dist/bundle.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions dist/bundle.js.map

Large diffs are not rendered by default.

Loading

0 comments on commit d1bf549

Please sign in to comment.