Changeset 773 for cpp


Ignore:
Timestamp:
04/05/18 23:14:35 (6 years ago)
Author:
Maciej Komosinski
Message:

Improved styling implementation, fixes issue number 18 [refs #62]

File:
1 edited

Legend:

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

    r772 r773  
    186186                                                        if (g->ordNode(i) == n3)
    187187                                                        {
    188                                                                 neuronid = neulist.size()-1;
     188                                                                neuronid = neulist.size() - 1;
    189189                                                        }
    190190                                                }
     
    236236                                        if (gcur == par)
    237237                                        {
    238                                                 neuronid = neulist.size()-1;
     238                                                neuronid = neulist.size() - 1;
    239239                                        }
    240240                                }
     
    395395                                if (gcur == n1)
    396396                                {
    397                                         neuronid = neulist.size()-1;
     397                                        neuronid = neulist.size() - 1;
    398398                                }
    399399                        }
     
    434434        {
    435435                // '*', 'G', 'T', or 'S', 1/4 chance each
    436                 nc =  GenoOperators::getRandomNeuroClassWithOutputAndNoInputs();
     436                nc = GenoOperators::getRandomNeuroClassWithOutputAndNoInputs();
    437437        }
    438438        if (nc != NULL)
     
    451451        }
    452452        // weight
    453         nn->f1 = GenoOperators::mutateNeuProperty(nn->f1,NULL,-1);
     453        nn->f1 = GenoOperators::mutateNeuProperty(nn->f1, NULL, -1);
    454454        //nn->f1 = 10.0f * (rnd01 - 0.5f);
    455455}
     
    485485                        nn->l1 = neuid - id;
    486486                }
    487                         //nn->l1 += (int)(2.0f * (rnd01 - 0.5f));
     487                //nn->l1 += (int)(2.0f * (rnd01 - 0.5f));
    488488                break;
    489489        case 2: // change weight
    490                 nn->f1 = GenoOperators::mutateNeuProperty(nn->f1,NULL,-1);
     490                nn->f1 = GenoOperators::mutateNeuProperty(nn->f1, NULL, -1);
    491491                //nn->f1 += 1.0f * (rnd01 - 0.5f);
    492492                break;
     
    717717{
    718718        char ch = g[pos];
     719
    719720        // style categories
    720721#define STYL4CAT_MODIFIC F14_MODIFIERS ","
    721 #define STYL4CAT_NEUMOD "[]|@*GTS:+-/!="
     722#define STYL4CAT_NEUMOD "[]:+-/!="
     723#define STYL4CAT_NEUSPECIAL "|@*"
    722724#define STYL4CAT_DIGIT "0123456789."
    723725#define STYL4CAT_REST "XN<># "
    724726
    725         if (!isalpha(ch) && !isdigit(ch) &&  !strchr("<>-+[]:,.@|#*/=!\t",ch)) {
     727        if (!isalpha(ch) && !strchr(STYL4CAT_MODIFIC STYL4CAT_NEUMOD STYL4CAT_NEUSPECIAL STYL4CAT_DIGIT STYL4CAT_REST "\t", ch))
     728        {
    726729                return GENSTYLE_CS(0, GENSTYLE_INVALID);
    727730        }
    728731        uint32_t style = GENSTYLE_CS(0, GENSTYLE_STRIKEOUT); //default, should be changed below
    729         if (strchr("X ", ch))              style = GENSTYLE_CS(0, GENSTYLE_NONE);
    730         else if (strchr("N", ch))               style = GENSTYLE_RGBS(0, 200, 0, GENSTYLE_NONE);
    731         else if (strchr("<", ch))               style = GENSTYLE_RGBS(0, 0, 200, GENSTYLE_BOLD);
    732         else if (strchr(">", ch))               style = GENSTYLE_RGBS(0, 0, 100, GENSTYLE_NONE);
     732        if (strchr("X ", ch))                    style = GENSTYLE_CS(0, GENSTYLE_NONE);
     733        else if (strchr("N", ch))                style = GENSTYLE_RGBS(0, 200, 0, GENSTYLE_NONE);
     734        else if (strchr("<", ch))                style = GENSTYLE_RGBS(0, 0, 200, GENSTYLE_BOLD);
     735        else if (strchr(">", ch))                style = GENSTYLE_RGBS(0, 0, 100, GENSTYLE_NONE);
    733736        else if (strchr(STYL4CAT_DIGIT, ch))     style = GENSTYLE_RGBS(100, 100, 100, GENSTYLE_NONE);
    734737        else if (strchr(STYL4CAT_MODIFIC, ch))   style = GENSTYLE_RGBS(100, 100, 100, GENSTYLE_NONE);
    735738        else if (strchr(STYL4CAT_NEUMOD, ch))    style = GENSTYLE_RGBS(0, 150, 0, GENSTYLE_NONE);
    736         else if (isalpha(ch)) {
    737                 int p = pos;
    738                 while (p > 0) {
    739                         p--;
    740                         if (!isalpha(g[p])) {
    741                                 if (isupper(g[p+1]) && (g[p] == ':' || g[p] == '[')) { // name of neuron class
    742                                         style = GENSTYLE_RGBS(150,0,150,GENSTYLE_ITALIC);
    743                                 }
    744                                 else { // property
    745                                         style = GENSTYLE_RGBS(255,140,0,GENSTYLE_BOLD);
    746                                 }
     739        if (isalpha(ch) || strchr(STYL4CAT_NEUSPECIAL, ch))
     740        {
     741                while (pos > 0)
     742                {
     743                        pos--;
     744                        if (!(isalpha(g[pos]) || strchr(STYL4CAT_NEUSPECIAL, ch)))
     745                        {
     746                                if (isupper(g[pos + 1]) && (g[pos] == ':' || g[pos] == '[')) // name of neuron class
     747                                        style = GENSTYLE_RGBS(150, 0, 150, GENSTYLE_ITALIC);
     748                                else // property
     749                                        style = GENSTYLE_RGBS(100, 100, 100, GENSTYLE_NONE);
    747750                        }
    748751                }
Note: See TracChangeset for help on using the changeset viewer.