(C++)  1.0.0
A multi-platform, modular, universal engine for embedding advanced AI in games.
grail::simulation::ISimulatedGameUnit Class Referenceabstract

Base class of a unit in the SimulatedGame framework. A unit represents part of the game-state and peforms actions that affect the game-state. You should not create instances of this class. Use specializations @SimulatedGameThinkingUnit or @SimulatedGameStochasticUnit instead. More...

#include <ISimulatedGameUnit.hh>

Inheritance diagram for grail::simulation::ISimulatedGameUnit:

Public Member Functions

virtual void Reset ()=0
 Resets state of the unit to the beginning of the SimulatedGame. More...
 
virtual int GetTeamIndex () const =0
 Returns the index of a team. Units with the same team index share the same game score. More...
 
virtual std::vector< std::unique_ptr< const ISimulatedGameAction > > GetAvailableActions () const =0
 Returns the actions the unit may perform.
More...
 
virtual std::unique_ptr< const ISimulatedGameActionGetRandomAvailableAction (RandomGenerator &rand_gen) const
 Returns a random action to be chosen in simulation. The default implementation samples from GetAvailableActions(). Override the method if you are able to return a uniform random action without the need of computing all available actions. More...
 
virtual void AfterAction (SimulatedGameRuntime &)
 This method is called after action.Apply(). You may insert custom logic here - for example - code that always needs to be executed after any action. More...
 
virtual std::string ToString () const
 Returns the text representation of the unit for debugging purposes. Default implementation returns an empty string. More...
 
virtual void FillDebugRepresentation (std::map< std::string, std::string > &nameValueDictionary) const
 Method used to gather data for GUI-based debugging. Insert properties of the state (key, value) you wish to view in the debugging tool. More...
 

Public Attributes

std::vector< std::unique_ptr< SimulatedGameHeuristic > > heuristicReasoners
 Add or remove heuristic. See @SimulatedGameHeuristic. Heuristic is used to provide the action to play in certain moments without considering all the options. More...
 

Friends

class SimulatedGame
 
class SimulatedGameNode
 

Detailed Description

Base class of a unit in the SimulatedGame framework. A unit represents part of the game-state and peforms actions that affect the game-state. You should not create instances of this class. Use specializations @SimulatedGameThinkingUnit or @SimulatedGameStochasticUnit instead.

Member Function Documentation

◆ AfterAction()

void grail::simulation::ISimulatedGameUnit::AfterAction ( SimulatedGameRuntime )
virtual

This method is called after action.Apply(). You may insert custom logic here - for example - code that always needs to be executed after any action.

◆ FillDebugRepresentation()

void grail::simulation::ISimulatedGameUnit::FillDebugRepresentation ( std::map< std::string, std::string > &  nameValueDictionary) const
virtual

Method used to gather data for GUI-based debugging. Insert properties of the state (key, value) you wish to view in the debugging tool.

Parameters
nameValueDictionary

◆ GetAvailableActions()

virtual std::vector<std::unique_ptr<const ISimulatedGameAction> > grail::simulation::ISimulatedGameUnit::GetAvailableActions ( ) const
pure virtual

Returns the actions the unit may perform.

This method must always return the same set of actions in the same state.

◆ GetRandomAvailableAction()

std::unique_ptr< const grail::simulation::ISimulatedGameAction > grail::simulation::ISimulatedGameUnit::GetRandomAvailableAction ( RandomGenerator &  rand_gen) const
virtual

Returns a random action to be chosen in simulation. The default implementation samples from GetAvailableActions(). Override the method if you are able to return a uniform random action without the need of computing all available actions.

Parameters
rand_genRandom generator (typedef std::mt19937_64 RandomGenerator)
Returns

◆ GetTeamIndex()

virtual int grail::simulation::ISimulatedGameUnit::GetTeamIndex ( ) const
pure virtual

Returns the index of a team. Units with the same team index share the same game score.

Implemented in grail::simulation::SimulatedGameStochasticUnit.

◆ Reset()

virtual void grail::simulation::ISimulatedGameUnit::Reset ( )
pure virtual

Resets state of the unit to the beginning of the SimulatedGame.


◆ ToString()

std::string grail::simulation::ISimulatedGameUnit::ToString ( ) const
virtual

Returns the text representation of the unit for debugging purposes. Default implementation returns an empty string.

Member Data Documentation

◆ heuristicReasoners

std::vector<std::unique_ptr<SimulatedGameHeuristic> > grail::simulation::ISimulatedGameUnit::heuristicReasoners

Add or remove heuristic. See @SimulatedGameHeuristic. Heuristic is used to provide the action to play in certain moments without considering all the options.



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