/// <summary> /// Uruchamianie Algorytmu Genetycznego /// </summary> private void StartGA() { RunGA(() => { //m_sampleController.Reset(); m_sampleContext.Population = new Population(Convert.ToInt32(PopulationMinUpDown.Value), Convert.ToInt32(PopulationMaxUpDown.Value), m_sampleController.CreateChromosome());//new IChromosome.BinaryChromosomeBase()); m_sampleContext.Population.GenerationStrategy = m_generationStrategy; m_ga = new MyGeneticAlgorithm(m_sampleContext.Population, m_fitness, m_selection, m_crossover, m_mutation); m_ga.CrossoverProbability = 0.75f; //Convert.ToSingle(hslCrossoverProbability.Value); m_ga.MutationProbability = Convert.ToSingle(MutationProbTrackbar.Value); // przechwycenie mutacji m_ga.Reinsertion = m_reinsertion; m_ga.Termination = m_termination; /*m_ga.Termination = new Termination( * if (TimeThresholdRadioBtn) m_termination = new TimeEvolvingTermination(); * else m_termination = new GenerationNumberTermination());*/ m_sampleContext.GA = m_ga; m_ga.GenerationRan += delegate { Gtk.Application.Invoke(delegate { m_sampleController.Update(); }); }; m_sampleController.ConfigGA(m_ga); m_ga.Start(); }); }
/** * CONSTRUCTOR */ public Bot(List <BoardConfiguration> historic) { this.historic = historic; base.board = GameObject.FindGameObjectWithTag("Board").GetComponent <Board>(); ga = new MyGeneticAlgorithm(base.board); configList = new List <BoardConfiguration>(); }
// Use this for initialization void Start() { random = new System.Random(); ga = new MyGeneticAlgorithm <float>(population, 3, random, GetRandomEntityValues, FitnessFunction, 5, 0.01f); flyingEntities = new FlyingEntity[population]; for (int i = 0; i < population; i++) { FlyingEntity flyingEntity = Instantiate(FlyingEntityPrefab, spawnPosition.position, Quaternion.identity).GetComponent <FlyingEntity>(); flyingEntities[i] = flyingEntity; flyingEntities[i].entityValues = new FlyingEntityValues(); flyingEntity.entityValues.DistanceForCollisionCheck = ga.Population[i].Genes[0]; flyingEntity.entityValues.DistanceForCollisionLeftAndRight = ga.Population[i].Genes[1]; flyingEntity.entityValues.Speed = ga.Population[i].Genes[2]; } }
/// <summary> /// Configure the Genetic Algorithm. /// </summary> /// <param name="ga">The genetic algorithm.</param> public virtual void ConfigGA(MyGeneticAlgorithm ga) { }