Exemplo n.º 1
0
        /// <summary>
        /// Clones the organism.
        /// </summary>
        /// <param name="trainingRoomSettings">The training room settings.</param>
        /// <returns>Returns a clone of the organism.</returns>
        public Organism Clone(TrainingRoomSettings trainingRoomSettings)
        {
            // Prepares a new id for the organisms to clone with.
            Guid newGuid = Guid.NewGuid();

            // Create a new organism with the given node id and training room settings.
            return(new Organism(newGuid, trainingRoomSettings, Generation, ConnectionGenes.Select(gene => gene.Clone(newGuid)).ToList()));
            //TODO: When inputs can mutate they should also be cloned
        }
Exemplo n.º 2
0
 /// <summary>
 /// Clones this brain to produce a brain that equals the other brain but is not the same instance.
 /// </summary>
 /// <param name="newId">Determines whether a new Id should be generated for the clone.</param>
 /// <returns>Returns a new brain with the same genes, training room, inputCount and outputCount.</returns>
 public Brain Clone(bool newId = false)
 {
     return(new Brain(newId ? Guid.NewGuid() : Id, TrainingRoom, ConnectionGenes.Select(gene => gene.Clone()).ToList()));
 }