public Neuron CloneConnections(Neuron neuronArgs, Neuron[] neuronListArgs, bool negative) { Neuron newNeuron = new Neuron(neuronArgs.index, neuronArgs.layer); newNeuron.negative = negative; int index = -1; for (int x = 0; x < neuronArgs.connections.Count; x++) { index = neuronArgs.connections[x].index; if (index + 1 <= neuronListArgs.Length) { newNeuron.connections.Add(neuronListArgs[index]); } } return newNeuron; }
public Neuron[] ConnectInput(Neuron[] neuronListArgs, Neuron neuron) { Neuron[] neuronList = neuronListArgs; int randomInt = random.Next(2); int connections = 0; while (connections == 0) { for (int x = 0; x < neuronListArgs.Length; x++) { if (randomInt == 1) { neuronListArgs[x].connections.Add(neuron); connections += 1; } randomInt = random.Next(2); } } return neuronList; }
public NeuralNetwork(int inputCount, int hiddenCount, int outputCount) { input = new Neuron[inputCount]; for (int x = 0; x < input.Length; x++) { input[x] = new Neuron(x, 0); } hidden = new Neuron[hiddenCount]; for (int x = 0; x < hidden.Length; x++) { hidden[x] = new Neuron(x, 1); hidden[x].index = x; hidden[x].layer = 1; } output = new Neuron[outputCount]; for (int x = 0; x < output.Length; x++) { output[x] = new Neuron(x, 2); output[x].index = x; output[x].layer = 2; } }
public void EstablishExistingNetwork(Neuron[] inputArgs, Neuron[] hiddenArgs, Neuron[] outputArgs) { input = inputArgs; hidden = hiddenArgs; output = outputArgs; }
public Neuron CreateHidden(int index, bool negative) { Neuron newNeuron = new Neuron(index, 1); newNeuron.negative = negative; return newNeuron; }
public Neuron MutateNeuron(Neuron neuron, Neuron[] neuronList) { Neuron newNeuron = neuron; newNeuron.connections.Clear(); int randomInt = random.Next(2); while (newNeuron.connections.Count == 0) { for (int x = 0; x < neuronList.Length; x++) { if (randomInt == 1) newNeuron.connections.Add(neuronList[x]); randomInt = random.Next(2); } } return newNeuron; }