#include <src/ExplicitAIAgent.h>
Inheritance diagram for ExplicitAIAgent:
This agent will basically follow this simple algorithm: IF not enough energy THEN hunt ELSE IF good quiet place THEN spawn ELSE seek good quiet place
The parameters like the amount of energy necessary to stop hunting, or the definition of a quiet place, have sensible default values, but left open to evolution.
Public Member Functions | |
ExplicitAIAgent (int specie, const std::vector< int > &predatorSpecies, const std::vector< int > &preySpecies) | |
virtual void | updateAI (const double elapsedTime, const double currentTime) |
Perform AI update: The position is constrained to be above the terrain, and attitude is updated accordingly. | |
ExplicitAIAgent (int specie) | |
void | updateAI (const double elapsedTime, const double currentTime) |
Perform AI update: The position is constrained to be above the terrain, and attitude is updated accordingly. | |
virtual void | winnerAction (CrogaiAgent *looser) |
Override this to specify an action to do when an agent wins over another one Default is to acquire energy equivalent to looser mass. | |
Static Public Member Functions | |
static void | createGenomesLogger (const std::string &id, int numSpecies) |
Creates the logGenomes with the given ID and max number of species utility routine. | |
static void | recordGenomesStatistics () |
Tells the logger to record all its statistics now. It won't be possible to change the values afterward, so this should normally be called at the end of your program. | |
Static Public Attributes | |
static double | sporeHalfLife = 120.0 |
To be set to some relevant value by your application. Default is 120 simulator time. | |
static double | maxGrazingSpeed = 1.0 |
To be set to some relevant value by your application. | |
static double | sporeEmissionEnergyThreshold = 1000.0 |
To be set to some relevant value by your application. | |
static double | sporeEmissionEnergyCost = 10.0 |
To be set to some relevant value by your application. | |
static double | maxMass = 2.0 |
To be set to some relevant value by your application Agents metabolize part of the energy they get into mass as growth process (see genome for ratio). | |
static double | minMass = 0.5 |
Then they can spend it to create children see genome for ratio of child mass/parent mass, child can have anything between min and (max-min) mass as initial value => maxMass should be at least > 2 * minMass or no child can ever be created (parent mass + child mass = 2*min mass at least). | |
static Logger * | logGenomes = 0 |
Log the previous statistics. These can't be updated in real time, and generations co-exist at the same time and their statistics may be updated in parallel (which would require to "go back" in the log file to update a value). => the logger is used only at the end of the program, when the last agent is destroyed, but it is also used as a flag indicator whether to bother computing the statistics at all! null by default. | |
Protected Member Functions | |
virtual void | hunt (const double elapsedTime, const double currentTime) |
hunt strategy for the AI | |
virtual void | graze (const double elapsedTime, const double currentTime) |
graze strategy for the AI | |
virtual void | searchQuietPlace (const double elapsedTime, const double currentTime) |
Searching a quiet place for reproduction. Neighbors list was already updated. | |
virtual bool | checkForQuietPlace (const double elapsedTime, const double currentTime) |
Check if here is a quiet place for reproduction. Neighbors list was already updated. | |
virtual void | spawn (Genome *spore) |
spawn, using the specified genome as spore | |
osg::Node * | buildAvatar () |
Overload from parent: get the color from genome. | |
virtual bool | isPrey (CrogaiAgent *agent) |
Allow subclasses to identify preys based on their own criteria. | |
virtual bool | isPredator (CrogaiAgent *agent) |
Allow subclasses to identify preys based on their own criteria. | |
virtual double | getEnergyForFight () |
Return the amount of energy this predator is willing to spend in a fight with the prey. | |
virtual void | energyGainAction (double gain) |
emit spores when gaining enough energy! | |
Protected Attributes | |
Genome * | genome |
This agent genome. For internal use during reproduction. | |
std::vector< int > | predatorSpecies |
std::vector< int > | preySpecies |
double | spawnCriticalMass |
Static Protected Attributes | |
static std::map< int, std::vector< Genome * > > | genomesMean |
Keep statistics about genomes mean on a per-specie, per generation basic Map of specie -> generation vector of genomes. Note: this is just the sum, it will still need to be divided by the total numbers in the generationsPopulationNumber map for the final mean values. | |
static std::map< int, std::vector< Genome * > > | genomesVariance |
Keep statistics about genomes variance on a per-specie, per generation basic Map of specie -> generation vector of genomes Note: this is just the sum of squares, it will still need to be substracted the squared mean and divided by the total numbers in the generationsPopulationNumber map for the final variance values. | |
Classes | |
struct | Genome |
|
Return the amount of energy this predator is willing to spend in a fight with the prey. By default, set no limit (return the current amount of energy) and thus fight to death even if the prey escapes (which is pretty desperate for a predator). Reimplemented from CrogaiAgent. |
|
Allow subclasses to identify preys based on their own criteria. Used during collision. By default, consider any agent of different specie as predator. Reimplemented from CrogaiAgent. |
|
Allow subclasses to identify preys based on their own criteria. Used during collision. By default, consider any agent of different specie as prey. Reimplemented from CrogaiAgent. |
|
Perform AI update: The position is constrained to be above the terrain, and attitude is updated accordingly. Two new internal variables are set for subclasse, which can be checked together with other state variables (position, attitude, etc...)
Subclasses should call this function at the beginning of their AI update routine Reimplemented from TerrainAgent. |
|
Perform AI update: The position is constrained to be above the terrain, and attitude is updated accordingly. Two new internal variables are set for subclasse, which can be checked together with other state variables (position, attitude, etc...)
Subclasses should call this function at the beginning of their AI update routine Reimplemented from TerrainAgent. |
|
Override this to specify an action to do when an agent wins over another one Default is to acquire energy equivalent to looser mass. Note: Looser destruction and score counting are already handled outside this function You should on the other hand use the parent function to handle energy Reimplemented from CrogaiAgent. |