Skip to content

1681-engine / index / BtSpec

Type Alias: BtSpec ​

ts
type BtSpec = 
  | {
  children: BtSpec[];
  type: "sequence" | "selector" | "reactiveSequence" | "reactiveSelector";
}
  | {
  children: BtSpec[];
  fail?: number;
  succeed?: number;
  type: "parallel";
}
  | {
  child: BtSpec;
  type: "invert" | "succeed";
}
  | {
  child: BtSpec;
  times: number;
  type: "repeat" | "retry";
}
  | {
  child: BtSpec;
  ms: number;
  type: "cooldown" | "timeout";
}
  | {
  ms: number;
  type: "wait";
}
  | {
  name: string;
  type: "action" | "condition";
}
  | {
  name: string;
  type: "tree";
};

Defined in: src/ai/buildTree.ts:33

A tree written as data (a JSON file a designer edits): composites hold children, decorators one child, and leaves name an action or a condition the game registered.

json
{ "type": "reactiveSelector", "children": [
  { "type": "sequence", "children": [{ "type": "condition", "name": "hurt" }, { "type": "action", "name": "flee" }] },
  { "type": "cooldown", "ms": 2000, "child": { "type": "action", "name": "bark" } },
  { "type": "action", "name": "wander" }
] }

Union Members ​

Type Literal ​

ts
{
  children: BtSpec[];
  type: "sequence" | "selector" | "reactiveSequence" | "reactiveSelector";
}

Type Literal ​

ts
{
  children: BtSpec[];
  fail?: number;
  succeed?: number;
  type: "parallel";
}

Type Literal ​

ts
{
  child: BtSpec;
  type: "invert" | "succeed";
}

Type Literal ​

ts
{
  child: BtSpec;
  times: number;
  type: "repeat" | "retry";
}

Type Literal ​

ts
{
  child: BtSpec;
  ms: number;
  type: "cooldown" | "timeout";
}

Type Literal ​

ts
{
  ms: number;
  type: "wait";
}

Type Literal ​

ts
{
  name: string;
  type: "action" | "condition";
}

Type Literal ​

ts
{
  name: string;
  type: "tree";
}

A named subtree of the registry, so a tree is shared by several (a "flee" every monster uses).

Released under the MIT License.