34#include "MemoryManager.h"
35#include "ArtificialNeuralNet.h"
38class GeneticAlgorithm;
42#define PME_GHOSTS_NN_FILE "neuralnet.cdc"
43#define PME_GHOSTS_NN_BLOCK "ghosts.xml"
45#define PME_GA_CROSSOVER_RATE 0.7
46#define PME_GA_MUTATION_RATE 0.2
47#define PME_GA_MAX_PERTURBATION 0.4
48#define PME_GA_NUM_ELITE 2
49#define PME_GA_NUM_COPIES_ELITE 2
50#define PME_GA_POPULATION 15
52#define PME_ANN_GHOST_RED_INPUT 2
53#define PME_ANN_GHOST_RED_HIDDEN 0
54#define PME_ANN_GHOST_RED_ACTIVATION ANN_ACTIVATION_SIGMOID
56#define PME_ANN_GHOST_PINK_INPUT 4
57#define PME_ANN_GHOST_PINK_HIDDEN 3
58#define PME_ANN_GHOST_PINK_ACTIVATION ANN_ACTIVATION_SIGMOID
60#define PME_ANN_GHOST_BLUE_INPUT 3
61#define PME_ANN_GHOST_BLUE_HIDDEN 2
62#define PME_ANN_GHOST_BLUE_ACTIVATION ANN_ACTIVATION_SIGMOID
64#define PME_ANN_GHOST_ORANGE_INPUT 3
65#define PME_ANN_GHOST_ORANGE_HIDDEN 0
66#define PME_ANN_GHOST_ORANGE_ACTIVATION ANN_ACTIVATION_SIGMOID
68#define PME_ANN_GHOST_OUTPUT 2
71class EVNTrainer :
public CMemPME
74 static EVNTrainer& Instance();
75 static void Terminate();
77 Sint32 load(
string& sGhostName, ArtificialNeuralNet* pNN,
string& sCDCFile,
string& sXMLName);
78 Sint32 execute(GlobalStatus&, GameField&);
83 static EVNTrainer* mInstance;
86 struct Creature :
public CMemPME
95 Sint32 iBestCreatureGeneration;
96 double dBestCreatureFitness;
97 Sint32 iNumBestCreatures;
98 vector<Genome> vBestCreaturesNN;
101 vector<BrainEvolved*> vBrains;
104 GeneticAlgorithm* pGA;
105 vector<Genome> vGenomesPopulation;
111 vector<Creature*> vCreatures;
114 Sint32 initCreatures(GlobalStatus& pGlobalStatus);
115 Sint32 createDefaultANN(
const string& sGhostName,
string sCDCFile,
string sXMLName);
116 Sint32 saveCreatures(
string sCDCFile,
string sXMLName);
117 Sint32 updateNode(XML* pXML, Creature* pCreature, Sint32 iNum);
118 Sint32 parseWeights(
char*, vector<double>&);
122 double dMutationRate;
123 double dCrossOverRate;
124 double dMaxPerturbation;
126 Sint32 iNumCopiesElite;