private void Initialization() { if (Settings.IS_NEURO && File.Exists(Settings.DATA_FILENAME)) { strategy = (Strategy)Network.Load(Settings.DATA_FILENAME); NeuroEvaluateFunction = strategy.Compute; enableNeuroSuccessful = true; } }
private void FindBestChromosome() { BestChromosome = population[0]; double fitnessMax = BestChromosome.Fitness; for (int i = 1; i < size; i++) { double fitness = population[i].Fitness; // check for max if (fitness > fitnessMax) { fitnessMax = fitness; BestChromosome = population[i]; } } }
public Strategy Clone() { DoubleArrayChromosome daChromosome = ToDoubleArrarChromosome(); Strategy s = new Strategy(activationFunction, inputsCount, neuronsCount); s.SetWithDoubleArrayChromosome(daChromosome); return s; }
public GameAINeuroEvolutionaryLearning(int size) { population = new List<Strategy>(); this.size = size; rand = new ThreadSafeRandom(); Strategy strategy = new Strategy( //new SigmoidFunction(), new LineFunction(), Settings.MAX_CHESSES, Settings.NETWORK_STRUCT); population.Add(strategy); for (int i = 0; i < size - 1; i++) { population.Add(strategy.CreateNew()); } }
public void Crossover(Strategy strategy) { if (strategy != null) { DoubleArrayChromosome c1 = ToDoubleArrarChromosome(); DoubleArrayChromosome c2 = strategy.ToDoubleArrarChromosome(); c1.Crossover(c2); SetWithDoubleArrayChromosome(c1); } else { throw new NullReferenceException(); } }