Blackboard

Blackboard is a universal data container. Blackboard entries are identified by string keys. Any blackboard can hold arbitrary data types. To lookup a blackboard value, it is necessary to know its key and the underlying data type.

Grail’s approach

Grail blackboards act as a knowledge repository that can be used for easy memorization of certain facts or establishing communication route between different agents. Each grail entity has access to its own private blackboard which can be used as the agent’s memory. There is also a possibility of subscribing an agent to a shared blackboard.

Source code example

  • C++

  • C#

blackboard.SetValue("speed", 1.57f);
float speed = blackboard.GetValue<float>("speed"); //OK
//int speed = blackboard.GetValue<int>("speed"); //Not OK, invalid data type
blackboard.SetValue("speed", 1.57f);
float speed = blackboard.GetValue<float>("speed"); //OK
//int speed = blackboard.GetValue<int>("speed"); //Not OK, invalid data type
To read data from a blackboard using GetValue method, the user needs to be sure that a proper key exists. If there is no certainty TryGetValue method should be used instead.

To see more code examples, see this page.

Example use case

Imagine a squad of soldiers, each of them having access to a shared blackboard, searching an area for possible threats. If any of them notices anything interesting, the location of said observation will be written to the blackboard. Now each member of the squad knows about the threat and can take appropriate action. Whenever the threat becomes neutralized, the entry is removed from the blackboard and the squad switches back to patrolling the area. To see some more fleshed out examples, check out the Blackboard Examples page.

Different approaches

  1. Traditionally, blackboard architecture is used in problem solving. Initially, blackboard contains the starting world state. Then every agent interprets that data and writes back the results of its reasoning. Agents continue their thought processes until a solution to the problem is found.

    Grail blackboards can also be used as helper structures in traditional blackboard problem solving but additional user effort will be needed to adapt them to this task.

  2. Unreal Engine 4 also uses blackboards as containers for data passed between different behaviors inside behavior tree.

API Reference