Exemplo n.º 1
0
        /// <summary>
        /// Construct a genome, do not provide links and neurons.
        /// </summary>
        /// <param name="training">The owner object.</param>
        /// <param name="id">The genome id.</param>
        /// <param name="inputCount">The input count.</param>
        /// <param name="outputCount">The output count.</param>
        public NEATGenome(NEATTraining training, long id,
                          int inputCount, int outputCount)
            : base(training)
        {
            GenomeID         = id;
            AdjustedScore    = 0;
            this.inputCount  = inputCount;
            this.outputCount = outputCount;
            AmountToSpawn    = 0;
            speciesID        = 0;

            double inputRowSlice = 0.8 / (inputCount);

            neuronsChromosome = new Chromosome();
            linksChromosome   = new Chromosome();

            for (int i = 0; i < inputCount; i++)
            {
                neuronsChromosome.Genes.Add(new NEATNeuronGene(NEATNeuronType.Input, i,
                                                               0, 0.1 + i * inputRowSlice));
            }

            neuronsChromosome.Genes.Add(new NEATNeuronGene(NEATNeuronType.Bias,
                                                           inputCount, 0, 0.9));

            double outputRowSlice = 1 / (double)(outputCount + 1);

            for (int i = 0; i < outputCount; i++)
            {
                neuronsChromosome.Genes.Add(new NEATNeuronGene(NEATNeuronType.Output, i
                                                               + inputCount + 1, 1, (i + 1) * outputRowSlice));
            }

            for (int i = 0; i < inputCount + 1; i++)
            {
                for (int j = 0; j < outputCount; j++)
                {
                    linksChromosome.Genes.Add(new NEATLinkGene(
                                                  ((NEATNeuronGene)neuronsChromosome.Genes[i]).Id,
                                                  ((NEATNeuronGene)Neurons.Genes[inputCount + j + 1])
                                                  .Id, true, inputCount + outputCount + 1
                                                  + NumGenes, RangeRandomizer.Randomize(-1,
                                                                                        1), false));
                }
            }

            this.Chromosomes.Add(neuronsChromosome);
            this.Chromosomes.Add(linksChromosome);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Create a NEAT gnome.
        /// </summary>
        /// <param name="training">The owner object.</param>
        /// <param name="genomeID">The genome id.</param>
        /// <param name="neurons">The neurons.</param>
        /// <param name="links">The links.</param>
        /// <param name="inputCount">The input count.</param>
        /// <param name="outputCount">The output count.</param>
        public NEATGenome(NEATTraining training, long genomeID,
                          Chromosome neurons, Chromosome links,
                          int inputCount, int outputCount)
            : base(training)
        {
            GenomeID          = genomeID;
            linksChromosome   = links;
            neuronsChromosome = neurons;
            AmountToSpawn     = 0;
            AdjustedScore     = 0;
            this.inputCount   = inputCount;
            this.outputCount  = outputCount;

            this.Chromosomes.Add(neuronsChromosome);
            this.Chromosomes.Add(linksChromosome);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Construct a genome, do not provide links and neurons. 
        /// </summary>
        /// <param name="training">The owner object.</param>
        /// <param name="id">The genome id.</param>
        /// <param name="inputCount">The input count.</param>
        /// <param name="outputCount">The output count.</param>
        public NEATGenome(NEATTraining training, long id,
                int inputCount, int outputCount)
            : base(training)
        {

            GenomeID = id;
            AdjustedScore = 0;
            this.inputCount = inputCount;
            this.outputCount = outputCount;
            AmountToSpawn = 0;
            speciesID = 0;

            double inputRowSlice = 0.8 / (inputCount);
            neuronsChromosome = new Chromosome();
            linksChromosome = new Chromosome();

            for (int i = 0; i < inputCount; i++)
            {
                neuronsChromosome.Genes.Add(new NEATNeuronGene(NEATNeuronType.Input, i,
                        0, 0.1 + i * inputRowSlice));
            }

            neuronsChromosome.Genes.Add(new NEATNeuronGene(NEATNeuronType.Bias,
                    inputCount, 0, 0.9));

            double outputRowSlice = 1 / (double)(outputCount + 1);

            for (int i = 0; i < outputCount; i++)
            {
                neuronsChromosome.Genes.Add(new NEATNeuronGene(NEATNeuronType.Output, i
                        + inputCount + 1, 1, (i + 1) * outputRowSlice));
            }

            for (int i = 0; i < inputCount + 1; i++)
            {
                for (int j = 0; j < outputCount; j++)
                {
                    linksChromosome.Genes.Add(new NEATLinkGene(
                            ((NEATNeuronGene)neuronsChromosome.Genes[i]).Id,
                            ((NEATNeuronGene)Neurons.Genes[inputCount + j + 1])
                                    .Id, true, inputCount + outputCount + 1
                                    + NumGenes, RangeRandomizer.Randomize(-1,
                                    1), false));
                }
            }

            this.Chromosomes.Add(neuronsChromosome);
            this.Chromosomes.Add(linksChromosome);

        }
Exemplo n.º 4
0
        /// <summary>
        /// Create a NEAT gnome. 
        /// </summary>
        /// <param name="training">The owner object.</param>
        /// <param name="genomeID">The genome id.</param>
        /// <param name="neurons">The neurons.</param>
        /// <param name="links">The links.</param>
        /// <param name="inputCount">The input count.</param>
        /// <param name="outputCount">The output count.</param>
        public NEATGenome(NEATTraining training, long genomeID,
                Chromosome neurons, Chromosome links,
                int inputCount, int outputCount)
            : base(training)
        {
            GenomeID = genomeID;
            linksChromosome = links;
            neuronsChromosome = neurons;
            AmountToSpawn = 0;
            AdjustedScore = 0;
            this.inputCount = inputCount;
            this.outputCount = outputCount;

            this.Chromosomes.Add(neuronsChromosome);
            this.Chromosomes.Add(linksChromosome);
        }