Пример #1
0
            public void CloneDoesNotAffectOriginalGeneTest()
            {
                List <ConnectionGene> originalGenes = new List <ConnectionGene>(_original.ConnectionGenes);

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

                Brain clone = _original.Clone();

                for (int i = 0; i < 100; i++)
                {
                    clone.Mutate();
                }

                CollectionAssert.AreEqual(_original.ConnectionGenes.ToList(), originalGenes);
            }
Пример #2
0
            public void Initialize()
            {
                _fakeUser = new User();
                Guid trainingRoomId = Guid.NewGuid();

                _roomName = "CoolRoom";

                //Create a training room with really high mutation settings
                TrainingRoomSettings trainingRoomSettings = new TrainingRoomSettings(trainingRoomId: trainingRoomId,
                                                                                     organismCount: 25,
                                                                                     inputCount: 3,
                                                                                     outputCount: 1,
                                                                                     c1: 1,
                                                                                     c2: 1,
                                                                                     c3: 0.4,
                                                                                     threshold: 3,
                                                                                     addConnectionChance: 1,
                                                                                     addNodeChance: 1,
                                                                                     crossOverChance: 0.75,
                                                                                     interSpeciesChance: 0.001,
                                                                                     mutationChance: 1,
                                                                                     mutateWeightChance: 0.8,
                                                                                     weightReassignChance: 0.1,
                                                                                     topAmountToSurvive: 0.5,
                                                                                     enableConnectionChance: 0.25,
                                                                                     seed: 1,
                                                                                     maxStagnantTime: 15,
                                                                                     championCloneMinSpeciesSize: 5);

                _organismFactory = new EvaluatableOrganismFactory();
                _trainingRoom    = new TrainingRoom(trainingRoomId, _fakeUser, _roomName, trainingRoomSettings, _organismFactory);

                for (int i = 0; i < trainingRoomSettings.OrganismCount; i++)
                {
                    EvaluatableOrganism organism = new EvaluatableOrganism(trainingRoomSettings, _trainingRoom.GetInnovationNumber)
                    {
                        IsLeased = true
                    };
                    _trainingRoom.AddOrganism(organism);
                }
                _trainingRoom.IncreaseNodeIdTo(trainingRoomSettings.InputCount + trainingRoomSettings.OutputCount);
            }