Changeset 767 for cpp/frams/genetics/f4/oper_f4.cpp
- Timestamp:
- 03/29/18 22:52:36 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
cpp/frams/genetics/f4/oper_f4.cpp
r760 r767 20 20 #define F4_MODIFIERS_VISUAL "" //not supported in f4 21 21 #define F4_MODIFIERS_RARE "EeWwAaSs" //expdef would need to handle these properly/specifically to ensure reasonable behavior, and hardly any expdef does. Modifying initial energy of a creature as a result of its genes (Ee) is in general not a good idea. Weight (Ww) works only in water, and in water sinking/going up should usually be caused by real "intentional" activity of a creature, not by its inherited weight. For assimilation (Aa), there is a dedicated parameter in CreaturesGroup. Stamina (Ss) is no longer needed as destructive collisions are not supported, and even if they were, some expdef would need to impose reasonable restrictions on the value of this parameter (e.g. similar to normalizeBiol4()) so there is some cost associated with it, and the specific consequences of destructions should be defined as needed. 22 #define F4_MODIFIERS " LlRrCcQqFfMmIi" F4_MODIFIERS_RARE F4_MODIFIERS_VISUAL22 #define F4_MODIFIERS ",LlRrCcQqFfMmIi" F4_MODIFIERS_RARE F4_MODIFIERS_VISUAL 23 23 const char *Geno_f4::all_modifiers = F4_MODIFIERS; 24 25 // codes that can be changed (apart from being added/deleted) 26 #define MUT_CHAN_CODES "<[#" 27 #define REP_MAXCOUNT 19 24 28 25 29 #define FIELDSTRUCT Geno_f4 … … 134 138 // ! the genotype is g->child (not g) ! 135 139 136 // codes that can be changed (apart being added/deleted)137 #define MUT_CHAN_CODES "<[#"138 #define ADD_SIMPLE_CODES ",XlLcCrRaAiIsSmMfFwWeEN@|"139 #define REP_MAXCOUNT 19140 141 140 // do the mutation 142 141 // pick a random node … … 176 175 else 177 176 { 178 f4_node *n4 = new f4_node(rndclass->getName().c_str(), n2, n2->pos); //TODO move this above177 f4_node *n4 = new f4_node(rndclass->getName().c_str(), n2, n2->pos); 179 178 if (rndclass->getPreferredInputs() != 0) 180 179 { … … 280 279 // choose a simple node from ADD_SIMPLE_CODES 281 280 n1->parent->removeChild(n1); 282 f4_node *n2 = new f4_node(ADD_SIMPLE_CODES[randomN(strlen(ADD_SIMPLE_CODES))], n1->parent, n1->parent->pos); 281 //f4_node *n2 = new f4_node(ADD_SIMPLE_CODES[randomN(strlen(ADD_SIMPLE_CODES))], n1->parent, n1->parent->pos); 282 int modifierid = GenoOperators::getRandomChar(all_modifiers, excluded_modifiers.c_str()); 283 f4_node *n2 = new f4_node(all_modifiers[modifierid], n1->parent, n1->parent->pos); 283 284 n2->addChild(n1); 284 285 n1->parent = n2; … … 717 718 } 718 719 719 720 721 720 uint32_t Geno_f4::style(const char *g, int pos) 722 721 { … … 727 726 #define STYL4CAT_DIGIT "0123456789." 728 727 #define STYL4CAT_REST "XN<># " 729 if (!strchr(STYL4CAT_MODIFIC STYL4CAT_NEUMOD STYL4CAT_DIGIT STYL4CAT_REST, ch)) 728 729 if (!isalpha(ch) && !isdigit(ch) && !strchr("<>-+[]:,.@|#*/=!\t",ch)) { 730 730 return GENSTYLE_CS(0, GENSTYLE_INVALID); 731 } 731 732 uint32_t style = GENSTYLE_CS(0, GENSTYLE_STRIKEOUT); //default, should be changed below 732 733 if (strchr("X ", ch)) style = GENSTYLE_CS(0, GENSTYLE_NONE); … … 737 738 if (strchr(STYL4CAT_MODIFIC, ch)) style = GENSTYLE_RGBS(100, 100, 100, GENSTYLE_NONE); 738 739 if (strchr(STYL4CAT_NEUMOD, ch)) style = GENSTYLE_RGBS(0, 150, 0, GENSTYLE_NONE); 740 if (isalpha(ch)) { 741 int p = pos; 742 while (p > 0) { 743 p--; 744 if (!isalpha(g[p])) { 745 if (isupper(g[p+1]) && (g[p] == ':' || g[p] == '[')) { // name of neuron class 746 style = GENSTYLE_RGBS(150,0,150,GENSTYLE_ITALIC); 747 } 748 else { // property 749 style = GENSTYLE_RGBS(255,140,0,GENSTYLE_BOLD); 750 } 751 } 752 } 753 } 739 754 return style; 740 755 }
Note: See TracChangeset
for help on using the changeset viewer.