Grail (C#)  1.4.0
A multi-platform, modular, universal engine for embedding advanced AI in games.
Grail.Evolution.BaseEvoParam Class Reference

A class that represents a parameter that is modifiable (optimizable) by evolutionary algorithms.
Unless your parameter is only a positional index (represented by an integer from 0 to max), use a specialized version EvoParam<Type>.
These parameters form an encoding and are stored as member Fields or Properties in an Individual and set as optimizable using Individual.SetMemberParameterOptimizable.
Typically, the Individual.SetMemberParameterOptimizable function should be called in the constructor of an Individual-derived class. More...

Inheritance diagram for Grail.Evolution.BaseEvoParam:

Public Member Functions

 BaseEvoParam (int domainLength)
 Constructs a new EvoParam. More...
 
void Randomize (Random random)
 Sets to a random possible value from a domain. More...
 
BaseEvoParam SetPrev ()
 Sets to the previous possible value in the domain (wrapped, i.e. first.prev -> last). More...
 
BaseEvoParam SetNext ()
 Sets to the next possible value in the domain (wrapped, i.e. last.next -> first). More...
 
BaseEvoParam SetNextClamped ()
 Sets to the next possible value in the domain (clamped, i.e. last.next -> last). More...
 
BaseEvoParam SetPrevClamped ()
 Sets to the previous possible value in the domain (clamped, i.e. first.prev -> first). More...
 

Public Attributes

readonly int domainLength
 The number of distinct values the parameter may take. More...
 
float NormalizedPositionWeight => domainLength > 1 ? PositionIndex / (float)(domainLength - 1) : 0.5f
 The normalized position, between 0.0 and 1.0, is the ratio of the current position index to the domainLength. More...
 

Properties

int PositionIndex [get, set]
 EvoParam uses PositionIndex to point to an element from its domain.
Setting this index makes the parameter hold the PositionIndex-ith value from the domain. Index starts at zero. More...
 

Detailed Description

A class that represents a parameter that is modifiable (optimizable) by evolutionary algorithms.
Unless your parameter is only a positional index (represented by an integer from 0 to max), use a specialized version EvoParam<Type>.
These parameters form an encoding and are stored as member Fields or Properties in an Individual and set as optimizable using Individual.SetMemberParameterOptimizable.
Typically, the Individual.SetMemberParameterOptimizable function should be called in the constructor of an Individual-derived class.

Constructor & Destructor Documentation

◆ BaseEvoParam()

Grail.Evolution.BaseEvoParam.BaseEvoParam ( int  domainLength)
inline

Constructs a new EvoParam.

Parameters
domainLengthThe number of distinct values EvoParam may take.

Member Function Documentation

◆ Randomize()

void Grail.Evolution.BaseEvoParam.Randomize ( Random  random)
inline

Sets to a random possible value from a domain.

Parameters
randomRandom number generator.

◆ SetNext()

BaseEvoParam Grail.Evolution.BaseEvoParam.SetNext ( )
inline

Sets to the next possible value in the domain (wrapped, i.e. last.next -> first).

Returns
The EvoParam returns itself.

◆ SetNextClamped()

BaseEvoParam Grail.Evolution.BaseEvoParam.SetNextClamped ( )
inline

Sets to the next possible value in the domain (clamped, i.e. last.next -> last).

Returns
The EvoParam returns itself.

◆ SetPrev()

BaseEvoParam Grail.Evolution.BaseEvoParam.SetPrev ( )
inline

Sets to the previous possible value in the domain (wrapped, i.e. first.prev -> last).

Returns
The EvoParam returns itself.

◆ SetPrevClamped()

BaseEvoParam Grail.Evolution.BaseEvoParam.SetPrevClamped ( )
inline

Sets to the previous possible value in the domain (clamped, i.e. first.prev -> first).

Returns
The EvoParam returns itself.

Member Data Documentation

◆ domainLength

readonly int Grail.Evolution.BaseEvoParam.domainLength

The number of distinct values the parameter may take.

◆ NormalizedPositionWeight

float Grail.Evolution.BaseEvoParam.NormalizedPositionWeight => domainLength > 1 ? PositionIndex / (float)(domainLength - 1) : 0.5f

The normalized position, between 0.0 and 1.0, is the ratio of the current position index to the domainLength.

Property Documentation

◆ PositionIndex

int Grail.Evolution.BaseEvoParam.PositionIndex
getset

EvoParam uses PositionIndex to point to an element from its domain.
Setting this index makes the parameter hold the PositionIndex-ith value from the domain. Index starts at zero.


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