Changeset 935 for cpp/frams/genetics/fH


Ignore:
Timestamp:
05/29/20 15:20:29 (4 years ago)
Author:
Maciej Komosinski
Message:

Utility functions that provide a set of all neuron classes fulfilling given criteria now also filter neuron classes by the desired Model shape type (BALL_AND_STICK or SOLIDS)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cpp/frams/genetics/fH/fH_oper.cpp

    r896 r935  
    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
     
    255255                fH_Handle *handle = NULL;
    256256                method = FH_OPCOUNT + roulette(addoperations, FH_ADD_OPCOUNT);
    257                 if (getActiveNeuroClassCount() == 0) method = FH_OPCOUNT + FH_ADD_STICK;
     257                if (getActiveNeuroClassCount(Model::SHAPE_BALL_AND_STICK) == 0) method = FH_OPCOUNT + FH_ADD_STICK;
    258258                switch (method - FH_OPCOUNT)
    259259                {
     
    466466        if (userandomclass)
    467467        {
    468                 nc = getRandomNeuroClass();
     468                nc = getRandomNeuroClass(Model::SHAPE_BALL_AND_STICK);
    469469                // checking of neuron class availability should be checked before
    470470        }
     
    503503uint32_t Geno_fH::style(const char *g, int pos)
    504504{
    505    char ch=g[pos];
    506    uint32_t style=GENSTYLE_CS(0,GENSTYLE_NONE); //default, should be changed below
    507 
    508    int pp=pos; //detect comment line
    509    while (pp>1 && g[pp-1]!='\n') pp--;
    510    if (g[pp]=='#') return GENSTYLE_RGBS(0,220,0,GENSTYLE_NONE); //comment line
    511 
    512    if (pos==0 || g[pos-1]=='\n' || ch==':' || ch==',') style=GENSTYLE_CS(0,GENSTYLE_BOLD); else
    513      if (ch=='\"') style=GENSTYLE_RGBS(150,0,0,GENSTYLE_BOLD); else
    514      {
    515       int cudz=0,neuclass=1; //ile cudz. do poczatku linii; czy w nazwie neuroklasy?
    516       while (pos>0)
    517       {
    518          pos--;
    519          if (g[pos]=='\"') cudz++;
    520          if (cudz==0 && (g[pos]==':' || g[pos]==',')) neuclass=0;
    521          if (g[pos]=='\n') break;
    522       }
    523       if (cudz%2)
    524       {
    525          if (neuclass) style=GENSTYLE_RGBS(150,0,150,GENSTYLE_BOLD); else //neuroclass
    526            if (isalpha(ch)) style=GENSTYLE_RGBS(255,140,0,GENSTYLE_BOLD); else //property
    527              style=GENSTYLE_RGBS(200,0,0,GENSTYLE_NONE);
    528       } else
    529         if (isalpha(ch)) style=GENSTYLE_RGBS(0,0,200,GENSTYLE_BOLD);
    530      }
    531    return style;
    532 }
     505        char ch = g[pos];
     506        uint32_t style = GENSTYLE_CS(0, GENSTYLE_NONE); //default, should be changed below
     507
     508        int pp = pos; //detect comment line
     509        while (pp > 1 && g[pp - 1] != '\n') pp--;
     510        if (g[pp] == '#') return GENSTYLE_RGBS(0, 220, 0, GENSTYLE_NONE); //comment line
     511
     512        if (pos == 0 || g[pos - 1] == '\n' || ch == ':' || ch == ',') style = GENSTYLE_CS(0, GENSTYLE_BOLD); else
     513                if (ch == '\"') style = GENSTYLE_RGBS(150, 0, 0, GENSTYLE_BOLD); else
     514                {
     515                        int cudz = 0, neuclass = 1; //ile cudz. do poczatku linii; czy w nazwie neuroklasy?
     516                        while (pos > 0)
     517                        {
     518                                pos--;
     519                                if (g[pos] == '\"') cudz++;
     520                                if (cudz == 0 && (g[pos] == ':' || g[pos] == ',')) neuclass = 0;
     521                                if (g[pos] == '\n') break;
     522                        }
     523                        if (cudz % 2)
     524                        {
     525                                if (neuclass) style = GENSTYLE_RGBS(150, 0, 150, GENSTYLE_BOLD); else //neuroclass
     526                                        if (isalpha(ch)) style = GENSTYLE_RGBS(255, 140, 0, GENSTYLE_BOLD); else //property
     527                                                style = GENSTYLE_RGBS(200, 0, 0, GENSTYLE_NONE);
     528                        }
     529                        else
     530                                if (isalpha(ch)) style = GENSTYLE_RGBS(0, 0, 200, GENSTYLE_BOLD);
     531                }
     532        return style;
     533}
Note: See TracChangeset for help on using the changeset viewer.