Exemple #1
0
        private void AddGeneFromThis(Gene curr1, Gene curr2, Dictionary <int, Node> dict, Random rnd, SortedList <int, Gene> genes)
        {
            var gene = curr1.ShallowCopy();

            AddNodesToDictIfNotIn(dict, gene); // Layers are OK
            gene.Type = (curr1.CrossoverChildDisabled(rnd, curr2)) ? GeneType.Enabled : GeneType.Disabled;
            genes.Add(gene.Innovation, gene);
        }
Exemple #2
0
        private void AddGeneFromOther(Gene curr1, Gene curr2, Dictionary <int, Node> dict, Random rnd, SortedList <int, Gene> genes)
        {
            var gene = curr2.ShallowCopy();

            AddNodesToDictIfNotIn(dict, gene); // Layers are not OK
            gene.Type = (curr2.CrossoverChildDisabled(rnd, curr1)) ? GeneType.Enabled : GeneType.Disabled;
            genes.Add(gene.Innovation, gene);
            // Correct Layers from more fit parent A.K.A. this genome
            gene.In.Layer  = curr1.In.Layer;
            gene.Out.Layer = curr1.Out.Layer;
        }