public void SetChromosome(ShooterChromosome chromosome, ShooterSampleConfig config) { Chromosome = chromosome; //Debug.Log("Setting Chromosome : " + Chromosome); Chromosome.MinDistanceFromTarget = DistanceFromTarget(); chromosome.Evaluated = false; m_startTime = Time.time; transform.rotation = Quaternion.identity; m_config = config; var phenotypes = chromosome.GetPhenotypes(); var str = phenotypes.Select(p => p.ThrowingVector).ToArray(); Y = str[0].y; Z = str[0].z; Strengh = str[0].x; if (m_cam != null) { m_cam.StartFollowing(gameObject); } SetBallColor(Color.green); //Appliquer la force StartCoroutine(Throwing()); //Calculer Fin de la Mesure StartCoroutine(CheckTimeout()); }
protected override GeneticAlgorithm CreateGA() { m_fitness = new ShooterFitness(); var chromosome = new ShooterChromosome(Config); var crossover = new UniformCrossover(); var mutation = new FlipBitMutation(); var selection = new EliteSelection(); var population = new Population(NumberOfSimultaneousEvaluations, NumberOfSimultaneousEvaluations, chromosome) { GenerationStrategy = new PerformanceGenerationStrategy() }; GeneticAlgorithm ga = new GeneticAlgorithm(population, m_fitness, selection, crossover, mutation) { Termination = new ShooterTermination(), TaskExecutor = new ParallelTaskExecutor { MinThreads = population.MinSize, MaxThreads = population.MaxSize * 2 } }; ga.GenerationRan += delegate { EvalutionInstancePosition = Vector3.zero; m_evaluationPool.ReleaseAll(); }; ga.MutationProbability = .1f; return(ga); }