Example #1
0
            public void CloneDoesNotAffectOriginalGeneTest()
            {
                List <ConnectionGene> originalGenes = new List <ConnectionGene>(_original.ConnectionGenes);

                foreach (ConnectionGene gene in originalGenes)
                {
                    _trainingRoom.GetInnovationNumber(gene.InNodeIdentifier, gene.OutNodeIdentifier);
                    _trainingRoom.IncreaseNodeIdTo(Math.Max(gene.InNodeIdentifier, gene.OutNodeIdentifier) + 1);
                }

                Organism clone = _original.Clone(_trainingRoom.TrainingRoomSettings);

                for (int i = 0; i < 100; i++)
                {
                    clone.Mutate(_trainingRoom.TrainingRoomSettings, _trainingRoom.GetAndIncreaseNodeId, _trainingRoom.GetInnovationNumber);
                }

                CollectionAssert.AreEqual(_original.ConnectionGenes.ToList(), originalGenes);
            }