Ejemplo n.º 1
0
        public override INeuralNetChromosome Clone()
        {
            var clone = new RMP_Chromosome();

            clone.InhibitoryConnectionChance = InhibitoryConnectionChance;
            clone.ConnectionChance           = ConnectionChance;

            clone.NewConnectionsCanForm = NewConnectionsCanForm;
            clone.ConnectionsCanDie     = ConnectionsCanDie;
            clone.NewNeuronsCanForm     = NewNeuronsCanForm;
            clone.NeuronsCanDie         = NeuronsCanDie;

            clone.EyeRNeuronGenes.AddRange(EyeRNeuronGenes.Select(n => (RMP_NeuronGene)n.Clone()));
            clone.EyeGNeuronGenes.AddRange(EyeGNeuronGenes.Select(n => (RMP_NeuronGene)n.Clone()));
            clone.EyeBNeuronGenes.AddRange(EyeBNeuronGenes.Select(n => (RMP_NeuronGene)n.Clone()));
            clone.DistanceNeuronGenes.AddRange(DistanceNeuronGenes.Select(n => (RMP_NeuronGene)n.Clone()));

            clone.HiddenNeuronGenes.AddRange(HiddenNeuronGenes.Select(n => (RMP_NeuronGene)n.Clone()));
            clone.InputNeuronGenes.AddRange(InputNeuronGenes.Select(n => (RMP_NeuronGene)n.Clone()));
            clone.OutputNeuronGenes.AddRange(OutputNeuronGenes.Select(n => (RMP_NeuronGene)n.Clone()));

            clone.MutationGenes.AddRange(MutationGenes.Select(n => (DoubleGene)n.Clone()));

            clone.GlobalSigmoidFunction       = (SigmoidFunction)GlobalSigmoidFunction.Clone();
            clone.GlobalOutputSigmoidFunction = (SigmoidFunction)GlobalOutputSigmoidFunction.Clone();

            return(clone);
        }
Ejemplo n.º 2
0
        public override void CreateRandom(int eyeNeurons, int inputs, int outputs, int hidden)
        {
            MutationGenes.Clear();

            MutationGenes.Add(new DoubleGene("NeuronAddChance", 0, 1, 0.1));
            MutationGenes.Add(new DoubleGene("NeuronRemoveChance", 0, 1, 0.1));
            MutationGenes.Add(new DoubleGene("MaxNeuronRemoving", 0, 1, 0.1));
            MutationGenes.Add(new DoubleGene("MaxNeuronAdding", 0, 1, 0.1));
            MutationGenes.Add(new DoubleGene("ConnectionAddChance", 0, 1, 0.1));
            MutationGenes.Add(new DoubleGene("ConnectionRemoveChance", 0, 1, 0.1));

            EyeRNeuronGenes.Clear();
            EyeGNeuronGenes.Clear();
            EyeBNeuronGenes.Clear();
            DistanceNeuronGenes.Clear();

            for (int i = 0; i < eyeNeurons; i++)
            {
                EyeRNeuronGenes.Add(GetRandomNeuronGene("Red"));
            }
            for (int i = 0; i < eyeNeurons; i++)
            {
                EyeGNeuronGenes.Add(GetRandomNeuronGene("Green"));
            }
            for (int i = 0; i < eyeNeurons; i++)
            {
                EyeBNeuronGenes.Add(GetRandomNeuronGene("Blue"));
            }
            for (int i = 0; i < eyeNeurons; i++)
            {
                DistanceNeuronGenes.Add(GetRandomNeuronGene("Distance"));
            }

            HiddenNeuronGenes.Clear();
            InputNeuronGenes.Clear();
            OutputNeuronGenes.Clear();

            for (int n = 0; n < hidden; n++)
            {
                HiddenNeuronGenes.Add(GetRandomNeuronGene("Hidden Neuron"));
            }
            for (int n = 0; n < inputs; n++)
            {
                InputNeuronGenes.Add(GetRandomNeuronGene("Input Neuron"));
            }
            for (int n = 0; n < outputs; n++)
            {
                OutputNeuronGenes.Add(GetRandomNeuronGene("Output Neuron"));
            }

            foreach (var gene in EyeRNeuronGenes)
            {
                ConnectRandomly(gene, true);
            }
            foreach (var gene in EyeGNeuronGenes)
            {
                ConnectRandomly(gene, true);
            }
            foreach (var gene in EyeBNeuronGenes)
            {
                ConnectRandomly(gene, true);
            }
            foreach (var gene in DistanceNeuronGenes)
            {
                ConnectRandomly(gene, true);
            }

            foreach (var gene in HiddenNeuronGenes)
            {
                ConnectRandomly(gene, false);
            }
            foreach (var gene in InputNeuronGenes)
            {
                ConnectRandomly(gene, true);
            }
        }