public Genome(Neat neat) { Connections = new RandomHashSet <ConnectionGene>(); Nodes = new RandomHashSet <NodeGene>(); Neat = neat; _random = new Random(); }
/// <summary> /// Constructs a Genome with the given NEAT. /// </summary> /// <param name="neat">The NEAT this Genome is a part of.</param> /// <param name="capacity">The capacity of the Genome.</param> public Genome(NEAT neat, int capacity, Random random) { Connections = new RandomHashSet <ConnectionGene>(capacity); Nodes = new RandomHashSet <NodeGene>(capacity); NEAT = neat; this.random = random; }
/// <summary> /// Constructs a Genome with the given NEAT. /// </summary> /// <param name="neat">The NEAT this Genome is a part of.</param> public Genome(NEAT neat) { Connections = new RandomHashSet <ConnectionGene>(); Nodes = new RandomHashSet <NodeGene>(); NEAT = neat; random = new Random(); }
/// <summary> /// Constructs a new calculator for the given genome. /// </summary> /// <param name="genome">The genome to create a calculator for.</param> public Calculator(Genome genome) { RandomHashSet <NodeGene> nodes = genome.Nodes; RandomHashSet <ConnectionGene> connections = genome.Connections; Dictionary <int, Node> nodeDictionary = new Dictionary <int, Node>(); for (int i = 0; i < nodes.Size; ++i) { Node node = new Node(nodes[i].X); nodeDictionary.Add(nodes[i].InnovationNumber, node); if (node.X <= 0.1) { input_nodes.Add(node); } else if (node.X >= 0.9) { output_nodes.Add(node); } else { hidden_nodes.Add(node); } } hidden_nodes.Sort(); //Uses the comparer we set. for (int i = 0; i < connections.Size; ++i) { Node from = nodeDictionary[connections[i].From.InnovationNumber]; //new Node(connections[i].From.InnovationNumber); Node to = nodeDictionary[connections[i].To.InnovationNumber]; //new Node(connections[i].To.InnovationNumber); //Node from = new Node(connections[i].From.InnovationNumber); //Node to = new Node(connections[i].To.InnovationNumber); Connection connection = new Connection(from, to); connection.Weight = connections[i].Weight; connection.Enabled = connections[i].Enabled; to.Connections.Add(connection); } }
public Neat(int inputSize, int outputSize, int clients) { _allConnections = new Dictionary <ConnectionGene, ConnectionGene>(); _allNodes = new RandomHashSet <NodeGene>(); Reset(inputSize, outputSize, clients); }