private NeatNeuron AddNeuron(NeatNeuronType TheNeuronType = NeatNeuronType.Hidden) { NeatNeuron NewNeuron = new NeatNeuron((uint)AllNeurons.Count, TheNeuronType); AllNeurons.Add((uint)AllNeurons.Count, NewNeuron); return(NewNeuron); }
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); }
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); } } }
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; }
public NeatNeuron(uint Key, NeatNeuronType TheNeuronType) { this.Key = Key; this.TheNeuronType = TheNeuronType; }