Ignore:
Timestamp:
06/25/20 16:31:25 (4 years ago)
Author:
Maciej Komosinski
Message:

Replace magic "100" with GenoOperators::NEUROCLASS_PROP_OFFSET

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cpp/frams/genetics/genooperators.cpp

    r955 r957  
    7676}
    7777
    78 int GenoOperators::selectRandomNeuProperty(Neuro *n)
     78int GenoOperators::selectRandomNeuronProperty(Neuro *n)
    7979{
    8080        int neuext = n->extraProperties().getPropCount(),
     
    8282        if (neuext + neucls == 0) return -1; //no properties in this neuron
    8383        int index = rndUint(neuext + neucls);
    84         if (index >= neuext) index = index - neuext + 100;
     84        if (index >= neuext) index = index - neuext + NEUROCLASS_PROP_OFFSET;
    8585        return index;
    8686}
    8787
    88 double GenoOperators::mutateNeuProperty(double current, Neuro *n, int i)
     88double GenoOperators::mutateNeuronProperty(double current, Neuro *n, int i)
    8989{
    9090        if (i == -1) return mutateCreepNoLimit('f', current, 2, true); //i==-1: mutating weight of neural connection
    9191        Param p;
    92         if (i >= 100) { i -= 100; p = n->getClass()->getProperties(); }
     92        if (i >= NEUROCLASS_PROP_OFFSET) { i -= NEUROCLASS_PROP_OFFSET; p = n->getClass()->getProperties(); }
    9393        else p = n->extraProperties();
    9494        double newval = current;
     
    354354                        const char *n = p.id(i);
    355355                        int l = (int)strlen(n);
    356                         if (len >= l && l > Len && (strncmp(s, n, l) == 0)) { I = 100 + i; Len = l; }
     356                        if (len >= l && l > Len && (strncmp(s, n, l) == 0)) { I = NEUROCLASS_PROP_OFFSET + i; Len = l; }
    357357                        if (also_v1_N_props) //recognize old properties symbols /=!
    358358                        {
     
    361361                                                if (strcmp(n, "fo") == 0) n = "!";
    362362                                l = (int)strlen(n);
    363                                 if (len >= l && l > Len && (strncmp(s, n, l) == 0)) { I = 100 + i; Len = l; }
     363                                if (len >= l && l > Len && (strncmp(s, n, l) == 0)) { I = NEUROCLASS_PROP_OFFSET + i; Len = l; }
    364364                        }
    365365                }
Note: See TracChangeset for help on using the changeset viewer.