コード例 #1
0
        public void Crossover(VRandom rng, NetworkComp genome)
        {
            //determins the rate of crossover
            double rate = rng.RandDouble(0.25, 0.75);

            //calculates the maximum number of nurons and axons
            //this is nessary incase the genomes have diffrent numbers
            int nmax = Math.Min(this.NuronCount, genome.NuronCount);
            int amax = Math.Min(this.AxonCount, genome.AxonCount);

            for (int i = 0; i < nmax; i++)
            {
                if (rng.NextDouble() > rate)
                {
                    continue;
                }

                NuronComp copy = genome.nurons[i];
                nurons[i].Funciton = copy.Funciton;
            }

            for (int i = 0; i < amax; i++)
            {
                if (rng.NextDouble() > rate)
                {
                    continue;
                }

                //NOTE: should we copy the entier axon or just the weight?

                AxonComp copy = genome.axons[i];
                axons[i].Weight  = copy.Weight;
                axons[i].Enabled = copy.Enabled;

                axons[i].Input  = copy.Input;
                axons[i].Output = copy.Output;
            }

            throw new NotImplementedException();
        }