Ejemplo n.º 1
0
        public static RMP_Connection GetConnectionFromGene(RMP_ConnectionGene gene, RMP_Neuron source, RMP_Net net)
        {
            var connection = new RMP_Connection();

            connection.ImprintGene(gene, source, net);

            return(connection);
        }
Ejemplo n.º 2
0
        public override void ImprintGenome(INeuralNetChromosome _genome)
        {
            var genome = (RMP_Chromosome)_genome;

            #region Creating the neurons
            foreach (var gene in genome.EyeRNeuronGenes)
            {
                var neuron = new RMP_InputNeuron(this);
                neuron.ImprintGene(gene);
                AddInputNeuron(neuron);
            }
            foreach (var gene in genome.EyeGNeuronGenes)
            {
                var neuron = new RMP_InputNeuron(this);
                neuron.ImprintGene(gene);
                AddInputNeuron(neuron);
            }
            foreach (var gene in genome.EyeBNeuronGenes)
            {
                var neuron = new RMP_InputNeuron(this);
                neuron.ImprintGene(gene);
                AddInputNeuron(neuron);
            }
            foreach (var gene in genome.DistanceNeuronGenes)
            {
                var neuron = new RMP_InputNeuron(this);
                neuron.ImprintGene(gene);
                AddInputNeuron(neuron);
            }

            foreach (var gene in genome.InputNeuronGenes)
            {
                var neuron = new RMP_InputNeuron(this);
                neuron.ImprintGene(gene);
                AddInputNeuron(neuron);
            }

            foreach (var gene in genome.HiddenNeuronGenes)
            {
                var neuron = new RMP_Neuron(this);
                neuron.ImprintGene(gene);
                AddHiddenNeuron(neuron);
            }
            foreach (var gene in genome.OutputNeuronGenes)
            {
                var neuron = new RMP_OutputNeuron(this);
                neuron.ImprintGene(gene);
                AddOutputNeuron(neuron);
            }

            #endregion

            #region Connection the neurons
            int count = 0;
            foreach (var gene in genome.EyeRNeuronGenes)
            {
                var neuron = InputNeurons[count++];

                foreach (var connectionGene in gene.Connections)
                {
                    neuron.Connections.Add(RMP_Connection.GetConnectionFromGene(connectionGene, neuron, this));
                }
            }

            foreach (var gene in genome.EyeGNeuronGenes)
            {
                var neuron = InputNeurons[count++];

                foreach (var connectionGene in gene.Connections)
                {
                    neuron.Connections.Add(RMP_Connection.GetConnectionFromGene(connectionGene, neuron, this));
                }
            }
            foreach (var gene in genome.EyeBNeuronGenes)
            {
                var neuron = InputNeurons[count++];

                foreach (var connectionGene in gene.Connections)
                {
                    neuron.Connections.Add(RMP_Connection.GetConnectionFromGene(connectionGene, neuron, this));
                }
            }

            foreach (var gene in genome.DistanceNeuronGenes)
            {
                var neuron = InputNeurons[count++];

                foreach (var connectionGene in gene.Connections)
                {
                    neuron.Connections.Add(RMP_Connection.GetConnectionFromGene(connectionGene, neuron, this));
                }
            }

            foreach (var gene in genome.InputNeuronGenes)
            {
                var neuron = InputNeurons[count++];

                foreach (var connectionGene in gene.Connections)
                {
                    neuron.Connections.Add(RMP_Connection.GetConnectionFromGene(connectionGene, neuron, this));
                }
            }

            count = 0;
            foreach (var gene in genome.HiddenNeuronGenes)
            {
                var neuron = HiddenNeurons[count++];

                foreach (var connectionGene in gene.Connections)
                {
                    neuron.Connections.Add(RMP_Connection.GetConnectionFromGene(connectionGene, neuron, this));
                }
            }

            count = 0;
            foreach (var gene in genome.OutputNeuronGenes)
            {
                var neuron = OutputNeurons[count++];

                foreach (var connectionGene in gene.Connections)
                {
                    neuron.Connections.Add(RMP_Connection.GetConnectionFromGene(connectionGene, neuron, this));
                }
            }

            #endregion
        }