private int individualTrain() { int genBestFitness = 0; int totalTeamBest = 0; foreach (PokemonTeam t in testTeams) { Console.Write("\nTraining against a team with: "); foreach (Pokemon p in t.getMembers()) { Console.Write(p.getName()); } float[] testDNA = pD.createDnaUsingPkmn(t); input = testDNA; for (int j = 0; j < DNA.Count; j++) { fillNetwork(DNA[j]); calculate(); PokemonTeam attacker = pD.createTeamUsingDNA(output); string debug; debug = "\nAttacking team: "; foreach (Pokemon p in attacker.getMembers()) { debug = debug + p.getName() + " "; } //Console.Write(debug); int fitness = b.battle(attacker.getMembers(), t.getMembers()); fitnesses[j] = fitness; //Console.Write("\nFeedForward Fitness = " + fitness); if (fitness > genBestFitness) { genBestFitness = fitness; } } totalTeamBest += genBestFitness; evolve(); } Console.Write("\nCurrent total: " + totalTeamBest); return(totalTeamBest); }
public void test() { PokemonExperiment test = new PokemonExperiment(pD); config.Load("configfiles/NEATConfig.config.xml"); test.Initialize("Pokemon", config.DocumentElement); var genomeDecoder = test.CreateGenomeDecoder(); IBlackBox box = genomeDecoder.Decode(bestGenome); BattleHandler b = new BattleHandler(); int score = 0; List <PokemonTeam> evalTeams = pD.getEvalTeams(); foreach (PokemonTeam t in pD.getEvalTeams()) { string debug = "\nBattling against a team with: "; foreach (Pokemon p in t.getMembers()) { debug += p.getName() + " "; } Console.Write(debug); box.ResetState(); ISignalArray inputArray; inputArray = box.InputSignalArray; float[] pkmnDnaIn = pD.createDnaUsingPkmn(t); for (int j = 0; j < t.getMembers().Length; j++) { inputArray[j] = pkmnDnaIn[j]; } box.Activate(); ISignalArray outputArray; outputArray = box.OutputSignalArray; float[] pkmnDnaOut = new float[outputArray.Length]; for (int j = 0; j < pkmnDnaOut.Length; j++) { pkmnDnaOut[j] = (float)outputArray[j]; } PokemonTeam attacker = pD.createTeamUsingDNA(pkmnDnaOut); score += b.battle(attacker.getMembers(), t.getMembers()); } Console.Write("\nA Score of " + score + " was achieved agains the evaluation teams! (NEAT)"); Console.Write("\nThe NEAT has a complexity of " + bestGenome.Complexity); }
public FitnessInfo Evaluate(IBlackBox box) { int fitness = 0; List <PokemonTeam> testTeams = pD.getTestTeams(); for (int i = 0; i < triesPerTest; i++) { foreach (PokemonTeam t in testTeams) { string debug = "\nTraining against a team with: "; foreach (Pokemon p in t.getMembers()) { debug += p.getName() + " "; } // Console.Write(debug); box.ResetState(); ISignalArray inputArray; inputArray = box.InputSignalArray; float[] pkmnDnaIn = pD.createDnaUsingPkmn(t); for (int j = 0; j < t.getMembers().Length; j++) { inputArray[j] = pkmnDnaIn[j]; } box.Activate(); ISignalArray outputArray; outputArray = box.OutputSignalArray; float[] pkmnDnaOut = new float[outputArray.Length]; for (int j = 0; j < pkmnDnaOut.Length; j++) { pkmnDnaOut[j] = (float)outputArray[j]; } PokemonTeam attacker = pD.createTeamUsingDNA(pkmnDnaOut); fitness += b.battle(attacker.getMembers(), t.getMembers()); evaluations++; //Console.Write("\nEvaluations = " + evaluations); //Console.Write("\nCurrent Neat Fitness: " + fitness); } } return(new FitnessInfo(fitness, fitness)); }
void test(BattleHandler b) { Pokemon pk1 = new Pokemon(); Pokemon pk2 = new Pokemon(); Pokemon pk3 = new Pokemon(); Pokemon pk4 = new Pokemon(); Pokemon pk5 = new Pokemon(); Pokemon pk6 = new Pokemon(); pk4.setUp("Flygon;Dragon,Ground;Dragon,Ground,Normal,Fire,Rock,Flying"); pk5.setUp("Zoroark;Dark;Dark,Ghost,Fire,Psychic"); pk6.setUp("Archeops;Rock,Flying;Dark,Dragon,Normal,Ground,Fight,Rock,Flying"); pk1.setUp("Gallade;Fight,Psychic;Fight,Grass,Psychic,Electric,Ground,Ghost,Rock,Bug,Poison,Fairy"); pk2.setUp("Gardevoir;Psychic,Fairy;Fairy,Psychic,Electric,Ghost,Fight,Grass"); pk3.setUp("Klingklang;Steel;Electric,Steel,Normal"); Pokemon[] team1 = { pk1, pk2, pk3 }; Pokemon[] team2 = { pk4, pk5, pk6 }; b.battle(team1, team2); }