Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Repeat and Retry nodes use options.random in selecting iteration and attempt counts when min and max count node arguments are defined #79

Merged
merged 4 commits into from
Sep 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +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 operations such as the selection of active children for any `lotto` nodes and the selection of durations for `wait` nodes when minimum and maximum durations are defined. 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. |
| 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 operations such as the selection of active children for any `lotto` nodes as well as the selection of durations for `wait` nodes, iterations for `repeat` nodes and attempts for `retry` nodes when minimum and maximum bounds are defined. 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 Expand Up @@ -666,6 +666,7 @@ A practical look at behaviour trees and a good example of modelling behaviour fo
## Version History
| Version | Notes |
| -------------- |:----------------------------------------------------------------------------------------|
| 3.2.0 | The 'random' function option is used for iteration and attempt selection for `repeat` and `retry` nodes respectively when minimum and maximum bounds are defined |
| 3.1.0 | Added 'random' function option to allow users to provide psuedo-random numbers for use in operations such as `lotto` node child selection and wait node duration selection when a minimum and maximum duration are defined. Wait nodes will now remain in the running state indefinitely until they are aborted if no duration is defined for them |
| 3.0.0 | Converted to Typescript |
| 2.3.0 | Added Global Functions and Subtrees |
Expand Down
17 changes: 12 additions & 5 deletions dist/RootAstNodesBuilder.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,17 @@ export type RootAstNode = DecoratorAstNode<Root> & {
type: "root";
name: null | string;
};
export type IterableAstNode = DecoratorAstNode<Repeat | Retry> & {
type: "repeat" | "retry";
iterations: null | number;
maximumIterations: null | number;
export type RepeatAstNode = DecoratorAstNode<Repeat> & {
type: "repeat";
iterations: number | null;
iterationsMin: number | null;
iterationsMax: number | null;
};
export type RetryAstNode = DecoratorAstNode<Retry> & {
type: "retry";
attempts: number | null;
attemptsMin: number | null;
attemptsMax: number | null;
};
export type ActionAstNode = LeafAstNode<Action> & {
type: "action";
Expand All @@ -87,7 +94,7 @@ export type WaitAstNode = LeafAstNode<Wait> & {
durationMin: number | null;
durationMax: number | null;
};
export type AnyAstNode = BranchAstNode | CompositeAstNode | LottoAstNode | DecoratorAstNode | RootAstNode | IterableAstNode | LeafAstNode | ActionAstNode | ConditionAstNode | WaitAstNode;
export type AnyAstNode = BranchAstNode | CompositeAstNode | LottoAstNode | DecoratorAstNode | RootAstNode | RepeatAstNode | RetryAstNode | LeafAstNode | ActionAstNode | ConditionAstNode | WaitAstNode;
/**
* Create an array of root AST nodes based on the given definition.
* @param definition The definition to parse the AST nodes from.
Expand Down
163 changes: 96 additions & 67 deletions dist/bundle.js

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

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

Large diffs are not rendered by default.

Loading