public void setInstruction(int function, int index, Instruction other)
 {
     source_code[function].RemoveAt(index);
     source_code[function].Insert(index, other);
 }
 public void setInstruction(int GlobalIndex, Instruction other)
 {
     int curs = 0;
     int x = 0;
     int y = 0;
     for (x = 0; x < source_code.Count && curs < GlobalIndex; x++)
     {
         for (y= 0; y < source_code[x].Count && curs < GlobalIndex; y++)
         {
             curs++;
             if (curs >= GlobalIndex)
                 break;
         }
         if (curs >= GlobalIndex)
             break;
     }
     setInstruction(x, y, other);
 }
        public Sequence recombine(double swap_proba, Random r)
        {
            Sequence neo = new Sequence(this, false);

               for (int x = 0; x < neo.source_code.Count; x++)
               {
               Instruction first = new Instruction();
               int ystock = -1;

               for (int y = 0; y < neo.source_code[x].Count; y++)
               {
                   double dice = r.NextDouble();
                   if (dice < swap_proba)
                   {
                       if (ystock == -1)
                       {
                           ystock = y;
                           first = neo.source_code[x][y];
                       }
                       else
                       {
                           neo.setInstruction(x, ystock, neo.source_code[x][y]);
                           neo.setInstruction(x, y, first);
                           ystock = -1;
                       }
                   }

               }
               }

               return neo;
        }