Ignore:
Timestamp:
02/15/19 03:09:31 (5 years ago)
Author:
Maciej Komosinski
Message:

The official C++17 fallthrough? attribute instead of comments no break

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cpp/frams/genetics/fB/fB_oper.cpp

    r821 r853  
    11// This file is a part of Framsticks SDK.  http://www.framsticks.com/
    2 // Copyright (C) 1999-2018  Maciej Komosinski and Szymon Ulatowski.
     2// Copyright (C) 1999-2019  Maciej Komosinski and Szymon Ulatowski.
    33// See LICENSE.txt for details.
    44
     
    301301                }
    302302        }
    303         /* no break */
     303        [[fallthrough]];
    304304        case FB_INSERTION:
    305305        {
     
    359359                res.insert(res.end(), iters[3], tokenized.end());
    360360
    361 //              SString first = line.substr(cuts[0], cuts[1] - cuts[0]);
    362 //              SString second = line.substr(cuts[2], cuts[3] - cuts[2]);
    363 //              SString result = line.substr(0, cuts[0]) + second +
    364 //                      line.substr(cuts[1], cuts[2] - cuts[1]) + first + line.substr(cuts[3]);
     361                //              SString first = line.substr(cuts[0], cuts[1] - cuts[0]);
     362                //              SString second = line.substr(cuts[2], cuts[3] - cuts[2]);
     363                //              SString result = line.substr(0, cuts[0]) + second +
     364                //                      line.substr(cuts[1], cuts[2] - cuts[1]) + first + line.substr(cuts[3]);
    365365                line = detokenizeSequence(&res);
    366366                chg = (float)(cuts[3] - cuts[2] + cuts[1] - cuts[0]) / line.len();
     
    420420                break;
    421421        }
    422 //      case FB_CROSSING_OVER:
    423 //      {
    424 //              // iterate through all genes of the first parent and assign them
    425 //              // randomly to children
    426 //              for (int i = 0; i < fB_GenoHelpers::geneCount(parent1); i++)
    427 //              {
    428 //                      int start, end;
    429 //                      SString gene = fB_GenoHelpers::getGene(i, parent1, start, end);
    430 //                      if (randomN(2) == 0)
    431 //                      {
    432 //                              child1 += gene;
    433 //                              chg1 += 1.0f;
    434 //                      }
    435 //                      else
    436 //                      {
    437 //                              child2 += gene;
    438 //                      }
    439 //              }
    440 //              chg1 /= fB_GenoHelpers::geneCount(parent1);
    441 //
    442 //              // do the same with second parent
    443 //              for (int i = 0; i < fB_GenoHelpers::geneCount(parent2); i++)
    444 //              {
    445 //                      int start, end;
    446 //                      SString gene = fB_GenoHelpers::getGene(i, parent2, start, end);
    447 //                      if (randomN(2) == 0)
    448 //                      {
    449 //                              child1 += gene;
    450 //                      }
    451 //                      else
    452 //                      {
    453 //                              child2 += gene;
    454 //                              chg2 += 1.0f;
    455 //                      }
    456 //              }
    457 //              chg2 /= fB_GenoHelpers::geneCount(parent2);
    458 //              break;
    459 //      }
     422        //      case FB_CROSSING_OVER:
     423        //      {
     424        //              // iterate through all genes of the first parent and assign them
     425        //              // randomly to children
     426        //              for (int i = 0; i < fB_GenoHelpers::geneCount(parent1); i++)
     427        //              {
     428        //                      int start, end;
     429        //                      SString gene = fB_GenoHelpers::getGene(i, parent1, start, end);
     430        //                      if (randomN(2) == 0)
     431        //                      {
     432        //                              child1 += gene;
     433        //                              chg1 += 1.0f;
     434        //                      }
     435        //                      else
     436        //                      {
     437        //                              child2 += gene;
     438        //                      }
     439        //              }
     440        //              chg1 /= fB_GenoHelpers::geneCount(parent1);
     441        //
     442        //              // do the same with second parent
     443        //              for (int i = 0; i < fB_GenoHelpers::geneCount(parent2); i++)
     444        //              {
     445        //                      int start, end;
     446        //                      SString gene = fB_GenoHelpers::getGene(i, parent2, start, end);
     447        //                      if (randomN(2) == 0)
     448        //                      {
     449        //                              child1 += gene;
     450        //                      }
     451        //                      else
     452        //                      {
     453        //                              child2 += gene;
     454        //                              chg2 += 1.0f;
     455        //                      }
     456        //              }
     457        //              chg2 /= fB_GenoHelpers::geneCount(parent2);
     458        //              break;
     459        //      }
    460460        case FB_CROSSING_OVER:
    461461        {
    462462                // get maximal count of genes from both parents
    463463                int maxgenecount = max(fB_GenoHelpers::geneCountNoNested(parent1),
    464                                 fB_GenoHelpers::geneCountNoNested(parent2));
     464                        fB_GenoHelpers::geneCountNoNested(parent2));
    465465
    466466                // while there are genes in at least one genotype
     
    472472                        // if both parents have genes available, then distribute them
    473473                        if (i < fB_GenoHelpers::geneCountNoNested(parent1) &&
    474                                         i < fB_GenoHelpers::geneCountNoNested(parent2))
     474                                i < fB_GenoHelpers::geneCountNoNested(parent2))
    475475                        {
    476476                                if (randomN(2) == 0)
Note: See TracChangeset for help on using the changeset viewer.