Changeset 973 for cpp/frams/genetics


Ignore:
Timestamp:
07/03/20 00:37:13 (4 years ago)
Author:
Maciej Komosinski
Message:

Increased SString and std::string compatibility: introduced length(), size(), and capacity(), and removed legacy methods that have std::string equivalents

Location:
cpp/frams/genetics
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • cpp/frams/genetics/f4/f4_general.cpp

    r955 r973  
    11// This file is a part of Framsticks SDK.  http://www.framsticks.com/
    2 // Copyright (C) 1999-2019  Maciej Komosinski and Szymon Ulatowski.
     2// Copyright (C) 1999-2020  Maciej Komosinski and Szymon Ulatowski.
    33// See LICENSE.txt for details.
    44
     
    12931293        if (2 == childCount())
    12941294                if (0 == out[0]) out += ">"; else
    1295                         if ('>' != out[out.len() - 1]) out += ">";
     1295                        if ('>' != out[out.length() - 1]) out += ">";
    12961296        if (NULL != child2)    child2->sprint(out);
    12971297        // make sure last char is a '>'
    12981298        if (0 == out[0]) out += ">"; else
    1299                 if ('>' != out[out.len() - 1]) out += ">";
     1299                if ('>' != out[out.length() - 1]) out += ">";
    13001300}
    13011301
     
    13101310
    13111311        // very last '>' can be omitted
    1312         len = out.len();
     1312        len = out.length();
    13131313        if (len > 1)
    13141314                if ('>' == out[len - 1]) { (out.directWrite())[len - 1] = 0; out.endWrite(); };
  • cpp/frams/genetics/f9/f9_conv.cpp

    r779 r973  
    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-2020  Maciej Komosinski and Szymon Ulatowski.
    33// See LICENSE.txt for details.
    44
     
    3232        m.open(using_checkpoints);
    3333        int recently_added = addSegment(m, 0, vertices, current, 0xDead);
    34         for (int i = 0; i < in.len(); i++)
     34        for (int i = 0; i < in.length(); i++)
    3535        {
    3636                char command = in[i];
     
    119119        double d1 = ind - indpre;
    120120        double d2 = indpost - ind;
    121         double v = indpre == indpost ? v1 : d2*v1 + d1*v2; //d1+d2==1
     121        double v = indpre == indpost ? v1 : d2 * v1 + d1 * v2; //d1+d2==1
    122122        return v;
    123123}
     
    136136                Joint *j = m.getJoint(i);
    137137                double x = joints_count < 2 ? 0 : (double)i / (joints_count - 1); //0..1, postion in the rainbow
    138                 double ind = x*maxind;
     138                double ind = x * maxind;
    139139                j->vcolor.x = mix(r, maxind, ind);
    140140                j->vcolor.y = mix(g, maxind, ind);
     
    153153                        averagecolor += j->vcolor;
    154154                p->vcolor = averagecolor / count;
    155                 if (count>5) count = 5; //avoid too fat...
     155                if (count > 5) count = 5; //avoid too fat...
    156156                p->vsize = 0.3 + count / 15.0; //the more Joints is attached to a Part, the fatter it is
    157157        }
     
    169169                        ((3 * i + 5) % 10) - 4.5,
    170170                        ((7 * i + 2) % 10) - 4.5
    171                         ); //-4.5 .. 4.5 in each axis
     171                ); //-4.5 .. 4.5 in each axis
    172172                p->p += noise / 1000;
    173173        }
  • cpp/frams/genetics/fB/fB_conv.cpp

    r954 r973  
    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-2020  Maciej Komosinski and Szymon Ulatowski.
    33// See LICENSE.txt for details.
    44
     
    8080                int endoffset = 0;
    8181                if (gene.indexOf("zz", 0) != -1) endoffset = 2;
    82                 if (gene.len() - endoffset < 3)
     82                if (gene.length() - endoffset < 3)
    8383                {
    8484                        fH_StickHandle *handle = new fH_StickHandle(dims, start, end);
     
    124124                if (gene.indexOf("zz", 0) != -1) endoffset = 2;
    125125                int nclassdefcount = 1;
    126                 while (z < gene.len() - endoffset)
     126                while (z < gene.length() - endoffset)
    127127                {
    128128                        if (processNextLetter(creature, handle, par, gene, propindex, z, ranges, nclassdefcount) == -1)
     
    185185                        }
    186186                        nextid++;
    187                 }
    188                 while (genotype[nextid] == '"');
     187                } while (genotype[nextid] == '"');
    189188                i = nextid;
    190189        }
  • cpp/frams/genetics/fB/fB_general.h

    r802 r973  
    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-2020  Maciej Komosinski and Szymon Ulatowski.
    33// See LICENSE.txt for details.
    44
     
    3535                do {
    3636                        count++;
    37                         if (start < genotype.len())
     37                        if (start < genotype.length())
    3838                                result = getNextGene(start, genotype, tmp, start);
    3939                        else
     
    5252                do {
    5353                        count++;
    54                         if (start < geno.len())
     54                        if (start < geno.length())
    5555                                getNextGene(start, geno, tmp, start);
    5656                        else
     
    8989                } while (quotecount % 2 != 0 && end != -1);
    9090
    91                 if (end == -1) end = genotype.len();
     91                if (end == -1) end = genotype.length();
    9292                else end += 2;
    9393                start -= 1;
     
    124124                } while (quotecount % 2 != 0 && end != -1);
    125125
    126                 if (end == -1) end = genotype.len();
     126                if (end == -1) end = genotype.length();
    127127                else end += 2;
    128128                start -= 1;
  • cpp/frams/genetics/fB/fB_oper.cpp

    r961 r973  
    4747                int endoffset = 0;
    4848                if (gene.indexOf("zz", 0) != -1) endoffset = 2;
    49                 if (gene.len() - endoffset < 3)
     49                if (gene.length() - endoffset < 3)
    5050                {
    5151                        return true; // genes with length < 3 are always sticks
     
    8383        }
    8484        // check if rest of characters are lowercase
    85         for (int i = genstart; i < genotype.len(); i++)
     85        for (int i = genstart; i < genotype.length(); i++)
    8686        {
    8787                if (!islower(genotype[i]))
     
    144144                fix = true;
    145145        }
    146         for (int i = pos; i < genotype.len(); i++)
     146        for (int i = pos; i < genotype.length(); i++)
    147147        {
    148148                // if character is not alphabetic - error
     
    208208        std::list<SString> res;
    209209        int i = 0;
    210         while (i < genotype.len())
     210        while (i < genotype.length())
    211211        {
    212212                // if character is not alphabetic - error
     
    252252                std::advance(it, rndid);
    253253                SString t = (*it);
    254                 if ((*it).len() == 1)
     254                if ((*it).length() == 1)
    255255                {
    256256                        if (rndUint(2) == 0)
     
    264264                                else (*it).directWrite()[0] = (*it)[0] + 1;
    265265                        }
    266                         chg = 1.0 / line.len();
     266                        chg = 1.0 / line.length();
    267267                }
    268268                else
     
    270270                        // first method needs to extract quotes
    271271                        SString def = (*it);
    272                         def = def.substr(1, def.len() - 2);
     272                        def = def.substr(1, def.length() - 2);
    273273                        Geno_fH::mutateNeuronProperties(def);
    274274                        SString res = "\"";
     
    276276                        res += "\"";
    277277                        (*it) = res;
    278                         chg = (double)def.len() / line.len();
     278                        chg = (double)def.length() / line.length();
    279279                }
    280280                line = detokenizeSequence(&tokenized);
     
    296296                        res += "\"";
    297297                        tokenized.insert(it, res);
    298                         chg = (double)classdef.len() / line.len();
     298                        chg = (double)classdef.length() / line.length();
    299299                        line = detokenizeSequence(&tokenized);
    300300                        break;
     
    304304        case FB_INSERTION:
    305305        {
    306                 chg = 1.0 / line.len();
     306                chg = 1.0 / line.length();
    307307                std::list<SString> tokenized = tokenizeSequence(line);
    308308                int rndid = rndUint(tokenized.size()); // select random insertion point
     
    317317        case FB_DELETION:
    318318        {
    319                 chg = 1.0 / line.len();
     319                chg = 1.0 / line.length();
    320320                std::list<SString> tokenized = tokenizeSequence(line);
    321321                std::list<SString>::iterator it = tokenized.begin();
     
    332332                SString gene = fB_GenoHelpers::getGene(rndgene, line, start, end);
    333333                if (gene.indexOf("zz", 0) == -1) gene += "zz";
    334                 chg = (float)gene.len() / line.len();
     334                chg = (float)gene.length() / line.length();
    335335                line = gene + line;
    336336                break;
     
    364364                //                      line.substr(cuts[1], cuts[2] - cuts[1]) + first + line.substr(cuts[3]);
    365365                line = detokenizeSequence(&res);
    366                 chg = (float)(cuts[3] - cuts[2] + cuts[1] - cuts[0]) / line.len();
     366                chg = (float)(cuts[3] - cuts[2] + cuts[1] - cuts[0]) / line.length();
    367367                break;
    368368        }
     
    412412                // add this gene to the beginning of the second parent genotype
    413413                child2 = gene + parent2;
    414                 chg2 = (float)parent2.len() / (float)child2.len();
     414                chg2 = (float)parent2.length() / (float)child2.length();
    415415                // do the same for second parent
    416416                choice = rndUint(fB_GenoHelpers::geneCount(parent2));
    417417                gene = fB_GenoHelpers::getGene(choice, parent2, start, end);
    418418                child1 = gene + parent1;
    419                 chg1 = (float)parent1.len() / (float)child1.len();
     419                chg1 = (float)parent1.length() / (float)child1.length();
    420420                break;
    421421        }
     
    523523        free(g1);
    524524        free(g2);
    525         if (child1.len() > 0 && child2.len() == 0)
     525        if (child1.length() > 0 && child2.length() == 0)
    526526        {
    527527                child1 = strdims + "\n" + child1;
     
    529529                g2 = strdup("");
    530530        }
    531         else if (child2.len() > 0 && child1.len() == 0)
     531        else if (child2.length() > 0 && child1.length() == 0)
    532532        {
    533533                child2 = strdims + "\n" + child2;
  • cpp/frams/genetics/fF/fF_genotype.h

    r841 r973  
    11// This file is a part of Framsticks SDK.  http://www.framsticks.com/
    2 // Copyright (C) 1999-2017  Maciej Komosinski and Szymon Ulatowski.
     2// Copyright (C) 1999-2020  Maciej Komosinski and Szymon Ulatowski.
    33// See LICENSE.txt for details.
    44
     
    3636                SString s = serialized;
    3737                ParamInterface::LoadOptions opts;
    38                 return ((param.load(ParamInterface::FormatSingleLine, s, &opts) == param.getPropCount()) && (opts.offset == s.len()));
     38                return ((param.load(ParamInterface::FormatSingleLine, s, &opts) == param.getPropCount()) && (opts.offset == s.length()));
    3939        }
    4040
  • cpp/frams/genetics/fH/fH_general.cpp

    r966 r973  
    214214        while (genotype.getNextToken(pos, line, '\n'))
    215215        {
    216                 if (line.len() > 0)
     216                if (line.length() > 0)
    217217                {
    218218                        int res = processLine(line, linenumber, lastpos, pos - 1);
  • cpp/frams/genetics/fL/fL_general.cpp

    r857 r973  
    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-2020  Maciej Komosinski and Szymon Ulatowski.
    33// See LICENSE.txt for details.
    44
     
    7676{
    7777        // if position exceeds length then return false
    78         if (pos >= src.len()) return false;
     78        if (pos >= src.length()) return false;
    7979        int opencount = -1;
    8080        int i = pos;
    81         for (; i < src.len(); i++)
     81        for (; i < src.length(); i++)
    8282        {
    8383                // token cannot contain branching parenthesis
     
    169169        SString temp;
    170170        temp = token.substr(tokpos);
    171         temp = temp.substr(0, temp.len() - 1);
     171        temp = temp.substr(0, temp.length() - 1);
    172172
    173173        // if word has parameters
     
    199199                                // if string is empty, then evaluate this with 0
    200200                                // if sequence could not be evaluated, then return error
    201                                 if (seq.len() > 0)
     201                                if (seq.length() > 0)
    202202                                {
    203203                                        eval = new MathEvaluation(numparams);
     
    217217                }
    218218        }
    219         else if (word->npar == 0 && temp.len() > 0)
     219        else if (word->npar == 0 && temp.length() > 0)
    220220        {
    221221                SString message = "Too many parameters for word:  ";
     
    351351{
    352352        // if word already exist, then return error
    353         if (this->name.len() == 0)
     353        if (this->name.length() == 0)
    354354        {
    355355                logMessage("fL_Word", "processDefinition", LOG_ERROR, "Axiom name is empty");
     
    456456        switch (type)
    457457        {
    458                 case fLElementType::TERM:
    459                 {
    460                         tab = fL_word_paramtab;
    461                         obj = new fL_Word();
    462                         break;
    463                 }
    464                 case fLElementType::INFO:
    465                 {
    466                         tab = fL_builder_paramtab;
    467                         obj = this;
    468                         break;
    469                 }
    470                 case fLElementType::RULE:
    471                 {
    472                         tab = fL_rule_paramtab;
    473                         obj = new fL_Rule(begin, end);
    474                         break;
    475                 }
    476                 default:
    477                         tab = NULL;
    478                         obj = NULL;
    479                         break;
     458        case fLElementType::TERM:
     459        {
     460                tab = fL_word_paramtab;
     461                obj = new fL_Word();
     462                break;
     463        }
     464        case fLElementType::INFO:
     465        {
     466                tab = fL_builder_paramtab;
     467                obj = this;
     468                break;
     469        }
     470        case fLElementType::RULE:
     471        {
     472                tab = fL_rule_paramtab;
     473                obj = new fL_Rule(begin, end);
     474                break;
     475        }
     476        default:
     477                tab = NULL;
     478                obj = NULL;
     479                break;
    480480        }
    481481        Param par(tab);
     
    573573        while (genotype.getNextToken(pos, line, '\n'))
    574574        {
    575                 if (line.len() > 0)
     575                if (line.length() > 0)
    576576                {
    577577                        // words can be defined in the beginning of genotype
     
    851851                                {
    852852                                        SString t = par.getString(q);
    853                                         if (t.len() > 0)
     853                                        if (t.length() > 0)
    854854                                        {
    855855                                                fL_Word *attrword = NULL;
     
    957957                }
    958958                double partprop = (ppar.getDoubleById(fL_part_names[i]) * alterationcount +
    959                                 currval) / (alterationcount + 1.0);
     959                        currval) / (alterationcount + 1.0);
    960960                ppar.setDoubleById(fL_part_names[i], partprop);
    961961        }
     
    10971097                                                delete newpart;
    10981098                                                logMessage("fL_Builder", "developModel", LOG_ERROR,
    1099                                                                 "Error parsing word parameter");
     1099                                                        "Error parsing word parameter");
    11001100                                                return 1;
    11011101                                        }
     
    11241124                                                {
    11251125                                                        logMessage("fL_Builder", "developModel", LOG_ERROR,
    1126                                                                         "Error parsing word parameter");
     1126                                                                "Error parsing word parameter");
    11271127                                                        delete newjoint;
    11281128                                                        return 1;
     
    11621162                        else if (word->name == "C")
    11631163                        {
    1164                                 connsbuffer.push_back({w, currstate.currneuron});
     1164                                connsbuffer.push_back({ w, currstate.currneuron });
    11651165                        }
    11661166                        else if (word->name.startsWith("rot"))
     
    11821182                                if (word->name == "rotX")
    11831183                                {
    1184                                         rotmatrix.rotate(Pt3D(rot,0,0));
     1184                                        rotmatrix.rotate(Pt3D(rot, 0, 0));
    11851185                                }
    11861186                                else if (word->name == "rotY")
    11871187                                {
    1188                                         rotmatrix.rotate(Pt3D(0,rot,0));
     1188                                        rotmatrix.rotate(Pt3D(0, rot, 0));
    11891189                                }
    11901190                                else if (word->name == "rotZ")
    11911191                                {
    1192                                         rotmatrix.rotate(Pt3D(0,0,rot));
     1192                                        rotmatrix.rotate(Pt3D(0, 0, rot));
    11931193                                }
    11941194                                currstate.direction = rotmatrix.transform(currstate.direction);
     
    12121212        {
    12131213                if (connsbuffer[i].second == NULL ||
    1214                                 (connsbuffer[i].second->getClass()->getPreferredInputs() != -1 &&
     1214                        (connsbuffer[i].second->getClass()->getPreferredInputs() != -1 &&
    12151215                                connsbuffer[i].second->getInputCount() >=
    12161216                                connsbuffer[i].second->getClass()->getPreferredInputs()))
     
    12251225                        SString attr = par.getStringById(FL_PE_CONN_ATTR);
    12261226                        fL_Word *attractor = NULL;
    1227                         if (attr.len() > 0)
     1227                        if (attr.length() > 0)
    12281228                        {
    12291229                                createWord(attr, attractor, 0, (*connsbuffer[i].first)->begin, (*connsbuffer[i].first)->end);
     
    12361236                                {
    12371237                                        logMessage("fL_Builder", "developModel", LOG_ERROR,
    1238                                                         "Error parsing word parameter");
     1238                                                "Error parsing word parameter");
    12391239                                        delete attractor;
    12401240                                        return 1;
     
    12451245                                connsbuffer[i].second->addInput(neu, weight);
    12461246                                if (using_mapping) neu->addMapping(
    1247                                                 IRange((*connsbuffer[i].first)->begin,
    1248                                                                 (*connsbuffer[i].first)->end));
     1247                                        IRange((*connsbuffer[i].first)->begin,
     1248                                                (*connsbuffer[i].first)->end));
    12491249                        }
    12501250                        else
     
    12521252                                connsbuffer[i].second->addInput(connsbuffer[i].second, weight);
    12531253                                if (using_mapping) neu->addMapping(
    1254                                                 IRange((*connsbuffer[i].first)->begin,
    1255                                                                 (*connsbuffer[i].first)->end));
     1254                                        IRange((*connsbuffer[i].first)->begin,
     1255                                                (*connsbuffer[i].first)->end));
    12561256                        }
    12571257                        delete attractor;
     
    12861286        m->open(using_checkpoints);
    12871287        bool wordsexceeded = false;
    1288         for (; t <= time; t+= timestamp)
     1288        for (; t <= time; t += timestamp)
    12891289        {
    12901290                alterTimedProperties(t); // always alter timed properties in the beginning
     
    12931293                {
    12941294                        iterate(t);
    1295                         curriter+=1.0;
     1295                        curriter += 1.0;
    12961296                }
    12971297                if (using_checkpoints)
     
    13621362{
    13631363        int count = genotype.size();
    1364         for (fL_Rule *rul: rules)
     1364        for (fL_Rule *rul : rules)
    13651365        {
    13661366                count += rul->objsucc.size();
     
    13731373{
    13741374        for (std::vector<fL_Rule *>::iterator it = rules.begin();
    1375                         it != rules.end(); it++)
     1375                it != rules.end(); it++)
    13761376        {
    13771377                std::vector<fL_Rule *>::iterator it2 = it;
     
    13931393                                {
    13941394                                        if ((*it)->condeval->getStringifiedRPN() ==
    1395                                                         (*it2)->condeval->getStringifiedRPN())
     1395                                                (*it2)->condeval->getStringifiedRPN())
    13961396                                        {
    13971397                                                todelete = true;
  • cpp/frams/genetics/fL/fL_oper.cpp

    r935 r973  
    285285        switch (method)
    286286        {
    287                 case FL_CHG_ITER:
    288                 {
    289                         if (rndUint(2) == 0)
    290                         {
    291                                 creature->time = creature->time + iterchangestep <= ExtValue::getDouble(FL_MAXITER) ?
    292                                                 creature->time + iterchangestep : creature->time - iterchangestep;
    293                         }
    294                         else
    295                         {
    296                                 creature->time = creature->time - iterchangestep >= 0 ?
    297                                                 creature->time - iterchangestep : creature->time + iterchangestep;
    298                         }
     287        case FL_CHG_ITER:
     288        {
     289                if (rndUint(2) == 0)
     290                {
     291                        creature->time = creature->time + iterchangestep <= ExtValue::getDouble(FL_MAXITER) ?
     292                                creature->time + iterchangestep : creature->time - iterchangestep;
     293                }
     294                else
     295                {
     296                        creature->time = creature->time - iterchangestep >= 0 ?
     297                                creature->time - iterchangestep : creature->time + iterchangestep;
     298                }
     299                break;
     300        }
     301        case FL_CHG_COND:
     302        {
     303                if (creature->rules.size() > 0)
     304                {
     305                        int ruleid = rndUint(creature->rules.size());
     306                        if (!creature->rules[ruleid]->condeval)
     307                        {
     308                                creature->rules[ruleid]->condeval = new MathEvaluation(creature->rules[ruleid]->objpred->npar);
     309                        }
     310                        creature->rules[ruleid]->condeval->mutateConditional();
    299311                        break;
    300312                }
    301                 case FL_CHG_COND:
    302                 {
    303                         if (creature->rules.size() > 0)
    304                         {
    305                                 int ruleid = rndUint(creature->rules.size());
    306                                 if (!creature->rules[ruleid]->condeval)
    307                                 {
    308                                         creature->rules[ruleid]->condeval = new MathEvaluation(creature->rules[ruleid]->objpred->npar);
    309                                 }
    310                                 creature->rules[ruleid]->condeval->mutateConditional();
    311                                 break;
    312                         }
    313                         // if there are no rules - create one
    314                 }
    315                 [[fallthrough]];
    316                 case FL_ADD_RULE:
    317                 {
    318                         std::unordered_map<std::string, fL_Word *>::iterator pred = creature->words.begin();
    319                         std::vector<fL_Word *> wordswithnorules;
    320                         for (; pred != creature->words.end(); pred++)
    321                         {
    322                                 if (!pred->second->builtin)
    323                                 {
    324                                         bool norules = true;
    325                                         for (fL_Rule * r : creature->rules)
    326                                         {
    327                                                 if (pred->second->name == r->objpred->name &&
    328                                                                 pred->second->npar == r->objpred->npar)
    329                                                 {
    330                                                         norules = false;
    331                                                         break;
    332                                                 }
    333                                         }
    334                                         if (norules)
    335                                         {
    336                                                 wordswithnorules.push_back(pred->second);
    337                                         }
    338                                 }
    339                         }
    340                         if (wordswithnorules.size() > 0)
    341                         {
    342                                 int predid = rndUint(wordswithnorules.size());
    343                                 fL_Rule *newrule = new fL_Rule(0,0);
    344                                 fL_Word *pred = new fL_Word();
    345                                 *pred = *wordswithnorules[predid];
    346                                 newrule->objpred = pred;
    347                                 fL_Word *initdef = randomWordDefinition(creature, roulette(addtypes, FL_ADD_COUNT - 1)); // -1 to avoid branching
    348                                 addWord(&newrule->objsucc, initdef, newrule->objsucc.begin());
    349                                 creature->rules.push_back(newrule);
    350                                 break;
    351                         }
    352                         else if (creature->rules.size() > 0)
    353                         {
    354                                 int ruleid = rndUint(creature->rules.size());
    355                                 fL_Rule *newrule = new fL_Rule(0, 0);
    356                                 fL_Word *pred = new fL_Word();
    357                                 *pred = *creature->rules[ruleid]->objpred;
    358                                 newrule->objpred = pred;
    359                                 if (creature->rules[ruleid]->condeval)
    360                                 {
    361                                         std::string formula = "";
    362                                         creature->rules[ruleid]->condeval->RPNToInfix(formula);
    363                                         if (formula.find("1.0-(") != 0)
    364                                         {
    365                                                 std::string res = "1.0-(";
    366                                                 res += formula;
    367                                                 res += ")";
    368                                                 newrule->condeval = new MathEvaluation(pred->npar);
    369                                                 newrule->condeval->convertString(res);
    370                                         }
    371                                         else
    372                                         {
    373                                                 newrule->condeval = new MathEvaluation(pred->npar);
    374                                                 newrule->condeval->mutateConditional();
    375                                         }
     313                // if there are no rules - create one
     314        }
     315        [[fallthrough]];
     316        case FL_ADD_RULE:
     317        {
     318                std::unordered_map<std::string, fL_Word *>::iterator pred = creature->words.begin();
     319                std::vector<fL_Word *> wordswithnorules;
     320                for (; pred != creature->words.end(); pred++)
     321                {
     322                        if (!pred->second->builtin)
     323                        {
     324                                bool norules = true;
     325                                for (fL_Rule * r : creature->rules)
     326                                {
     327                                        if (pred->second->name == r->objpred->name &&
     328                                                pred->second->npar == r->objpred->npar)
     329                                        {
     330                                                norules = false;
     331                                                break;
     332                                        }
     333                                }
     334                                if (norules)
     335                                {
     336                                        wordswithnorules.push_back(pred->second);
     337                                }
     338                        }
     339                }
     340                if (wordswithnorules.size() > 0)
     341                {
     342                        int predid = rndUint(wordswithnorules.size());
     343                        fL_Rule *newrule = new fL_Rule(0, 0);
     344                        fL_Word *pred = new fL_Word();
     345                        *pred = *wordswithnorules[predid];
     346                        newrule->objpred = pred;
     347                        fL_Word *initdef = randomWordDefinition(creature, roulette(addtypes, FL_ADD_COUNT - 1)); // -1 to avoid branching
     348                        addWord(&newrule->objsucc, initdef, newrule->objsucc.begin());
     349                        creature->rules.push_back(newrule);
     350                        break;
     351                }
     352                else if (creature->rules.size() > 0)
     353                {
     354                        int ruleid = rndUint(creature->rules.size());
     355                        fL_Rule *newrule = new fL_Rule(0, 0);
     356                        fL_Word *pred = new fL_Word();
     357                        *pred = *creature->rules[ruleid]->objpred;
     358                        newrule->objpred = pred;
     359                        if (creature->rules[ruleid]->condeval)
     360                        {
     361                                std::string formula = "";
     362                                creature->rules[ruleid]->condeval->RPNToInfix(formula);
     363                                if (formula.find("1.0-(") != 0)
     364                                {
     365                                        std::string res = "1.0-(";
     366                                        res += formula;
     367                                        res += ")";
     368                                        newrule->condeval = new MathEvaluation(pred->npar);
     369                                        newrule->condeval->convertString(res);
    376370                                }
    377371                                else
     
    380374                                        newrule->condeval->mutateConditional();
    381375                                }
    382                                 fL_Word *worddef = randomWordDefinition(creature, roulette(addtypes, FL_ADD_COUNT - 1));
    383                                 addWord(&newrule->objsucc, worddef, newrule->objsucc.begin());
    384                                 creature->rules.push_back(newrule);
    385                                 break;
    386                         }
    387                         // if there are no words, from which rules can be formed, then add one
    388                 }
    389                 [[fallthrough]];
    390                 case FL_ADD_WDEF:
    391                 {
    392                         if (creature->countDefinedWords() <= maxdefinedwords)
    393                         {
    394                                 int npar = rndUint(ExtValue::getInt(FL_MAXPARAMS, false));
    395                                 for (int i = 0; i < maxdefinedwords; i++)
    396                                 {
    397                                         std::string name = "w";
    398                                         name += std::to_string(i);
    399                                         if (creature->words.find(name) == creature->words.end())
    400                                         {
    401                                                 fL_Word *word = new fL_Word(false, 0, 0);
    402                                                 word->npar = npar;
    403                                                 word->name = name.c_str();
    404                                                 word->processDefinition(creature);
    405                                                 break;
    406                                         }
    407                                 }
    408                                 break;
    409                         }
    410                         //no break at the end of case - if there is too many words, then
    411                         // deletion should be performed
    412                 }
    413                 [[fallthrough]];
    414                 case FL_DEL_WORD:
    415                 {
     376                        }
     377                        else
     378                        {
     379                                newrule->condeval = new MathEvaluation(pred->npar);
     380                                newrule->condeval->mutateConditional();
     381                        }
     382                        fL_Word *worddef = randomWordDefinition(creature, roulette(addtypes, FL_ADD_COUNT - 1));
     383                        addWord(&newrule->objsucc, worddef, newrule->objsucc.begin());
     384                        creature->rules.push_back(newrule);
     385                        break;
     386                }
     387                // if there are no words, from which rules can be formed, then add one
     388        }
     389        [[fallthrough]];
     390        case FL_ADD_WDEF:
     391        {
     392                if (creature->countDefinedWords() <= maxdefinedwords)
     393                {
     394                        int npar = rndUint(ExtValue::getInt(FL_MAXPARAMS, false));
     395                        for (int i = 0; i < maxdefinedwords; i++)
     396                        {
     397                                std::string name = "w";
     398                                name += std::to_string(i);
     399                                if (creature->words.find(name) == creature->words.end())
     400                                {
     401                                        fL_Word *word = new fL_Word(false, 0, 0);
     402                                        word->npar = npar;
     403                                        word->name = name.c_str();
     404                                        word->processDefinition(creature);
     405                                        break;
     406                                }
     407                        }
     408                        break;
     409                }
     410                //no break at the end of case - if there is too many words, then
     411                // deletion should be performed
     412        }
     413        [[fallthrough]];
     414        case FL_DEL_WORD:
     415        {
     416                int numpars = 0;
     417                int ruleid = 0;
     418                std::list<fL_Word *> *list = selectRandomSequence(creature, numpars, ruleid);
     419                if (ruleid == -1 && creature->countSticksInSequence(list) == 1)
     420                {
     421                        if (list->size() > 1)
     422                        {
     423                                int rndid = rndUint(list->size() - 1);
     424                                int j = 0;
     425                                std::list<fL_Word *>::iterator it = list->begin();
     426                                if ((*it)->name == "S")
     427                                {
     428                                        it++;
     429                                }
     430                                while (it != list->end() && j < rndid && ((*it)->name == "S"))
     431                                {
     432                                        if ((*it)->name != "S")
     433                                        {
     434                                                j++;
     435                                        }
     436                                        it++;
     437                                }
     438                                if (it != list->end())
     439                                {
     440                                        if ((*it)->type == fLElementType::BRANCH)
     441                                        {
     442                                                deleteBranch(list, it);
     443                                        }
     444                                        else
     445                                        {
     446                                                delete (*it);
     447                                                list->erase(it);
     448                                        }
     449                                        break;
     450                                }
     451                                // else add word
     452                        }
     453                        // else add word
     454                }
     455                else
     456                {
     457                        int rndid = rndUint(list->size());
     458                        std::list<fL_Word *>::iterator it = list->begin();
     459                        std::advance(it, rndid);
     460                        if ((*it)->type == fLElementType::BRANCH)
     461                        {
     462                                deleteBranch(list, it);
     463                        }
     464                        else
     465                        {
     466                                delete (*it);
     467                                list->erase(it);
     468                        }
     469                        if (ruleid > -1 && creature->rules[ruleid]->objsucc.size() == 0)
     470                        {
     471                                delete creature->rules[ruleid];
     472                                creature->rules.erase(creature->rules.begin() + ruleid);
     473                        }
     474                        break;
     475                }
     476                // if no words available, then add word
     477        }
     478        [[fallthrough]];
     479        case FL_ADD_WORD:
     480        {
     481                int numpars = 0;
     482                int tmp = 0;
     483                std::list<fL_Word *> *list = selectRandomSequence(creature, numpars, tmp);
     484                int rndid = rndUint(list->size());
     485                std::list<fL_Word *>::iterator it = list->begin();
     486                std::advance(it, rndid);
     487                int meth = roulette(addtypes, FL_ADD_COUNT);
     488                if (tmp == -1)
     489                { // if sequence is axiom and it does not have non-builtin words
     490                        bool hasdefined = false;
     491                        for (std::list<fL_Word *>::iterator elem = list->begin(); elem != list->end(); elem++)
     492                        {
     493                                if (!(*elem)->builtin)
     494                                {
     495                                        hasdefined = true;
     496                                        break;
     497                                }
     498                        }
     499                        if (!hasdefined)
     500                        {
     501                                meth = FL_ADD_OTHER;
     502                        }
     503
     504                }
     505                if (meth != FL_ADD_BRANCH)
     506                {
     507                        fL_Word *worddef = randomWordDefinition(creature, meth);
     508                        addWord(list, worddef, it);
     509                }
     510                else
     511                {
     512                        fL_Branch *start = new fL_Branch(fL_Branch::BranchType::OPEN, 0, 0);
     513                        list->insert(it, start);
     514                        int rottype = rndUint(2);
     515                        switch (rottype)
     516                        {
     517                        case 0:
     518                                addWord(list, creature->words["rotY"], it);
     519                        case 1:
     520                                addWord(list, creature->words["rotZ"], it);
     521                        }
     522                        addWord(list, creature->words["S"], it);
     523                        fL_Branch *end = new fL_Branch(fL_Branch::BranchType::CLOSE, 0, 0);
     524                        list->insert(it, end);
     525                }
     526                break;
     527        }
     528        case FL_CHG_WORD:
     529        {
     530                int numpars = 0;
     531                int tmp = 0;
     532                std::list<fL_Word *> *list = selectRandomSequence(creature, numpars, tmp);
     533                int rndid = rndUint(list->size());
     534                std::list<fL_Word *>::iterator selectedword = list->begin();
     535                std::advance(selectedword, rndid);
     536                if ((*selectedword)->type == fLElementType::BRANCH)
     537                {
     538                        break;
     539                }
     540                int chgtype = roulette(chgoperations, FL_CHG_COUNT);
     541                if (creature->countSticksInSequence(list) == 1 && tmp == -1) // if sequence is axiom
     542                {
     543                        fL_Word *worddef = randomWordDefinition(creature, roulette(addtypes, FL_ADD_COUNT - 1));
     544
    416545                        int numpars = 0;
    417                         int ruleid = 0;
    418                         std::list<fL_Word *> *list = selectRandomSequence(creature, numpars, ruleid);
    419                         if (ruleid == -1 && creature->countSticksInSequence(list) == 1)
    420                         {
    421                                 if (list->size() > 1)
    422                                 {
    423                                         int rndid = rndUint(list->size() - 1);
    424                                         int j = 0;
    425                                         std::list<fL_Word *>::iterator it = list->begin();
    426                                         if ((*it)->name == "S")
    427                                         {
    428                                                 it++;
    429                                         }
    430                                         while (it != list->end() && j < rndid && ((*it)->name == "S"))
    431                                         {
    432                                                 if ((*it)->name != "S")
    433                                                 {
    434                                                         j++;
    435                                                 }
    436                                                 it++;
    437                                         }
    438                                         if (it != list->end())
    439                                         {
    440                                                 if ((*it)->type == fLElementType::BRANCH)
    441                                                 {
    442                                                         deleteBranch(list, it);
    443                                                 }
    444                                                 else
    445                                                 {
    446                                                         delete (*it);
    447                                                         list->erase(it);
    448                                                 }
    449                                                 break;
    450                                         }
    451                                         // else add word
    452                                 }
    453                                 // else add word
    454                         }
    455                         else
    456                         {
    457                                 int rndid = rndUint(list->size());
    458                                 std::list<fL_Word *>::iterator it = list->begin();
    459                                 std::advance(it, rndid);
    460                                 if ((*it)->type == fLElementType::BRANCH)
    461                                 {
    462                                         deleteBranch(list, it);
    463                                 }
    464                                 else
    465                                 {
    466                                         delete (*it);
    467                                         list->erase(it);
    468                                 }
    469                                 if (ruleid > -1 && creature->rules[ruleid]->objsucc.size() == 0)
    470                                 {
    471                                         delete creature->rules[ruleid];
    472                                         creature->rules.erase(creature->rules.begin() + ruleid);
    473                                 }
    474                                 break;
    475                         }
    476                         // if no words available, then add word
    477                 }
    478                 [[fallthrough]];
    479                 case FL_ADD_WORD:
    480                 {
    481                         int numpars = 0;
    482                         int tmp = 0;
    483546                        std::list<fL_Word *> *list = selectRandomSequence(creature, numpars, tmp);
    484547                        int rndid = rndUint(list->size());
    485548                        std::list<fL_Word *>::iterator it = list->begin();
    486549                        std::advance(it, rndid);
    487                         int meth = roulette(addtypes, FL_ADD_COUNT);
    488                         if (tmp == -1)
    489                         { // if sequence is axiom and it does not have non-builtin words
    490                                 bool hasdefined = false;
    491                                 for (std::list<fL_Word *>::iterator elem = list->begin(); elem != list->end(); elem++)
    492                                 {
    493                                         if (!(*elem)->builtin)
    494                                         {
    495                                                 hasdefined = true;
    496                                                 break;
    497                                         }
    498                                 }
    499                                 if (!hasdefined)
    500                                 {
    501                                         meth = FL_ADD_OTHER;
    502                                 }
    503 
    504                         }
    505                         if (meth != FL_ADD_BRANCH)
    506                         {
    507                                 fL_Word *worddef = randomWordDefinition(creature, meth);
    508                                 addWord(list, worddef, it);
     550
     551                        addWord(list, worddef, it);
     552
     553                        break;
     554                }
     555                else if (chgtype == FL_CHG_WORD_NAME)
     556                {
     557                        if ((*selectedword)->builtin)
     558                        {
     559                                delete (*selectedword);
     560                                selectedword = list->erase(selectedword);
     561                                fL_Word *worddef = randomWordDefinition(creature, roulette(addtypes, FL_ADD_COUNT - 1));
     562                                addWord(list, worddef, selectedword);
    509563                        }
    510564                        else
    511565                        {
    512                                 fL_Branch *start = new fL_Branch(fL_Branch::BranchType::OPEN, 0, 0);
    513                                 list->insert(it, start);
    514                                 int rottype = rndUint(2);
    515                                 switch (rottype)
    516                                 {
    517                                 case 0:
    518                                         addWord(list, creature->words["rotY"], it);
    519                                 case 1:
    520                                         addWord(list, creature->words["rotZ"], it);
    521                                 }
    522                                 addWord(list, creature->words["S"], it);
    523                                 fL_Branch *end = new fL_Branch(fL_Branch::BranchType::CLOSE, 0, 0);
    524                                 list->insert(it, end);
    525                         }
    526                         break;
    527                 }
    528                 case FL_CHG_WORD:
    529                 {
    530                         int numpars = 0;
    531                         int tmp = 0;
    532                         std::list<fL_Word *> *list = selectRandomSequence(creature, numpars, tmp);
    533                         int rndid = rndUint(list->size());
    534                         std::list<fL_Word *>::iterator selectedword = list->begin();
    535                         std::advance(selectedword, rndid);
    536                         if ((*selectedword)->type == fLElementType::BRANCH)
    537                         {
    538                                 break;
    539                         }
    540                         int chgtype = roulette(chgoperations, FL_CHG_COUNT);
    541                         if (creature->countSticksInSequence(list) == 1 && tmp == -1) // if sequence is axiom
    542                         {
    543                                 fL_Word *worddef = randomWordDefinition(creature, roulette(addtypes, FL_ADD_COUNT - 1));
    544 
    545                                 int numpars = 0;
    546                                 std::list<fL_Word *> *list = selectRandomSequence(creature, numpars, tmp);
    547                                 int rndid = rndUint(list->size());
    548                                 std::list<fL_Word *>::iterator it = list->begin();
    549                                 std::advance(it, rndid);
    550 
    551                                 addWord(list, worddef, it);
    552 
    553                                 break;
    554                         }
    555                         else if (chgtype == FL_CHG_WORD_NAME)
    556                         {
    557                                 if ((*selectedword)->builtin)
     566                                std::vector<fL_Word *> available;
     567                                for (std::unordered_map<std::string, fL_Word *>::iterator wit = creature->words.begin();
     568                                        wit != creature->words.end(); wit++)
     569                                {
     570                                        if ((*selectedword)->npar == wit->second->npar &&
     571                                                (*selectedword)->name != wit->second->name &&
     572                                                !wit->second->builtin)
     573                                        {
     574                                                available.push_back(wit->second);
     575                                        }
     576                                }
     577                                if (available.size() > 0)
     578                                {
     579                                        int newnameid = rndUint(available.size());
     580                                        (*selectedword)->name = available[newnameid]->name;
     581                                }
     582                                else
    558583                                {
    559584                                        delete (*selectedword);
     
    562587                                        addWord(list, worddef, selectedword);
    563588                                }
    564                                 else
    565                                 {
    566                                         std::vector<fL_Word *> available;
    567                                         for (std::unordered_map<std::string, fL_Word *>::iterator wit = creature->words.begin();
    568                                                         wit != creature->words.end(); wit++)
    569                                         {
    570                                                 if ((*selectedword)->npar == wit->second->npar &&
    571                                                                 (*selectedword)->name != wit->second->name &&
    572                                                                 !wit->second->builtin)
     589                        }
     590                }
     591                else
     592                {
     593                        if ((*selectedword)->npar > 0)
     594                        {
     595                                int randeval = rndUint((*selectedword)->npar);
     596                                Param par((*selectedword)->tab, (*selectedword)->data);
     597                                if ((*selectedword)->builtin && (*selectedword)->name == "N"
     598                                        && strcmp(par.id(randeval), FL_PE_NEURO_DET) == 0)
     599                                {
     600                                        SString res = par.getStringById(FL_PE_NEURO_DET);
     601                                        Geno_fH::mutateNeuronProperties(res);
     602                                        par.setStringById(FL_PE_NEURO_DET, res);
     603                                }
     604                                else if ((*selectedword)->builtin &&
     605                                        (*selectedword)->name == "C" &&
     606                                        strcmp(par.id(randeval), FL_PE_CONN_ATTR) == 0)
     607                                {
     608                                        SString strattractor = par.getStringById(FL_PE_CONN_ATTR);
     609                                        if (strattractor.length() > 0)
     610                                        {
     611                                                fL_Word *w = NULL;
     612                                                creature->createWord(strattractor, w, numpars, 0, 0);
     613                                                // mutate attractor parameter
     614                                                if (w->npar > 0)
    573615                                                {
    574                                                         available.push_back(wit->second);
     616                                                        int rndattr = rndUint(w->npar);
     617                                                        if (!w->parevals[rndattr])
     618                                                        {
     619                                                                w->parevals[rndattr] = new MathEvaluation(numpars);
     620                                                        }
     621                                                        w->parevals[rndattr]->mutate(false, false);
    575622                                                }
    576                                         }
    577                                         if (available.size() > 0)
    578                                         {
    579                                                 int newnameid = rndUint(available.size());
    580                                                 (*selectedword)->name = available[newnameid]->name;
     623                                                strattractor = w->stringify(true);
     624                                                par.setStringById(FL_PE_CONN_ATTR, strattractor);
     625                                                delete w;
    581626                                        }
    582627                                        else
    583628                                        {
    584                                                 delete (*selectedword);
    585                                                 selectedword = list->erase(selectedword);
    586                                                 fL_Word *worddef = randomWordDefinition(creature, roulette(addtypes, FL_ADD_COUNT - 1));
    587                                                 addWord(list, worddef, selectedword);
    588                                         }
    589                                 }
    590                         }
    591                         else
    592                         {
    593                                 if ((*selectedword)->npar > 0)
    594                                 {
    595                                         int randeval = rndUint((*selectedword)->npar);
    596                                         Param par((*selectedword)->tab, (*selectedword)->data);
    597                                         if ((*selectedword)->builtin && (*selectedword)->name == "N"
    598                                                         && strcmp(par.id(randeval), FL_PE_NEURO_DET) == 0)
    599                                         {
    600                                                 SString res = par.getStringById(FL_PE_NEURO_DET);
    601                                                 Geno_fH::mutateNeuronProperties(res);
    602                                                 par.setStringById(FL_PE_NEURO_DET, res);
    603                                         }
    604                                         else if ((*selectedword)->builtin &&
    605                                                         (*selectedword)->name == "C" &&
    606                                                         strcmp(par.id(randeval), FL_PE_CONN_ATTR) == 0)
    607                                         {
    608                                                 SString strattractor = par.getStringById(FL_PE_CONN_ATTR);
    609                                                 if (strattractor.len() > 0)
     629                                                if (creature->builtincount < (int)creature->words.size())
    610630                                                {
    611                                                         fL_Word *w = NULL;
    612                                                         creature->createWord(strattractor, w, numpars, 0, 0);
    613                                                         // mutate attractor parameter
     631                                                        fL_Word *wdef = randomWordDefinition(creature, FL_ADD_OTHER);
     632                                                        fL_Word *w = new fL_Word();
     633                                                        *w = *wdef;
     634                                                        w->data = ParamObject::makeObject(w->tab);
     635                                                        Param apar(w->tab);
     636                                                        apar.select(w->data);
     637                                                        apar.setDefault();
    614638                                                        if (w->npar > 0)
    615639                                                        {
    616640                                                                int rndattr = rndUint(w->npar);
    617                                                                 if (!w->parevals[rndattr])
     641                                                                for (int i = 0; i < w->npar; i++)
    618642                                                                {
    619                                                                         w->parevals[rndattr] = new MathEvaluation(numpars);
     643                                                                        if (i == rndattr)
     644                                                                        {
     645                                                                                MathEvaluation *ev = new MathEvaluation(numpars);
     646                                                                                ev->mutate(false, false);
     647                                                                                w->parevals.push_back(ev);
     648                                                                        }
     649                                                                        else
     650                                                                        {
     651                                                                                w->parevals.push_back(NULL);
     652                                                                        }
    620653                                                                }
    621                                                                 w->parevals[rndattr]->mutate(false, false);
     654
    622655                                                        }
    623                                                         strattractor = w->stringify(true);
     656                                                        strattractor = w->stringify(false);
    624657                                                        par.setStringById(FL_PE_CONN_ATTR, strattractor);
    625658                                                        delete w;
    626659                                                }
    627                                                 else
    628                                                 {
    629                                                         if (creature->builtincount < (int)creature->words.size())
    630                                                         {
    631                                                                 fL_Word *wdef = randomWordDefinition(creature, FL_ADD_OTHER);
    632                                                                 fL_Word *w = new fL_Word();
    633                                                                 *w = *wdef;
    634                                                                 w->data = ParamObject::makeObject(w->tab);
    635                                                                 Param apar(w->tab);
    636                                                                 apar.select(w->data);
    637                                                                 apar.setDefault();
    638                                                                 if (w->npar > 0)
    639                                                                 {
    640                                                                         int rndattr = rndUint(w->npar);
    641                                                                         for (int i = 0; i < w->npar; i++)
    642                                                                         {
    643                                                                                 if (i == rndattr)
    644                                                                                 {
    645                                                                                         MathEvaluation *ev = new MathEvaluation(numpars);
    646                                                                                         ev->mutate(false, false);
    647                                                                                         w->parevals.push_back(ev);
    648                                                                                 }
    649                                                                                 else
    650                                                                                 {
    651                                                                                         w->parevals.push_back(NULL);
    652                                                                                 }
    653                                                                         }
    654 
    655                                                                 }
    656                                                                 strattractor = w->stringify(false);
    657                                                                 par.setStringById(FL_PE_CONN_ATTR, strattractor);
    658                                                                 delete w;
    659                                                         }
    660                                                 }
    661                                         }
    662                                         else
    663                                         {
    664                                                 if (!(*selectedword)->parevals[randeval])
    665                                                 {
    666                                                         (*selectedword)->parevals[randeval] = new MathEvaluation(numpars);
    667                                                 }
    668                                                 (*selectedword)->parevals[randeval]->mutate(false, iterchangestep != 1.0);
    669                                         }
    670                                 }
    671                         }
    672                         break;
    673                 }
     660                                        }
     661                                }
     662                                else
     663                                {
     664                                        if (!(*selectedword)->parevals[randeval])
     665                                        {
     666                                                (*selectedword)->parevals[randeval] = new MathEvaluation(numpars);
     667                                        }
     668                                        (*selectedword)->parevals[randeval]->mutate(false, iterchangestep != 1.0);
     669                                }
     670                        }
     671                }
     672                break;
     673        }
    674674        }
    675675
     
    702702        }
    703703        else if (to->words.find(fromword->name.c_str()) != to->words.end() &&
    704                         to->words[fromword->name.c_str()]->npar == fromword->npar) // if there is already same word with same number of parameters
     704                to->words[fromword->name.c_str()]->npar == fromword->npar) // if there is already same word with same number of parameters
    705705        {
    706706                fL_Word *newword = new fL_Word();
     
    710710        }
    711711        for (std::unordered_map<std::string, fL_Word *>::iterator it = to->words.begin();
    712                         it != to->words.end(); it++)
     712                it != to->words.end(); it++)
    713713        { // find word with same number of parameters
    714714                if (fromword->npar == it->second->npar && map.find(fromword->name.c_str()) == map.end() && !it->second->builtin)
     
    774774                                        std::string form;
    775775                                        if (w->builtin && w->name == "N"
    776                                                         && strcmp(par.id(i), FL_PE_NEURO_DET) == 0)
     776                                                && strcmp(par.id(i), FL_PE_NEURO_DET) == 0)
    777777                                        {
    778778                                                SString res = origpar.getStringById(FL_PE_NEURO_DET);
     
    781781                                        }
    782782                                        else if (w->builtin && w->name == "C"
    783                                                         && strcmp(par.id(i), FL_PE_CONN_ATTR) == 0)
     783                                                && strcmp(par.id(i), FL_PE_CONN_ATTR) == 0)
    784784                                        {
    785785                                                SString strattractor = origpar.getStringById(FL_PE_CONN_ATTR);
    786                                                 if (strattractor.len() > 0)
     786                                                if (strattractor.length() > 0)
    787787                                                {
    788788                                                        fL_Word *tmp = NULL;
  • cpp/frams/genetics/fS/fS_general.cpp

    r969 r973  
    9999                if (separatorIndex == -1)
    100100                {
    101                         keyLength = keyValue.len();
     101                        keyLength = keyValue.length();
    102102                        value = DEFAULT_NEURO_CONNECTION_WEIGHT;
    103103                } else
    104104                {
    105105                        keyLength = separatorIndex;
    106                         size_t valueLength = keyValue.len() - (separatorIndex);
     106                        size_t valueLength = keyValue.length() - (separatorIndex);
    107107                        value = fS_stod(buffer + separatorIndex + 1, start, &valueLength);
    108108                }
     
    859859{
    860860        SString geno;
    861         geno.memoryHint(100);     // Provide a small buffer from the start to improve performance
     861        geno.reserve(100);     // Provide a small buffer from the start to improve performance
    862862        startNode->getGeno(geno);
    863863        return geno;
Note: See TracChangeset for help on using the changeset viewer.