AI Manager

AI manager is Grail’s command center. Manager takes care of registered entities and shared blackboards. Also, it’s responsible for threading.

Public Interface

Constructor

Constructs AI manager. During construction, AI manager spawns worker threads, whose number is determined by a constructor argument. Those threads work on updating reasoners of registered entities. If the user passes 0 as the constructor argument, all updates will be executed on the main thread.

Create Blackboard

Creates a shared blackboard identified by the given name.

Register AI Entity

Registers an entity with a given priority. After registration, AI Manager will be able to update the entity’s state. Entities with lower priority values are be updated first.

Remove AI Entity

Queues an entity to be unregistered from the manager. All queued entities are removed by the end of the next update.

Register Entity Group

Manager registers entity group (and its entities) with given priority. As a result entities and their behaviors will be updated when UpdateEntities will be called. Entities with lower priority will be updated first. Resulting priority of each entity in group is calculated by adding group priority and relative priority of given entity.

Remove Entity Group

Manager removes entity group and caches its entities for removal. Later on all cached entities will be unregistered from this manager. Unregistered entities will no longer be updated, neither will be their behaviors and reasoners.

Subscribe To Blackboard

Subscribes the given entity to a shared blackboard owned by this manager and identified by a name.

Update Entities

Updates all registered entities. More specifically, this methods causes updates of behaviors assigned to those entities.

Update Reasoners

Allows worker threads (or main thread, depending on configuration) to update reasoners connected to registered entities. Basically, calling this method allows entities to think.

Register Entity Change Observer

Registers entity change observer that will be notified via OnEntityAdded and OnEntityRemoved functions when entity os added or removed from manager.

Remove Entity Change Observer

Removes entity change observer so it no longer be notified on adding or removing entity from manager.

Contains Entity

Checks if given entity is registered in manager. Returns true if entity is registered in manager, false otherwise.

API Reference