Esempio n. 1
0
 public S_Brain(S_Brain Parent1, S_Brain Parent2)
 {
     Neurons    = new S_Neuron[Parent1.Neurons.Length][];
     Neurons[0] = new S_Neuron[Parent1.Neurons[0].Length];
     for (int i = 0; i < Neurons[0].Length; i++)
     {
         Neurons[0][i] = new S_Neuron(RandomParent(Parent1, Parent2).Neurons[0][i]);
     }
     for (int layer = 0; layer < Parent1.Neurons.Length - 2; layer++)
     {
         Neurons[layer + 1] = new S_Neuron[Parent1.Neurons[layer + 1].Length];
         for (int i = 0; i < Parent1.Neurons[layer + 1].Length; i++)
         {
             Neurons[layer + 1][i] = new S_Neuron(RandomParent(Parent1, Parent2).Neurons[layer + 1][i]);
         }
     }
     Neurons[Parent1.Neurons.Length - 1] = new S_Neuron[Parent1.Neurons[Parent1.Neurons.Length - 1].Length];
     for (int i = 0; i < Parent1.Neurons[Parent1.Neurons.Length - 1].Length; i++)
     {
         Neurons[Parent1.Neurons.Length - 1][i] = new S_Neuron(RandomParent(Parent1, Parent2).Neurons[Parent1.Neurons.Length - 1][i]);
     }
     M_NeuronID = Parent1.M_NeuronID;
     for (int layer = 0; layer < Neurons.Length; layer++)
     {
         for (int i = 0; i < Neurons[layer].Length; i++)
         {
             Neurons[layer][i].CloneConnections(this, RandomParent(Parent1, Parent2).Neurons[layer][i]);
         }
     }
 }
Esempio n. 2
0
 public S_Brain(S_Brain clone)
 {
     Neurons    = new S_Neuron[clone.Neurons.Length][];
     Neurons[0] = new S_Neuron[clone.Neurons[0].Length];
     for (int i = 0; i < Neurons[0].Length; i++)
     {
         Neurons[0][i] = new S_Neuron(clone.Neurons[0][i]);
     }
     for (int layer = 0; layer < clone.Neurons.Length - 2; layer++)
     {
         Neurons[layer + 1] = new S_Neuron[clone.Neurons[layer + 1].Length];
         for (int i = 0; i < clone.Neurons[layer + 1].Length; i++)
         {
             Neurons[layer + 1][i] = new S_Neuron(clone.Neurons[layer + 1][i]);
         }
     }
     Neurons[clone.Neurons.Length - 1] = new S_Neuron[clone.Neurons[clone.Neurons.Length - 1].Length];
     for (int i = 0; i < clone.Neurons[clone.Neurons.Length - 1].Length; i++)
     {
         Neurons[clone.Neurons.Length - 1][i] = new S_Neuron(clone.Neurons[clone.Neurons.Length - 1][i]);
     }
     M_NeuronID = clone.M_NeuronID;
     for (int layer = 0; layer < Neurons.Length; layer++)
     {
         for (int i = 0; i < Neurons[layer].Length; i++)
         {
             Neurons[layer][i].CloneConnections(this, clone.Neurons[layer][i]);
         }
     }
 }
Esempio n. 3
0
 public S_Brain RandomParent(S_Brain Parent1, S_Brain Parent2)
 {
     if (GlobalRandom.random.Next(500) % 2 == 0)
     {
         return(Parent1);
     }
     return(Parent2);
 }
Esempio n. 4
0
 public void CloneConnections(S_Brain brain, S_Neuron cloneme)
 {
     connections = new List <S_Connection>(cloneme.connections.Count);
     foreach (S_Connection c in cloneme.connections)
     {
         connections.Add(new S_Connection(brain.getNeuron(c.target.Neuron_Id), c.Weight));
     }
 }