/// <summary> /// If using NEAT, this function simply sets the AgentBrain genome variable as the brain. Otherwise, the genome is actually used as a genome and is decoded into the appropriate brain structure. /// </summary> private void createBrains() { if (Genome != null) { if (NeatBrain) { Brain = Genome; } else if (Homogeneous) { ANN = SubstrateDescription.generateHomogeneousGenome(Genome, NormalizeANNWeights, this.AdaptableANN, this.ModulatoryANN, EvolveSubstrate); Brains = new List <INetwork>(); for (int i = 0; i < NumRobots; i++) { INetwork b = ANN.Decode(null); Brains.Add(b); } } else { if (MultipleBrains) { List <NeatGenome> genes = SubstrateDescription.generateGenomeStackSituationalPolicy(Genome, Convert.ToUInt32(NumRobots), NormalizeANNWeights, AdaptableANN, ModulatoryANN, 2, out ZCoordinates); for (int j = 0; j < genes.Count; j++) { MultiBrains.Add(genes[j].Decode(null)); } Brain = MultiBrains[0]; } else if (Hive) { ANN = SubstrateDescription.generateHiveBrainGenomeStack(Genome, Convert.ToUInt32(NumRobots), NormalizeANNWeights, AdaptableANN, ModulatoryANN, out ZCoordinates, EvolveSubstrate, UseCTRNNs); Brain = UseCTRNNs ? ANN.DecodeToCTRNN() : ANN.Decode(null); } else { ANN = SubstrateDescription.generateMultiGenomeStack(Genome, Convert.ToUInt32(NumRobots), NormalizeANNWeights, AdaptableANN, ModulatoryANN, out ZCoordinates, EvolveSubstrate); Brain = ANN.Decode(null); } } } }
private void createBrains() { if (genome != null) { if (homogenous) { ANN = substrateDescription.generateHomogeneousGenome(genome, normalizeANNWeights, this.adaptableANN, this.modulatoryANN, evolveSubstrate); brains = new List <INetwork>(); for (int i = 0; i < numRobots; i++) { INetwork b = ANN.Decode(null); brains.Add(b); } } else { if (multipleBrains) //Multiple brains with situational policies { List <NeatGenome> genes = substrateDescription.generateGenomeStackSituationalPolicy(genome, Convert.ToUInt32(numRobots), normalizeANNWeights, adaptableANN, modulatoryANN, 2, out zcoordinates); for (int j = 0; j < genes.Count; j++) { multiBrains.Add(genes[j].Decode(null)); } brain = multiBrains[0]; } else { ANN = substrateDescription.generateMultiGenomeStack(genome, Convert.ToUInt32(numRobots), normalizeANNWeights, adaptableANN, modulatoryANN, out zcoordinates, evolveSubstrate); brain = ANN.Decode(null); } } } }
private void createBrains() { if (genome != null) { //Schrum: debugging //Console.WriteLine("genome != null"); if (homogenous) { //Schrum: debugging //Console.WriteLine("homogenous"); ANN = substrateDescription.generateHomogeneousGenome(genome, normalizeANNWeights, this.adaptableANN, this.modulatoryANN, evolveSubstrate); brains = new List <INetwork>(); for (int i = 0; i < numRobots; i++) { INetwork b = ANN.Decode(null); brains.Add(b); } } else { //Schrum: debugging //Console.WriteLine("!homogenous"); if (multipleBrains) //Multiple brains with situational policies { //Schrum: debugging //Console.WriteLine("multipleBrains"); // Schrum: The original code hard codes "2" as the nubmer of brains for any multi brain scenario TODO //List<NeatGenome> genes = substrateDescription.generateGenomeStackSituationalPolicy(genome, Convert.ToUInt32(numRobots), normalizeANNWeights, adaptableANN, modulatoryANN, 2, out zcoordinates); List <NeatGenome> genes = substrateDescription.generateGenomeStackSituationalPolicy(genome, Convert.ToUInt32(numRobots), normalizeANNWeights, adaptableANN, modulatoryANN, numBrains, out zcoordinates, forcedSituationalPolicyGeometry); // Schrum: Debugging module deletion /** * if(genes.Count == 0) * { * Console.WriteLine("InputNeuronCount :" + genome.InputNeuronCount); * Console.WriteLine("NumLinks :" + genome.NumLinks); * Console.WriteLine("NumOutputModules :" + genome.NumOutputModules); * Console.WriteLine("OutputNeuronCount:" + genome.OutputNeuronCount); * Console.WriteLine("OutputsPerPolicy :" + genome.OutputsPerPolicy); * Console.WriteLine("TotalNeuronCount :" + genome.TotalNeuronCount); * * throw new Exception("How is genes.Count 0!"); * } **/ for (int j = 0; j < genes.Count; j++) { multiBrains.Add(genes[j].Decode(null)); } // Schrum: for debugging /* * for (int j = 0; j < multiBrains.Count; j++) * { * if (multiBrains[j] == null) * { * Console.WriteLine(j +": Null brain!"); * } * else * { * Console.WriteLine(j + ":" + multiBrains[j]); * Console.WriteLine(j + ":CurrentOutputModule:" + multiBrains[j].CurrentOutputModule); * Console.WriteLine(j + ":InputNeuronCount:" + multiBrains[j].InputNeuronCount); * Console.WriteLine(j + ":OutputNeuronCount:" + multiBrains[j].OutputNeuronCount); * Console.WriteLine(j + ":OutputsPerPolicy:" + multiBrains[j].OutputsPerPolicy); * Console.WriteLine(j + ":TotalNeuronCount:" + multiBrains[j].TotalNeuronCount); * Console.WriteLine(j + ":NumOutputModules:" + multiBrains[j].NumOutputModules); * } * } */ brain = multiBrains[0]; } else { //Schrum: debugging //Console.WriteLine("!multipleBrains"); ANN = substrateDescription.generateMultiGenomeStack(genome, Convert.ToUInt32(numRobots), normalizeANNWeights, adaptableANN, modulatoryANN, out zcoordinates, evolveSubstrate); brain = ANN.Decode(null); } } } }