Blueprint

To make use of behavior instantiation, users should acquaint themselves with Blueprint helper class.

Blueprints are used in Utility Reasoner to identify which evaluators should be taken into consideration for each Context.

Blueprint is a template class so user should provide following template parameters:
  • InstanceType - Type of instantiated object (usually Behavior).

  • ContextType - Context type. It identifies what data should be used during utility selection. It is also used as parameter during object instantiation.

  • DataType - Type of data which containing subset of game state which can be used to generate valid Contexts.

Each blueprint needs to be passed 3 parameters during construction:
  1. name - Used mostly to identify the blueprint during debugging.

  2. contextProducer - Callable returning container of ContextType and taking DataType as an argument. This abstraction should generate Contexts valid at given moment, so that they can be used in UtilitySelector to determine which object should be instantiated.

  3. instanceProducer - Callable returning instance of InstanceType and taking ContexType as an argument. This abstraction should instantiate proper object of type InstanceType given Context properly returned from UtilitySelector.

Usage Example

  • C++

  • C#

using EntityBlackboardPair = std::pair<const AIEntity*, Blackboard>;
...

Blueprint<Behavior, EntityBlackboardPair, AIEntity> blueprint{"attack", Attack::ProduceContexts, [](const EntityBlackboardPair& pair} { std::make_unique<Attack>(pair.second.GetValue<Enemy>("enemy")); }
using EntityBlackboardPair = ValueTuple<AIEntity, Blackboard>;
...

var blueprint = new Blueprint<Behavior, EntityBlackboardPair, AIEntity>("attack", Attack.ProduceContexts, (in EntityBlackboardPair pair) => { return new Attack(pair.Item2.GetValue<Enemy>("enemy"); });

API Reference