Grail (C++)  1.3.0
A multi-platform, modular, universal engine for embedding advanced AI in games.
grail::evolution::TypedEvoParam< T > Class Template Referencefinal

TypedEvoParam A class for defining evolutionary-optimizable parameters. They can be registered in EvoScripts for the evolutionary optimization functionality. The template type @T defines type of possible values the parameter may store. As T you have to either use a trivially destructible object or a smart pointer that will delete itself when it goes out of scope. More...

#include <TypedEvoParam.hh>

Inheritance diagram for grail::evolution::TypedEvoParam< T >:
Collaboration diagram for grail::evolution::TypedEvoParam< T >:

Public Member Functions

 TypedEvoParam (std::initializer_list< T > argsDomain)
 TypedEvoParam - Constructor. More...
 
 TypedEvoParam (std::vector< T > &argsDomain)
 TypedEvoParam - Constructor. More...
 
int IndexOfValue (T value)
 IndexOfValue - finds a given value in the parameter's domain and returns its index. More...
 
const T Value () const
 Value - gets the current value that the parameter is holding. More...
 
 operator T () const
 
virtual std::string ToString () const override
 ToString - returns the string representation of the current value hold by the parameter. More...
 
- Public Member Functions inherited from grail::evolution::EvoParam
void Randomize (std::mt19937_64 &rand_gen)
 Sets to a random possible value from a domain. More...
 
const EvoParamSetNext ()
 Sets to the next possible value in the domain (wrapped, i.e. last.next -> first) and returns itself.
 
const EvoParamSetPrev ()
 Sets to the previous possible value in the domain (wrapped, i.e. first.prev -> last) and returns itself.
 
const EvoParamSetNextClamped ()
 Sets to the next possible value in the domain (clamped, i.e. last.next -> last) and returns itself.
 
const EvoParamSetPrevClamped ()
 Sets to the previous possible value in the domain (clamped, i.e. first.prev -> first) and returns itself.
 
float GetNormalizedPositionWeight () const
 Returns the normalized position as [0.0, 1.0] floating point number.
 
size_t GetPositionIndex () const
 Returns the position of the parameter i.e. the index of the currently assigned element from the domain.
 
void SetPositionIndex (size_t position)
 Sets the position of the parameter i.e. the index of the currently assigned element from the domain. More...
 

Additional Inherited Members

- Protected Member Functions inherited from grail::evolution::EvoParam
 EvoParam (size_t domainLength)
 EvoParam - Constructor. More...
 
- Protected Attributes inherited from grail::evolution::EvoParam
const size_t domainLength = {1}
 domainLength - the number of distinct values EvoParam may take.
 
size_t positionIndex
 positionIndex - EvoParam uses positionIndex to point to an element from its domain. More...
 

Detailed Description

template<class T>
class grail::evolution::TypedEvoParam< T >

TypedEvoParam A class for defining evolutionary-optimizable parameters. They can be registered in EvoScripts for the evolutionary optimization functionality. The template type @T defines type of possible values the parameter may store. As T you have to either use a trivially destructible object or a smart pointer that will delete itself when it goes out of scope.

Constructor & Destructor Documentation

◆ TypedEvoParam() [1/2]

template<class T >
grail::evolution::TypedEvoParam< T >::TypedEvoParam ( std::initializer_list< T >  argsDomain)
inline

TypedEvoParam - Constructor.

◆ TypedEvoParam() [2/2]

template<class T >
grail::evolution::TypedEvoParam< T >::TypedEvoParam ( std::vector< T > &  argsDomain)
inline

TypedEvoParam - Constructor.

Member Function Documentation

◆ IndexOfValue()

template<class T >
int grail::evolution::TypedEvoParam< T >::IndexOfValue ( value)
inline

IndexOfValue - finds a given value in the parameter's domain and returns its index.

Returns
index of the value found.

◆ operator T()

template<class T >
grail::evolution::TypedEvoParam< T >::operator T ( ) const
inline

Expicit cast so you can use constructions such as: TypedEvoParam<int> speed({10,15,20}) if(speed > 2) .... *‍/

◆ ToString()

template<class T >
virtual std::string grail::evolution::TypedEvoParam< T >::ToString ( ) const
inlineoverridevirtual

ToString - returns the string representation of the current value hold by the parameter.

Reimplemented from grail::evolution::EvoParam.

◆ Value()

template<class T >
const T grail::evolution::TypedEvoParam< T >::Value ( ) const
inline

Value - gets the current value that the parameter is holding.

Returns
current value.

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