Grail (C++)  1.4.0
A multi-platform, modular, universal engine for embedding advanced AI in games.
grail::planner::DomainTranslator Class Referenceabstract

#include <DomainTranslator.hh>

Collaboration diagram for grail::planner::DomainTranslator:

Public Member Functions

 DomainTranslator (bool isDomainReusable=true)
 
 DomainTranslator (const DomainTranslator &)=default
 
 DomainTranslator (DomainTranslator &&)=default
 
DomainTranslatoroperator= (const DomainTranslator &)=default
 
DomainTranslatoroperator= (DomainTranslator &&)=default
 
std::unique_ptr< WorldStateGetWorldState (AIEntity &entity, const class Goal &goal, MemoryPool *memory)
 
const ObjectIndexBindingGetObjectIndexBinding () const
 
virtual Plan TranslatePlan (const AIEntity &entity, const Planner::AbstractPlan &plan, const Goal &goal) const =0
 
void ResetMemoryPool (MemoryPool &memory)
 ResetMemoryPool - Resets memory pool's memory cell pointer. If domain is reusable, memory will be reset to a memory cell right after the domain data. More...
 

Protected Member Functions

virtual std::vector< IPlannerObject * > GeneratePlannerObjects (AIEntity &entity, const Goal &goal, MemoryPool *memory)=0
 
virtual std::vector< WorldObjectTypeCreateObjectTypes (const AIEntity &entity, const Goal &goal, MemoryPool *memory)=0
 
virtual void AddActionTemplates (const AIEntity &entity, const std::shared_ptr< Domain > &domain, const Goal &goal)=0
 
virtual void SetWorldStateParameters (const AIEntity &entity, WorldState &state, const Goal &goal) const
 

Protected Attributes

ObjectIndexBinding binding {}
 

Detailed Description

An abstract class to implement translating from in-game world state to plan-space world state and from abstract plan to behavior sequence. It serves as a translation layer between the planning AI and the rest of the game.

Constructor & Destructor Documentation

◆ DomainTranslator()

grail::planner::DomainTranslator::DomainTranslator ( bool  isDomainReusable = true)

Constructs a DomainTranslator using the specified MemoryPool.

Parameters
isDomainReusable- if set to true, the planner will assume that the planning domain remains constant and can be reused, meaning that addActionTemplates and createObjectTypes will be invoked only once on DomainTranslator construction

Member Function Documentation

◆ AddActionTemplates()

virtual void grail::planner::DomainTranslator::AddActionTemplates ( const AIEntity entity,
const std::shared_ptr< Domain > &  domain,
const Goal goal 
)
protectedpure virtual

Inside this method, action templates for all possible actions should be added to the Domain. Use Domain::addActionTemplate

◆ CreateObjectTypes()

virtual std::vector<WorldObjectType> grail::planner::DomainTranslator::CreateObjectTypes ( const AIEntity entity,
const Goal goal,
MemoryPool memory 
)
protectedpure virtual
Returns
All possible world object types used by the planner (see WorldObjectType).

◆ GeneratePlannerObjects()

virtual std::vector<IPlannerObject*> grail::planner::DomainTranslator::GeneratePlannerObjects ( AIEntity entity,
const Goal goal,
MemoryPool memory 
)
protectedpure virtual

This method should return a vector of IPlannerObject instances that correspond to in-game objects. An ObjectIndexBinding instance will be created from the returned objects.

◆ GetObjectIndexBinding()

const ObjectIndexBinding & grail::planner::DomainTranslator::GetObjectIndexBinding ( ) const
Returns
the constructed (IPlannerObject <-> WorldObject) index binding

◆ GetWorldState()

std::unique_ptr< WorldState > grail::planner::DomainTranslator::GetWorldState ( AIEntity entity,
const class Goal goal,
MemoryPool memory 
)

Creates a new world state for the planner based on the domain and the given arguments.

Parameters
entity- the AI entity that uses planning.
goal- the goal for the PlannerReasoner.
memory- memory pool object to be used.

◆ ResetMemoryPool()

void grail::planner::DomainTranslator::ResetMemoryPool ( MemoryPool memory)

ResetMemoryPool - Resets memory pool's memory cell pointer. If domain is reusable, memory will be reset to a memory cell right after the domain data.

Parameters
memory- memory pool being resetted

◆ SetWorldStateParameters()

void grail::planner::DomainTranslator::SetWorldStateParameters ( const AIEntity entity,
WorldState state,
const Goal goal 
) const
protectedvirtual

Inside this method, initial abstract WorldState parameters should be set. Use state.setParameter

◆ TranslatePlan()

virtual Plan grail::planner::DomainTranslator::TranslatePlan ( const AIEntity entity,
const Planner::AbstractPlan plan,
const Goal goal 
) const
pure virtual

/return A Behavior-based plan to apply in the game based on the plan constructed in the abstract planning space. Keep in mind that a single Action does not have to correspond to a single Behavior - your plan translation logic can be arbitrary.

Parameters
entity- the "AIEntity" object that utilizes planning for behavior selection.
plan- the abstract plan (from the planning space)
goal- the goal for which the plan was constructed.

The documentation for this class was generated from the following files: