public Network() { for (int i = 0; i < NETWORK_DEPTH; i++){ _neurons[i] = new Neuron[NETWORK_BREADTH]; for (int j = 0; j < _neurons[i].Length; j++) { _neurons[i][j] = new Neuron(j%2 == 0 , j==0); } } }
public Network(Network n) { for (int i = 0; i < _neurons.Length; i++){ _neurons[i] = new Neuron[NETWORK_BREADTH]; for (int j = 0; j < _neurons[i].Length; j++){ _neurons[i][j] = new Neuron(n._neurons[i][j]); } } }
public Neuron(Neuron n) { _sum = n._sum; _first = n._first; if (_first) _values = new float[Network.FIRST_BREADTH]; for (int i = 0; i < n._values.Length; i++){ _values[i] = n._values[i]; } }
public static void Crossover(Neuron n1, Neuron n2) { if (n1._sum != n2._sum){ n1._sum = !n1._sum; n2._sum = !n2._sum; } else if (n1._first){ int border = Program.RandomGenerator.Next(Network.NETWORK_BREADTH); for (int i = 0; i < border; i++){ float tmp = n1._values[i]; n1._values[i] = n2._values[i]; n2._values[i] = tmp; } } else for (int i = 0; i < n1._values.Length; i++){ n1._values[i] = (n1._values[i] + n2._values[i])/2; n2._values[i] = n1._values[i]; } }