Beispiel #1
0
 private void Initialization()
 {
     if (Settings.IS_NEURO && File.Exists(Settings.DATA_FILENAME))
     {
         strategy = (Strategy)Network.Load(Settings.DATA_FILENAME);
         NeuroEvaluateFunction = strategy.Compute;
         enableNeuroSuccessful = true;
     }
 }
Beispiel #2
0
        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];
                }
            }
        }
Beispiel #3
0
 public Strategy Clone()
 {
     DoubleArrayChromosome daChromosome = ToDoubleArrarChromosome();
     Strategy s = new Strategy(activationFunction, inputsCount, neuronsCount);
     s.SetWithDoubleArrayChromosome(daChromosome);
     return s;
 }
Beispiel #4
0
 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());
     }
 }
Beispiel #5
0
 public void Crossover(Strategy strategy)
 {
     if (strategy != null)
     {
         DoubleArrayChromosome c1 = ToDoubleArrarChromosome();
         DoubleArrayChromosome c2 = strategy.ToDoubleArrarChromosome();
         c1.Crossover(c2);
         SetWithDoubleArrayChromosome(c1);
     }
     else
     {
         throw new NullReferenceException();
     }
 }