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

A base class of a unit in SimulatedGame that peforms actions according to some probability distribution. It does not represents any players in the game. It should be used if either (1) randomness affects actions available to other players (2) randomness heavily affects the game outcome. Random effects should be applied as actions of SimulatedGameStochasticUnit. More...

#include <SimulatedGameStochasticUnit.hh>

Inheritance diagram for grail::simulation::SimulatedGameStochasticUnit:
Collaboration diagram for grail::simulation::SimulatedGameStochasticUnit:

Public Member Functions

virtual int GetTeamIndex () const override
 TeamIndex is relevant for SimulatedGameStochasticUnit only for GUI purposes (to show it as a separate team). More...
 
virtual size_t GetRandomActionIndex (std::vector< std::unique_ptr< const ISimulatedGameAction >> &actions, RandomGenerator &rand_gen) const
 This function returns index of the action (rather than the action itself) chosen according to the unit's logic. The default implementation assumes the uniform random distribution (each action chosen with equal probability). Override it if actions have different chances to be chosen. More...
 
- Public Member Functions inherited from grail::simulation::ISimulatedGameUnit
virtual void Reset ()=0
 Resets state of the unit to the beginning of the SimulatedGame. 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...
 

Friends

class SimulatedGame
 

Additional Inherited Members

- Public Attributes inherited from grail::simulation::ISimulatedGameUnit
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...
 

Detailed Description

A base class of a unit in SimulatedGame that peforms actions according to some probability distribution. It does not represents any players in the game. It should be used if either (1) randomness affects actions available to other players (2) randomness heavily affects the game outcome. Random effects should be applied as actions of SimulatedGameStochasticUnit.

Member Function Documentation

◆ GetRandomActionIndex()

size_t grail::simulation::SimulatedGameStochasticUnit::GetRandomActionIndex ( std::vector< std::unique_ptr< const ISimulatedGameAction >> &  actions,
grail::RandomGenerator &  rand_gen 
) const
virtual

This function returns index of the action (rather than the action itself) chosen according to the unit's logic. The default implementation assumes the uniform random distribution (each action chosen with equal probability). Override it if actions have different chances to be chosen.

Parameters
actionsThe collection of available actions that is cached for the unit.
rand_genRandom generator (typedef std::mt19937_64 RandomGenerator)
Returns
Index of the chosen action. This value cannot be greater than the size of @actions collection.

◆ GetTeamIndex()

int grail::simulation::SimulatedGameStochasticUnit::GetTeamIndex ( ) const
overridevirtual

TeamIndex is relevant for SimulatedGameStochasticUnit only for GUI purposes (to show it as a separate team).


Implements grail::simulation::ISimulatedGameUnit.


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