Skip to content

Commit

Permalink
Assorted documentation fixes (#356)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dritic authored Sep 30, 2024
1 parent c5726af commit 23341d1
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 15 deletions.
6 changes: 3 additions & 3 deletions docs/manual/blackboard.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ The `Blackboard` is a useful object in Behavior Trees, designed to store and sha

## Purpose of Blackboards

- **Centralized Data Management**:
- **Centralized Data Management**:
- Blackboards act as a centralized repository for data in behaviour trees.
- They offer an organized way to store and manage data, avoiding the complexity of passing variables directly to nodes.
- This approach ensures that all nodes can access and modify the same set of data, maintaining consistency across the behavior tree.

- **Consistency and Synchronization**:
- **Consistency and Synchronization**:
- Using a blackboard ensures that data remains consistent across all nodes.
- It enables synchronized behaviors among different game characters or objects, as they all refer to the same data source.

Expand All @@ -18,7 +18,7 @@ The `Blackboard` is a useful object in Behavior Trees, designed to store and sha

By default, every `BeehaveTree` manages its own instance of a blackboard. However, you can also create a new blackboard in your scene and reference it via the blackboard property on the Beehave tree. This approach allows you to share the same blackboard between multiple trees, promoting reusability and simplifying data management.

> **Global vs Local Scope in Blackboards**:
> **Global vs Local Scope in Blackboards**:
> - When a value is set on a shared blackboard, it becomes 'global' and affects all trees referencing that blackboard.
> - However, using a custom blackboard name (as the 3rd argument in the key-value pair) allows for localizing the scope. This means changes to the blackboard will only affect the trees that use that specific custom name, enabling more controlled and isolated behaviors.
Expand Down
2 changes: 1 addition & 1 deletion docs/manual/composites.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ When a parent node restarts, it means the whole composite node begins its evalua
When a composite node ticks again, it will "jump" to the currently `RUNNING` child node and tick it.

For [sequence nodes](sequence.md), on the first frame it starts ticking all its children in order, starting from the first one, until either all of them return `SUCCESS` or one of them returns `RUNNING`. If one of them returned `RUNNING`, on the next frame, the sequence will only tick the running child node. Not all of them, just the running one - and possibly the child nodes following it, if the running child has completed and returned `SUCCESS`.
For [selector nodes](selector.md), on the first frame it starts ticking each child in order until one of them returns `SUCCESS` or one of them returns `RUNNING`. If one of them returned `RUNNING`, on the next frame, the selector will only tick the running child node, skipping all the previous ones, and possibly the child nodes following it, if the running child has completed and returned `FAILURE`.
For [selector nodes](selector.md), on the first frame it starts ticking each child in order until one of them returns `SUCCESS` or one of them returns `RUNNING`. If one of them returned `RUNNING`, on the next frame, the selector will only tick the running child node, skipping all the previous ones, and possibly the child nodes following it, if the running child has completed and returned `FAILURE`.

## Interrupting child nodes

Expand Down
2 changes: 1 addition & 1 deletion docs/manual/selector.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ The enemy will choose the first successful option, and the Selector node will re
</ul>
</ul>

Note that "If the player is close and the enemy is low on health, retreat" sequence goes before "If the player is in range, attack the player". If you put them other way around, enemy would always keep attacking the player as SelectorSequence will always run first sequence that doesn't return `FAILURE`.
Note, that the "If the player is close and the enemy is low on health, retreat" sequence goes before "If the player is in range, attack the player". If you put them the other way around, the enemy would always keep attacking the player as SelectorSequence will always run the first sequence that doesn't return `FAILURE`.

### Example 2: NPC Reactions
An NPC in your game should react differently based on the player's reputation. You can use a Selector node with the following child nodes:
Expand Down
2 changes: 1 addition & 1 deletion docs/manual/sequence.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ The guard will follow this sequence, and if all actions are successful, the Sequ
</li>
</ul>

Instead of creating a custom action for waiting, you could use <a href="#/manual/decorators?id=delayer">Delayer</a> decorator.
Instead of creating a custom action for waiting, you could use the <a href="#/manual/decorators?id=delayer">Delayer</a> decorator.


### Example 2: NPC Conversation
Expand Down
18 changes: 9 additions & 9 deletions docs/manual/simple_parallel.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
# Simple Parallel Node
The Simple Parallel node is a fundamental building block in Behavior Trees, used to execute two children at same time. It helps you run multiple actions simultaneously.Think of the Simple Parallel node as "While doing A, do B as well."
The Simple Parallel node is a fundamental building block in Behavior Trees, used to execute two children at the same time. It helps you run multiple actions simultaneously. Think of the Simple Parallel node as "While doing A, do B as well".

## How does it work?
Simple Parallel nodes will attampt to execute all chidren at same time and can only have exactly two children. First child as primary node, second child as secondary node.
This node will always report primary node's state, and continue tick while primary node return `RUNNING`. The state of secondary node will be ignored and executed like a subtree.
If primary node return `SUCCESS` or `FAILURE`, this node will interrupt secondary node and return primary node's result.
If this node is running under delay mode, it will wait seconday node finish its action after primary node terminates.
Simple Parallel nodes will attempt to execute all children at the same time and can only have exactly two children. First child as the primary node, second child as the secondary node.
This node will always report the primary node's state, and continue ticking while the primary node returns `RUNNING`. The state of the secondary node will be ignored and executed like a subtree.
If the primary node returns `SUCCESS` or `FAILURE`, this node will interrupt the secondary node and return the primary node's result.
If this node is running under delay mode, it will wait for the secondary node to finish its action after the primary node terminates.


## Example Scenarios
Here are some example scenarios to help you understand the Sequence node better:

### Example: While attacking the enemy, move toward the enemy
Imagine you want a ranged enemy character trying to shoot you whenever he can while to move towards you. You can use a Simple Parallel node with the following child nodes architecture:
### Example: While attacking the enemy, move toward the enemy
Imagine you want a ranged enemy character trying to shoot you whenever they can while moving towards you. You can use a Simple Parallel node with the following child nodes architecture:

1. Move to player
2. Sequence Node
1. Check if enemy can shoot
2. Shoot

The enemy will move to a player and try to shoot at same time, and if move action is successful or failure, the Simple Parallel node will termitate the child sequence node for shooting attempt, then return `SUCCESS` or `FAILURE` according to move action result.
The enemy will move to the player and try to shoot at the same time. If the move action is successful or fails, the Simple Parallel node will terminate the child sequence node for the shooting attempt, then return `SUCCESS` or `FAILURE` according to the move action result.

<ul style="list-style: none;">
<li>
Expand Down Expand Up @@ -60,4 +60,4 @@ The enemy will move to a player and try to shoot at same time, and if move actio
</li>
</ul>

Simple Parallel can be nested to create complex behaviors while it's not suggested, because too much nesting would make it hard to maintain your behavior tree.
Although Simple Parallel can be nested to create complex behaviors, it is not recommended, as too much nesting may make it difficult to maintain your behavior tree.

0 comments on commit 23341d1

Please sign in to comment.