Ejemplo n.º 1
0
 public Genome(Neat neat)
 {
     Connections = new RandomHashSet <ConnectionGene>();
     Nodes       = new RandomHashSet <NodeGene>();
     Neat        = neat;
     _random     = new Random();
 }
Ejemplo n.º 2
0
        /// <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;
        }
Ejemplo n.º 3
0
        /// <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();
        }
Ejemplo n.º 4
0
        /// <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);
            }
        }
Ejemplo n.º 5
0
 public Neat(int inputSize, int outputSize, int clients)
 {
     _allConnections = new Dictionary <ConnectionGene, ConnectionGene>();
     _allNodes       = new RandomHashSet <NodeGene>();
     Reset(inputSize, outputSize, clients);
 }