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

#include <WorldState.hh>

Inheritance diagram for grail::planner::WorldState:
Collaboration diagram for grail::planner::WorldState:

Public Member Functions

 WorldState (MemoryPool *memory, const std::shared_ptr< Domain > &domain, const std::vector< WorldObject > &worldObjects)
 
 WorldState (const WorldState &other)
 
 WorldState (WorldState &&other)=default
 
WorldStateoperator= (const WorldState &other)
 
WorldStateoperator= (WorldState &&other)=default
 
bool operator== (const WorldState &other) const
 
std::vector< class ActionGetLegalActions () const
 
std::vector< std::vector< unsigned int > > GenerateParameterLists (const std::vector< std::vector< unsigned int >> &precedingParameterLists, unsigned int searchedTypeIndex) const
 For internal use only.
 
const WorldObjectGetObjectByIndex (unsigned int index) const
 
WorldObjectGetObjectByIndex (unsigned int index)
 
const std::map< unsigned int, WorldObject > & GetObjectMap () const
 
std::shared_ptr< DomainGetDomain () const
 
WorldObjectAddObject (const std::string &typeName)
 
void RemoveObject (unsigned int objectIndex)
 
void AddQueuedObjects ()
 
void RemoveQueuedObjects ()
 
std::vector< const WorldObject * > GetObjectsOfType (const std::string &typeName) const
 
std::vector< WorldObject * > GetObjectsOfType (const std::string &typeName)
 
int CountObjectsOfType (const std::string &typeName) const
 
- Public Member Functions inherited from grail::planner::ParametrizedObject
void MergeParameters (const ParametrizedObject &other)
 MergeParameters - Adds other parameters to the own one, replacing parameter with those of other in case of conflict. More...
 
std::size_t GetParametersSize () const
 
bool Contains (const std::string &paramName) const
 
template<typename ParameterType >
void SetParameter (const std::string &paramName, const ParameterType &paramValue)
 
template<typename ParameterType >
ParameterType GetParameterValue (const std::string &paramName) const
 
bool CollectionContains (const std::string &collectionName, unsigned int objectIndex) const
 
void AddCollection (const std::string &collectionName)
 
std::set< unsigned int > * GetCollection (const std::string &name)
 
const std::set< unsigned int > * GetCollection (const std::string &name) const
 
bool HasEqualParams (const ParametrizedObject &other) const
 
void SetSerializeSnapshotFunction (std::function< void(const ParametrizedObject &object, std::map< std::string, std::string > &nameValues)> function)
 SetSerializeSnapshotFunction - Sets a function serializing a snapshot of parameter values to string. More...
 
ParametrizedObjectoperator= (const ParametrizedObject &other)
 
ParametrizedObjectoperator= (ParametrizedObject &&other)=default
 

Additional Inherited Members

- Protected Member Functions inherited from grail::planner::ParametrizedObject
 ParametrizedObject (MemoryPool *memory)
 
 ParametrizedObject (const ParametrizedObject &other)
 
 ParametrizedObject (ParametrizedObject &&other)=default
 
- Protected Attributes inherited from grail::planner::ParametrizedObject
std::map< std::string, ObjectParameter * > parameters {}
 
std::map< std::string, std::set< unsigned int > > indexCollections {}
 
MemoryPoolmemory
 

Detailed Description

A class representing the planner state. The state consists of WorldObjects. The planner aims to find the most cost-effective path from the initial state to the goal state. The WorldState also determines action-related aspects such as their legality. WorldStates can be modified through applying actions' effects.

Constructor & Destructor Documentation

◆ WorldState()

grail::planner::WorldState::WorldState ( MemoryPool memory,
const std::shared_ptr< Domain > &  domain,
const std::vector< WorldObject > &  worldObjects 
)

Constructs a new WorldState object based on a domain and initial objects.

Parameters
memory- the MemoryPool object for memory optimization.
domain- the planning domain of the space this state belongs to.
objects- the initial list of world objects building the state.

Member Function Documentation

◆ AddObject()

WorldObject & grail::planner::WorldState::AddObject ( const std::string &  typeName)

Creates a new "WorldObject" of the provided type and queues it for addition to the WorldState. The addition will be executed at the end of the current planner iteration. The object will be created with default parameters which you can change later.

Parameters
typeName- the name of the type of the object to create.
Returns
The created object.

◆ CountObjectsOfType()

int grail::planner::WorldState::CountObjectsOfType ( const std::string &  typeName) const
Returns
The number of objects of given type, including all derived types

◆ GetDomain()

std::shared_ptr< Domain > grail::planner::WorldState::GetDomain ( ) const
Returns
The domain of the same planning problem as this state corresponds to.

◆ GetLegalActions()

std::vector< Action > grail::planner::WorldState::GetLegalActions ( ) const
Returns
All available actions in the current state.

◆ GetObjectByIndex() [1/2]

WorldObject * grail::planner::WorldState::GetObjectByIndex ( unsigned int  index)

Retrieves an existing "WorldObject" stored at the provided index. The index serves as a unique ID.

Parameters
index- the index of the object to return.
Returns
The retrieved object or null if there is no object under the provided index.

◆ GetObjectByIndex() [2/2]

const WorldObject * grail::planner::WorldState::GetObjectByIndex ( unsigned int  index) const

Retrieves an existing "WorldObject" stored at the provided index. The index serves as a unique ID.

Parameters
index- the index of the object to return.
Returns
The retrieved object or null if there is no object under the provided index.

◆ GetObjectMap()

const std::map< unsigned int, WorldObject > & grail::planner::WorldState::GetObjectMap ( ) const
Returns
A dictionary of WorldObjects: the building blocks of the state.

◆ GetObjectsOfType() [1/2]

std::vector< WorldObject * > grail::planner::WorldState::GetObjectsOfType ( const std::string &  typeName)
Returns
All objects of a given type, including all derived types

◆ GetObjectsOfType() [2/2]

std::vector< const WorldObject * > grail::planner::WorldState::GetObjectsOfType ( const std::string &  typeName) const
Returns
All objects of a given type, including all derived types

◆ RemoveObject()

void grail::planner::WorldState::RemoveObject ( unsigned int  objectIndex)

Adds the object specified by objectIndex to a set of objects that should be removed at the end of the current planner iteration


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