示例#1
0
 public AddConnectionMutation(IInnovationPointGenerator connectionInnovationGenerator, IRandom random, double probabilityPerturbing, int maxAttempts)
 {
     _connectionInnovationGenerator = connectionInnovationGenerator;
     _random = random;
     _probabilityPerturbing = probabilityPerturbing;
     _maxAttempts           = maxAttempts;
 }
示例#2
0
        public Connection Copy(IInnovationPointGenerator innovationGenerator)
        {
            var copy = Copy();

            copy.Id = innovationGenerator.GetNextInnovation();
            return(copy);
        }
示例#3
0
 public XORNNProvider(IInnovationPointGenerator nodeGenerator, IInnovationPointGenerator connectionGenerator, IRandom random, Genome grandFather)
 {
     _nodeGenerator       = nodeGenerator;
     _connectionGenerator = connectionGenerator;
     _random      = random;
     _grandFather = grandFather;
 }
示例#4
0
        public Evaluator(INeatConfiguration neatConfiguration, IGenesisGenomeProvider genomeProvider, IInnovationPointGenerator nodeInnovationGenerator, IInnovationPointGenerator connectionInnovationGenerator, IMutation addConnectionMutation, IMutation addNodeMutation, IMutation weightMutation, ICrossFunctionStrategy crossFunctionStrategy, IRandom random)
        {
            _neatConfiguration             = neatConfiguration;
            _nodeInnovationGenerator       = nodeInnovationGenerator;
            _connectionInnovationGenerator = connectionInnovationGenerator;
            _addConnectionMutation         = addConnectionMutation;
            _addNodeMutation       = addNodeMutation;
            _weightMutation        = weightMutation;
            _crossFunctionStrategy = crossFunctionStrategy;
            _random  = random;
            _genomes = Enumerable.Repeat(genomeProvider.GenerateGenesisGenome(), neatConfiguration.PopulationSize).ToList();

            _evaluatedGenomes = new List <FitnessGenome>();
            _nextGeneration   = new List <Genome>();

            _lastGenerationResults = new List <FitnessGenome>();
        }
示例#5
0
文件: Tests2.cs 项目: mrBoie/NeatPlay
            private Genome GenerateTemplateGenome(IInnovationPointGenerator nodeGenerator, IInnovationPointGenerator connectionGenerator)
            {
                var genome = new Genome();

                genome.Nodes =
                    Enumerable
                    .Repeat(1, 3)
                    .Select(n => new Node
                {
                    Id       = nodeGenerator.GetNextInnovation(),
                    NodeType = NodeType.Sensor
                })
                    .ToDictionary(n => n.Id, n => n);

                var outputId = nodeGenerator.GetNextInnovation();

                genome.Nodes.Add(outputId, new Node {
                    Id = outputId, NodeType = NodeType.Output
                });

                var c1 = new Connection
                {
                    Id        = connectionGenerator.GetNextInnovation(),
                    InNodeId  = genome.Nodes.First(n => n.Value.NodeType == NodeType.Sensor).Key,
                    OutNodeId = genome.Nodes.First(n => n.Value.NodeType == NodeType.Output).Key,
                    IsEnabled = true,
                    Weight    = 0.5
                };
                var c2 = new Connection
                {
                    Id        = connectionGenerator.GetNextInnovation(),
                    InNodeId  = genome.Nodes.Last(n => n.Value.NodeType == NodeType.Sensor).Key,
                    OutNodeId = genome.Nodes.First(n => n.Value.NodeType == NodeType.Output).Key,
                    IsEnabled = true,
                    Weight    = 0.5
                };

                genome.Connections = new Dictionary <int, Connection>();
                genome.Connections.Add(c1.Id, c1);
                genome.Connections.Add(c2.Id, c2);

                return(genome);
            }
示例#6
0
 public void Init()
 {
     _nodeInnovationGenerator       = Substitute.For <IInnovationPointGenerator>();
     _connectionInnovationGenerator = Substitute.For <IInnovationPointGenerator>();
     _randomizer = Substitute.For <IRandom>();
 }
示例#7
0
 public AddConnectionMutation(IInnovationPointGenerator connectionInnovator, IRandom random, INeatConfiguration configuration) :
     this(connectionInnovator, random, configuration.PerturbingRate, configuration.MaxAttemptsAtFindingConnections)
 {
 }
示例#8
0
文件: Tests2.cs 项目: mrBoie/NeatPlay
 public GenomeProvider(IInnovationPointGenerator nodeGenerator, IInnovationPointGenerator connectionGenerator, IRandom random, Genome grandFather)
 {
     _GenomeGrandfather = grandFather;
     _random            = random;
 }
示例#9
0
文件: Tests2.cs 项目: mrBoie/NeatPlay
 public GenomeProvider(IInnovationPointGenerator nodeGenerator, IInnovationPointGenerator connectionGenerator, IRandom random)
 {
     _GenomeGrandfather = GenerateTemplateGenome(nodeGenerator, connectionGenerator);
     _random            = random;
 }
示例#10
0
文件: Tests2.cs 项目: mrBoie/NeatPlay
 public WeightOfAHundred(INeatConfiguration neatConfiguration, IGenesisGenomeProvider genomeProvider, IInnovationPointGenerator nodeInnovationGenerator, IInnovationPointGenerator connectionInnovationGenerator, IMutation addConnectionMutation, IMutation addNodeMutation, IMutation weightMutation, ICrossFunctionStrategy crossFunctionStrategy, IRandom random) : base(neatConfiguration, genomeProvider, nodeInnovationGenerator, connectionInnovationGenerator, addConnectionMutation, addNodeMutation, weightMutation, crossFunctionStrategy, random)
 {
 }
示例#11
0
 public XORNNEvaluator(INeatConfiguration neatConfiguration, IGenesisGenomeProvider genomeProvider, IInnovationPointGenerator nodeInnovationGenerator, IInnovationPointGenerator connectionInnovationGenerator, IMutation addConnectionMutation, IMutation addNodeMutation, IMutation weightMutation, ICrossFunctionStrategy crossFunctionStrategy, IRandom random, ProblemDomain problemDomain) : base(neatConfiguration, genomeProvider, nodeInnovationGenerator, connectionInnovationGenerator, addConnectionMutation, addNodeMutation, weightMutation, crossFunctionStrategy, random)
 {
     _problemDomain = problemDomain;
 }
示例#12
0
 public AddNodeMutation(IInnovationPointGenerator nodeInnovationGenerator, IInnovationPointGenerator connectionInnovationGenerator, IRandom random)
 {
     this.nodeInnovationGenerator       = nodeInnovationGenerator;
     this.connectionInnovationGenerator = connectionInnovationGenerator;
     this.random = random;
 }
 public void Init()
 {
     _config = new DefaultNeatConfiguration(23);
     _innovationPointGenerator = Substitute.For <IInnovationPointGenerator>();
     _random = Substitute.For <IRandom>();
 }