Ejemplo n.º 1
0
        private static ConnectionGene GetMatchingGene(NeatEvaluator evaluator, ConnectionGene connection1, ConnectionGene connection2, float disableInheritChance)
        {
            ConnectionGene geneToTake;

            if (evaluator.GetRandomFloat() < 0.5)
            {
                geneToTake = connection1.Copy(null);
            }
            else
            {
                geneToTake = connection2.Copy(null);
            }

            if (connection1.Enabled || connection2.Enabled)
            {
                if (!connection1.Enabled || !connection2.Enabled)
                {
                    geneToTake.Enabled = true;
                    if (evaluator.GetRandomFloat() < disableInheritChance)
                    {
                        geneToTake.Enabled = false;
                    }
                }
            }

            return(geneToTake);
        }
Ejemplo n.º 2
0
        public bool AddConnection(ConnectionGene connection)
        {
            if (Connections.AddNew(connection.Copy(null)))
            {
                //IncrementInnovationId();
                return(true);
            }

            return(false);
        }
Ejemplo n.º 3
0
        private static ConnectionGene GetGeneFromFitterParent(NeatEvaluator evaluator, Genome fitParent, bool fitnessEqual, ConnectionGene connection, Genome genome)
        {
            ConnectionGene geneToTake = null;

            if (fitnessEqual)
            {
                if (evaluator.GetRandomFloat() < 0.5)
                {
                    geneToTake = connection.Copy(null);
                }
            }
            else
            {
                if (genome == fitParent)
                {
                    geneToTake = connection.Copy(null);
                }
            }

            return(geneToTake);
        }