Skip to content

Commit

Permalink
Tidying
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikolas Howard committed Mar 9, 2024
1 parent 261eef4 commit 211d540
Show file tree
Hide file tree
Showing 11 changed files with 124 additions and 96 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ 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 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. |
| 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.prototype.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 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
15 changes: 12 additions & 3 deletions dist/BehaviourTreeDefinition.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*/
export interface NodeAttributeDefinition {
/**
* The name of the agent function to invoke.
* The name of the agent function or globally registered function to invoke.
*/
call: string;
/**
Expand Down Expand Up @@ -80,7 +80,7 @@ export interface ActionNodeDefinition extends NodeDefinition {
*/
type: "action";
/**
* The name of the agent function or registered function to invoke.
* The name of the agent function or globally registered function to invoke.
*/
call: string;
/**
Expand All @@ -97,7 +97,7 @@ export interface ConditionNodeDefinition extends NodeDefinition {
*/
type: "condition";
/**
* The name of the agent function or registered function to invoke.
* The name of the agent function or globally registered function to invoke.
*/
call: string;
/**
Expand All @@ -113,6 +113,9 @@ export interface WaitNodeDefinition extends NodeDefinition {
* The node type.
*/
type: "wait";
/**
* The duration to wait in milliseconds if defined as a single integer, or the lower and upper duration bounds if defined as an array containing two integer values.
*/
duration?: number | [number, number];
}
/**
Expand Down Expand Up @@ -176,6 +179,9 @@ export interface RepeatNodeDefinition extends DecoratorNodeDefinition {
* The node type.
*/
type: "repeat";
/**
* The number of iterations to make if defined as a single number, or the lower and upper iteration bounds if defined as an array containing two integer values.
*/
iterations?: number | [number, number];
}
/**
Expand All @@ -186,6 +192,9 @@ export interface RetryNodeDefinition extends DecoratorNodeDefinition {
* The node type.
*/
type: "retry";
/**
* The number of attempts to make if defined as a single number, or the lower and upper attempt bounds if defined as an array containing two integer values.
*/
attempts?: number | [number, number];
}
/**
Expand Down
9 changes: 7 additions & 2 deletions dist/BehaviourTreeOptions.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,17 @@
*/
export interface BehaviourTreeOptions {
/**
* Gets a delta time in seconds that is used to calculate the elapsed duration of any wait nodes.
* Gets 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.prototype.getTime()` will be used instead by default.
* @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.
* Gets a pseudo-random floating-point number between 0 (inclusive) and 1 (exclusive) for use in operations such as:
* - The selection of active children for any `lotto` nodes.
* - The selection of durations for `wait` nodes,
* - The selection of 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.
* @returns A floating-point number between 0 (inclusive) and 1 (exclusive)
*/
random?(): number;
Expand Down
74 changes: 37 additions & 37 deletions dist/bundle.js

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

6 changes: 3 additions & 3 deletions dist/bundle.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import State from "./State";
import { validateDefinition } from "./BehaviourTreeDefinitionValidator";
import { convertMDSLToJSON } from "./mdsl/MDSLDefinitionParser";
import { BehaviourTree, FlattenedTreeNode } from "./BehaviourTree";
import { BehaviourTreeOptions } from "./BehaviourTreeOptions";
import { validateDefinition } from "./BehaviourTreeDefinitionValidator";
import { convertMDSLToJSON } from "./mdsl/MDSLDefinitionParser";
export { BehaviourTree, State, convertMDSLToJSON, validateDefinition };
export type { FlattenedTreeNode, BehaviourTreeOptions };
74 changes: 37 additions & 37 deletions dist/index.js

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

6 changes: 3 additions & 3 deletions dist/index.js.map

Large diffs are not rendered by default.

15 changes: 12 additions & 3 deletions src/BehaviourTreeDefinition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*/
export interface NodeAttributeDefinition {
/**
* The name of the agent function to invoke.
* The name of the agent function or globally registered function to invoke.
*/
call: string;
/**
Expand Down Expand Up @@ -85,7 +85,7 @@ export interface ActionNodeDefinition extends NodeDefinition {
*/
type: "action";
/**
* The name of the agent function or registered function to invoke.
* The name of the agent function or globally registered function to invoke.
*/
call: string;
/**
Expand All @@ -103,7 +103,7 @@ export interface ConditionNodeDefinition extends NodeDefinition {
*/
type: "condition";
/**
* The name of the agent function or registered function to invoke.
* The name of the agent function or globally registered function to invoke.
*/
call: string;
/**
Expand All @@ -120,6 +120,9 @@ export interface WaitNodeDefinition extends NodeDefinition {
* The node type.
*/
type: "wait";
/**
* The duration to wait in milliseconds if defined as a single integer, or the lower and upper duration bounds if defined as an array containing two integer values.
*/
duration?: number | [number, number];
}

Expand Down Expand Up @@ -189,6 +192,9 @@ export interface RepeatNodeDefinition extends DecoratorNodeDefinition {
* The node type.
*/
type: "repeat";
/**
* The number of iterations to make if defined as a single number, or the lower and upper iteration bounds if defined as an array containing two integer values.
*/
iterations?: number | [number, number];
}

Expand All @@ -200,6 +206,9 @@ export interface RetryNodeDefinition extends DecoratorNodeDefinition {
* The node type.
*/
type: "retry";
/**
* The number of attempts to make if defined as a single number, or the lower and upper attempt bounds if defined as an array containing two integer values.
*/
attempts?: number | [number, number];
}

Expand Down
9 changes: 7 additions & 2 deletions src/BehaviourTreeOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,18 @@
*/
export interface BehaviourTreeOptions {
/**
* Gets a delta time in seconds that is used to calculate the elapsed duration of any wait nodes.
* Gets 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.prototype.getTime()` will be used instead by default.
* @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.
* Gets a pseudo-random floating-point number between 0 (inclusive) and 1 (exclusive) for use in operations such as:
* - The selection of active children for any `lotto` nodes.
* - The selection of durations for `wait` nodes,
* - The selection of 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.
* @returns A floating-point number between 0 (inclusive) and 1 (exclusive)
*/
random?(): number;
Expand Down
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import State from "./State";
import { validateDefinition } from "./BehaviourTreeDefinitionValidator";
import { convertMDSLToJSON } from "./mdsl/MDSLDefinitionParser";
import { BehaviourTree, FlattenedTreeNode } from "./BehaviourTree";
import { BehaviourTreeOptions } from "./BehaviourTreeOptions";
import { validateDefinition } from "./BehaviourTreeDefinitionValidator";
import { convertMDSLToJSON } from "./mdsl/MDSLDefinitionParser";

export { BehaviourTree, State, convertMDSLToJSON, validateDefinition };
export type { FlattenedTreeNode, BehaviourTreeOptions };

0 comments on commit 211d540

Please sign in to comment.