Ejemplo n.º 1
0
        private NeatNeuron AddNeuron(NeatNeuronType TheNeuronType = NeatNeuronType.Hidden)
        {
            NeatNeuron NewNeuron = new NeatNeuron((uint)AllNeurons.Count, TheNeuronType);

            AllNeurons.Add((uint)AllNeurons.Count, NewNeuron);
            return(NewNeuron);
        }
Ejemplo n.º 2
0
        private NeatNeuron InsertNeuron(int index, NeatNeuronType TheNeuronType = NeatNeuronType.Hidden)
        {
            NeatNeuron NewNeuron = new NeatNeuron((uint)AllNeurons.Count, TheNeuronType);

            AllNeurons.Insert(index, (uint)AllNeurons.Count, NewNeuron);
            return(NewNeuron);
        }
Ejemplo n.º 3
0
        public NeatNeuralNetwork(Stream TheStream)
        {
            using (BinaryReader TheBinaryReader = new BinaryReader(TheStream))
            {
                InputNeuronCount  = TheBinaryReader.ReadInt32();
                OutputNeuronCount = TheBinaryReader.ReadInt32();
                AllNeurons        = new OrderedDictionary(InputNeuronCount + OutputNeuronCount + 1);

                TopAncestorSeed = TheBinaryReader.ReadInt32();
                TheRandomizer   = new System.Random(TheBinaryReader.ReadInt32());

                int AllNeuronsCount = TheBinaryReader.ReadInt32();
                for (int i = 0; i < AllNeuronsCount; i++)
                {
                    uint           Key           = TheBinaryReader.ReadUInt32();
                    NeatNeuronType TheNeuronType = (NeatNeuronType)TheBinaryReader.ReadInt32();
                    NeatNeuron     TheNeuron     = new NeatNeuron(Key, TheNeuronType);

                    int IncomingConnectionsCount = TheBinaryReader.ReadInt32();
                    for (int j = 0; j < IncomingConnectionsCount; j++)
                    {
                        double TheWeight      = TheBinaryReader.ReadDouble();
                        uint   OtherNeuronKey = TheBinaryReader.ReadUInt32();
                        bool   Enabled        = TheBinaryReader.ReadBoolean();
                        TheNeuron.IncomingConnections.Add(new NeatConnection(TheWeight, OtherNeuronKey, Enabled));
                    }

                    AllNeurons.Add(Key, TheNeuron);
                }
            }
        }
Ejemplo n.º 4
0
            public NeatNeuron(NeatNeuron Main)
            {
                this.Key   = Main.Key;
                this.Value = Main.Value;

                foreach (NeatConnection aNeatConnection in Main.IncomingConnections)
                {
                    this.IncomingConnections.Add(new NeatConnection(aNeatConnection));
                }

                this.TheNeuronType = Main.TheNeuronType;
            }
Ejemplo n.º 5
0
 public NeatNeuron(uint Key, NeatNeuronType TheNeuronType)
 {
     this.Key           = Key;
     this.TheNeuronType = TheNeuronType;
 }