Blackboard

Inherits:

A key/value storage for sharing among LimboHSM states and BehaviorTree tasks.

Description

Blackboard is where data is stored and shared between states in the LimboHSM system and tasks in a BehaviorTree. Each state and task in the BehaviorTree can access this Blackboard, allowing them to read and write data. This makes it easy to share information between different actions and behaviors.

Blackboard can also act as a parent scope for another Blackboard. If a specific variable is not found in the active scope, it looks in the parent Blackboard to find it. A parent Blackboard can itself have its own parent scope, forming what we call a “blackboard scope chain.” Importantly, there is no limit to how many Blackboards can be in this chain, and the Blackboard doesn’t modify values in the parent scopes.

New scopes can be created using the BTNewScope and BTSubtree decorators. Additionally, a new scope is automatically created for any LimboState that has defined non-empty Blackboard data or for any root-level LimboHSM node.

Methods

void

bind_var_to_property(var_name: StringName, object: Object, property: StringName, create: bool = false)

void

clear()

void

erase_var(var_name: StringName)

Blackboard

get_parent() const

Variant

get_var(var_name: StringName, default: Variant = null, complain: bool = true) const

Dictionary

get_vars_as_dict() const

bool

has_var(var_name: StringName) const

void

link_var(var_name: StringName, target_blackboard: Blackboard, target_var: StringName, create: bool = false)

Array[StringName]

list_vars() const

void

populate_from_dict(dictionary: Dictionary)

void

print_state() const

void

set_parent(blackboard: Blackboard)

void

set_var(var_name: StringName, value: Variant)

Blackboard

top() const

void

unbind_var(var_name: StringName)


Method Descriptions

void bind_var_to_property(var_name: StringName, object: Object, property: StringName, create: bool = false) 🔗

Establish a binding between a variable and the object’s property specified by property and object. Changes to the variable update the property, and vice versa. If create is true, the variable will be created if it doesn’t exist.


void clear() 🔗

Removes all variables from the Blackboard. Parent scopes are not affected.


void erase_var(var_name: StringName) 🔗

Removes a variable by its name.


Blackboard get_parent() const 🔗

Returns a Blackboard that serves as the parent scope for this instance.


Variant get_var(var_name: StringName, default: Variant = null, complain: bool = true) const 🔗

Returns variable value or default if variable doesn’t exist. If complain is true, an error will be printed if variable doesn’t exist. If the variable doesn’t exist in the current Blackboard scope, it will look in the parent scope Blackboard to find it.


Dictionary get_vars_as_dict() const 🔗

Returns all variables in the Blackboard as a dictionary. Keys are the variable names, values are the variable values. Parent scopes are not included.


bool has_var(var_name: StringName) const 🔗

Returns true if the Blackboard contains the var_name variable, including the parent scopes.


Links a variable to another Blackboard variable. If a variable is linked to another variable, their state will always be identical, and any change to one will be reflected in the other. If create is true, the variable will be created if it doesn’t exist.

You can use this method to link a variable in the current scope to a variable in another scope, or in another Blackboard instance. A variable can only be linked to one other variable. Calling this method again will overwrite the previous link. However, it is possible to link to the same variable from multiple different variables.


Array[StringName] list_vars() const 🔗

Returns all variable names in the Blackboard. Parent scopes are not included.


void populate_from_dict(dictionary: Dictionary) 🔗

Fills the Blackboard with multiple variables from a dictionary. The dictionary keys must be variable names and the dictionary values must be variable values. Keys must be StringName or String.


void print_state() const 🔗

Prints the values of all variables in each scope.


void set_parent(blackboard: Blackboard) 🔗

Assigns the parent scope. If a value isn’t in the current Blackboard scope, it will look in the parent scope Blackboard to find it.


void set_var(var_name: StringName, value: Variant) 🔗

Assigns a value to a variable in the current Blackboard scope. If the variable doesn’t exist, it will be created. If the variable already exists in the parent scope, the parent scope value will NOT be changed.


Blackboard top() const 🔗

Returns the topmost Blackboard in the scope chain.


void unbind_var(var_name: StringName) 🔗

Remove binding from a variable.