Exemple #1
0
    /// <summary>
    /// Create new Species which will have reference list to the cars with similar Genome.
    /// </summary>
    public Species(CarBrain firstBrain)
    {
        allCreatedSpeciesSum++;
        speciesNumber = allCreatedSpeciesSum;
        PickColor();

        brainsList.Add(firstBrain);
        bestGenomePattern = new Genome(CarBrain.InNodesNumber, CarBrain.OutNodesNumber);
        bestGenomePattern.CloneGenome(firstBrain.Genome);
    }
Exemple #2
0
    /// <summary>
    /// Update the best Species fitness and Genome pattern.
    /// </summary>
    public void UpdateBestFitness()
    {
        int      bestFitness = int.MinValue;
        CarBrain bestBrain   = null;

        foreach (CarBrain brain in brainsList)
        {
            if (bestFitness < brain.Fitness)
            {
                bestFitness = brain.Fitness;
                bestBrain   = brain;
            }
        }
        this.bestFitness = bestFitness;

        if (bestBrain != null)
        {
            bestGenomePattern.CloneGenome(bestBrain.Genome);
        }
    }