Beispiel #1
0
 void Lose()
 {
     Globals.isPaused   = true;
     individual.fitness = ScoreManager.score + ((float)totalFrames / (float)50);
     ResetPosition();
     ResetVariables();
     GameObject.Find("Ball").GetComponent <Ball>().ResetRotation();
     ScoreManager.Reset();
     PopulationHelper.Advance();
 }
Beispiel #2
0
    void Start()
    {
        Config.SetIndividualsPerPopulation(14);
        Config.SetElite(4);
        Config.SetMutationRate(4.5f);
        Config.SetJumps(30);
        Config.SetMinMaxJumpFrames(0, 80);

        PopulationHelper.Init();
        PopulationHelper.StartIndividual(0);
    }
    void Start()
    {
        Config.SetLogFile("log.json");
        Config.SetIndividualsPerPopulation(20);
        Config.SetElite(4);
        Config.SetCrossover(Config.CrossoverAlgorithm.OneOfEach);
        Config.SetMutation(10.5f, Config.MutationAlgorithm.ModifiedValue);
        Config.SetJumps(30);
        Config.SetMinMaxJumpFrames(0, 65);

        PopulationHelper.Init();
        PopulationHelper.StartIndividual(0);
    }
Beispiel #4
0
    public static List <Individual> GetIndividualsWithHighestFitness(List <Individual> population, int nIndividuals)
    {
        List <Individual> populationCopy = PopulationHelper.CopyPopulation(population);
        List <Individual> individualsWithHighestFitness = new List <Individual>();

        for (int i = 0; i < nIndividuals; i++)
        {
            Individual individualWithHighestFitness = populationCopy[0];

            for (int j = 1; j < populationCopy.Count; j++)
            {
                if (populationCopy[j].fitness > individualWithHighestFitness.fitness)
                {
                    individualWithHighestFitness = populationCopy[j];
                }
            }

            individualsWithHighestFitness.Add(individualWithHighestFitness);
            populationCopy.Remove(individualWithHighestFitness);
        }

        return(individualsWithHighestFitness);
    }