Changeset 1260
- Timestamp:
- 06/22/23 04:00:45 (17 months ago)
- Location:
- cpp/frams
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
cpp/frams/Makefile-SDK-files
r1242 r1260 41 41 NN_LAYOUT_OBJS=frams/canvas/nn_layout_model.o frams/canvas/nn_simple_layout.o frams/canvas/nn_smart_layout.o 42 42 43 SDK_OBJS=frams/util/list.o frams/util/advlist.o frams/param/param.o frams/ util/sstring.o frams/util/sstringutils.o frams/util/3d.o frams/vm/classes/3dobject.o frams/model/model.o frams/model/modelparts.o frams/neuro/neurolibrary.o frams/genetics/geno.o frams/genetics/genoconv.o frams/util/extvalue.o frams/vm/classes/collectionobj.o frams/util/hashtable.o common/log.o common/util-string.o common/util-file.o common/nonstd_stdio.o frams/util/callbacks.o frams/param/syntparam.o frams/util/multirange.o frams/util/multimap.o frams/param/paramtabobj.o common/loggers/loggers.o frams/param/paramobj.o frams/genetics/genooperators.o common/nonstd_math.o frams/util/validitychecks.o common/Convert.o frams/util/rndutil.o common/virtfile/stringfile.o common/virtfile/stdinoutfilesystem.o $(PRINTFLOAT_OBJS)43 SDK_OBJS=frams/util/list.o frams/util/advlist.o frams/param/param.o frams/param/paramlist.o frams/util/sstring.o frams/util/sstringutils.o frams/util/3d.o frams/vm/classes/3dobject.o frams/model/model.o frams/model/modelparts.o frams/neuro/neurolibrary.o frams/genetics/geno.o frams/genetics/genoconv.o frams/util/extvalue.o frams/vm/classes/collectionobj.o frams/util/hashtable.o common/log.o common/util-string.o common/util-file.o common/nonstd_stdio.o frams/util/callbacks.o frams/param/syntparam.o frams/util/multirange.o frams/util/multimap.o frams/param/paramtabobj.o common/loggers/loggers.o frams/param/paramobj.o frams/genetics/genooperators.o common/nonstd_math.o frams/util/validitychecks.o common/Convert.o frams/util/rndutil.o common/virtfile/stringfile.o common/virtfile/stdinoutfilesystem.o $(PRINTFLOAT_OBJS) 44 44 45 45 STDOUT_LOGGER_OBJS=common/virtfile/virtfile.o common/loggers/loggertostdout.o common/console.o -
cpp/frams/_demos/geneprops_test.cpp
r1242 r1260 80 80 int maxcount = 4; 81 81 82 enum Function { Legacy, RecreatedLegacy, New05, NewExponential };83 Function fun = Legacy;82 enum Function { Legacy, AllChange05, ExperimentalExponential }; 83 Function fun = AllChange05; 84 84 85 85 int argpos = 0; … … 91 91 { 92 92 case 'l': fun = Legacy; break; 93 case 'r': fun = RecreatedLegacy; break; 94 case 'n': fun = New05; break; 95 case 'e': fun = NewExponential; break; 93 case 'n': fun = AllChange05; break; 94 case 'e': fun = ExperimentalExponential; break; 96 95 case 'h': printf("%s args: [modifier [max_count]] (one of " F14_MODIFIERS ")\n" 97 96 "\t-l = legacy function\n" 98 "\t-r = recreated legacy function\n" 99 "\t-n = new, change=0.5, normalizeBiol4 disabled\n" 100 "\t-e = new exponential function\n", argv[0]); 97 "\t-n = modern, change=0.5, normalizeBiol4 disabled\n" 98 "\t-e = experimental exponential function\n", argv[0]); 101 99 return 0; 102 100 default: fprintf(stderr, "%s: invalid option: %s\n", argv[0], arg); return 2; … … 115 113 116 114 GenePropsOps_Exponential exponential_ops; 117 GenePropsOps_ Old recreated_ops;118 GenePropsOps_ New05 new05_ops;115 GenePropsOps_Legacy legacy_ops; 116 GenePropsOps_AllChange05 allchange05_ops; 119 117 GenePropsOps *ops; 120 118 121 119 switch (fun) 122 120 { 123 case RecreatedLegacy: ops = &recreated_ops; break;124 case NewExponential: ops = &exponential_ops; break;125 case New05: ops = &new05_ops; break;121 case Legacy: ops = &legacy_ops; break; 122 case ExperimentalExponential: ops = &exponential_ops; break; 123 case AllChange05: ops = &allchange05_ops; break; 126 124 default: ops = NULL; 127 125 } … … 138 136 char m = ((1 << c) & i) ? modifier_u : modifier_l; 139 137 tmp[c] = m; 140 if (fun == Legacy) 141 props.executeModifier_Legacy(m); 142 else 143 props.executeModifier(m, ops); 138 props.executeModifier(m, ops); 144 139 } 145 140 if (count > 0) -
cpp/frams/genetics/geneprops.cpp
r1248 r1260 51 51 } 52 52 53 int GeneProps::executeModifier_Legacy(char modif)54 {55 switch (modif)56 {57 #ifdef v1f1COMPATIBLE58 case 'L': length += (3.0 - length) * 0.3;59 length = std::min(length, Model::getMaxJoint().d.x); break;60 #else61 case 'L': length += (2.0 - length) * 0.3; //2.0 is currently Model::getMaxJoint().d.x so min() does not limit the range62 length = std::min(length, Model::getMaxJoint().d.x); break;63 #endif64 case 'l': length += (0.33 - length) * 0.3;65 length = std::max(length, Model::getMinJoint().d.x); break;66 67 case 'W': weight += (2.0 - weight) * 0.3; break;68 case 'w': weight += (0.5 - weight) * 0.3; break;69 case 'F': friction += (4 - friction) * 0.2; break;70 case 'f': friction -= friction * 0.2; break;71 case 'C': curvedness += (2.0 - curvedness) * 0.25; break;72 case 'c': curvedness += (-2.0 - curvedness) * 0.25; break;73 case 'Q': twist += (M_PI_2 - twist) * 0.3; break;74 case 'q': twist += (-M_PI_2 - twist) * 0.3; break;75 case 'E': energy += (10.0 - energy) * 0.1; break;76 case 'e': energy -= energy * 0.1; break;77 78 case 'A': assimilation += (1 - assimilation) * 0.8; normalizeBiol4(); break;79 case 'a': assimilation -= assimilation * 0.4; normalizeBiol4(); break;80 case 'I': ingestion += (1 - ingestion) * 0.8; normalizeBiol4(); break;81 case 'i': ingestion -= ingestion * 0.4; normalizeBiol4(); break;82 case 'S': stamina += (1 - stamina) * 0.8; normalizeBiol4(); break;83 case 's': stamina -= stamina * 0.4; normalizeBiol4(); break;84 case 'M': muscle_power += (1 - muscle_power) * 0.8; normalizeBiol4(); break;85 case 'm': muscle_power -= muscle_power * 0.4; normalizeBiol4(); break;86 87 case 'D': cred += (1.0 - cred) * 0.25; break;88 case 'd': cred += (0.0 - cred) * 0.25; break;89 case 'G': cgreen += (1.0 - cgreen) * 0.25; break;90 case 'g': cgreen += (0.0 - cgreen) * 0.25; break;91 case 'B': cblue += (1.0 - cblue) * 0.25; break;92 case 'b': cblue += (0.0 - cblue) * 0.25; break;93 94 default: return -1;95 }96 return 0;97 }98 99 53 int GeneProps::executeModifier(char modif, GenePropsOps* ops) 100 54 { 101 55 if (ops == NULL) 102 ops = get StandardOps();56 ops = getDefaultOps(); 103 57 104 58 #define APPLY(name) ops->name->apply(name, modif) … … 152 106 153 107 if (ops == NULL) 154 ops = get StandardOps();108 ops = getDefaultOps(); 155 109 if (ops->use_normalizebiol4) normalizeBiol4(); 156 110 … … 171 125 } 172 126 173 double GenePropsOp_ Old::increase(double value) const127 double GenePropsOp_Legacy::increase(double value) const 174 128 { 175 129 return value + (maxvalue - value) * change; 176 130 } 177 131 178 double GenePropsOp_ Old::decrease(double value) const132 double GenePropsOp_Legacy::decrease(double value) const 179 133 { 180 134 return value + (minvalue - value) * revchange; 181 135 } 182 136 183 GenePropsOp_ Old::GenePropsOp_Old(double minvalue, double maxvalue, double defvalue, double change, double revchange)137 GenePropsOp_Legacy::GenePropsOp_Legacy(double minvalue, double maxvalue, double defvalue, double change, double revchange) 184 138 { 185 139 this->minvalue = minvalue; … … 246 200 } 247 201 248 GenePropsOps_ Old::GenePropsOps_Old()202 GenePropsOps_Legacy::GenePropsOps_Legacy() 249 203 { 250 204 use_normalizebiol4 = true; 251 205 252 length = new GenePropsOp_ Old(0.33, 2.0, GeneProps::standard_values.length, 0.3);253 weight = new GenePropsOp_ Old(0.5, 2.0, GeneProps::standard_values.weight, 0.3);254 friction = new GenePropsOp_ Old(0, 4.0, GeneProps::standard_values.friction, 0.2);255 curvedness = new GenePropsOp_ Old(-2, 2, GeneProps::standard_values.curvedness, 0.25);256 twist = new GenePropsOp_ Old(-M_PI_2, M_PI_2, GeneProps::standard_values.twist, 0.3);257 energy = new GenePropsOp_ Old(0, 10, GeneProps::standard_values.energy, 0.1);258 259 assimilation = new GenePropsOp_ Old(0, 1, GeneProps::standard_values.assimilation, 0.8, 0.4);260 ingestion = new GenePropsOp_ Old(0, 1, GeneProps::standard_values.ingestion, 0.8, 0.4);261 stamina = new GenePropsOp_ Old(0, 1, GeneProps::standard_values.stamina, 0.8, 0.4);262 muscle_power = new GenePropsOp_ Old(0, 1, GeneProps::standard_values.muscle_power, 0.8, 0.4);263 264 cred = new GenePropsOp_ Old(0, 1, GeneProps::standard_values.cred, 0.25);265 cgreen = new GenePropsOp_ Old(0, 1, GeneProps::standard_values.cgreen, 0.25);266 cblue = new GenePropsOp_ Old(0, 1, GeneProps::standard_values.cblue, 0.25);267 } 268 269 GenePropsOps_ New05::GenePropsOps_New05()206 length = new GenePropsOp_Legacy(0.33, 2.0, GeneProps::standard_values.length, 0.3); 207 weight = new GenePropsOp_Legacy(0.5, 2.0, GeneProps::standard_values.weight, 0.3); 208 friction = new GenePropsOp_Legacy(0, 4.0, GeneProps::standard_values.friction, 0.2); 209 curvedness = new GenePropsOp_Legacy(-2, 2, GeneProps::standard_values.curvedness, 0.25); 210 twist = new GenePropsOp_Legacy(-M_PI_2, M_PI_2, GeneProps::standard_values.twist, 0.3); 211 energy = new GenePropsOp_Legacy(0, 10, GeneProps::standard_values.energy, 0.1); 212 213 assimilation = new GenePropsOp_Legacy(0, 1, GeneProps::standard_values.assimilation, 0.8, 0.4); 214 ingestion = new GenePropsOp_Legacy(0, 1, GeneProps::standard_values.ingestion, 0.8, 0.4); 215 stamina = new GenePropsOp_Legacy(0, 1, GeneProps::standard_values.stamina, 0.8, 0.4); 216 muscle_power = new GenePropsOp_Legacy(0, 1, GeneProps::standard_values.muscle_power, 0.8, 0.4); 217 218 cred = new GenePropsOp_Legacy(0, 1, GeneProps::standard_values.cred, 0.25); 219 cgreen = new GenePropsOp_Legacy(0, 1, GeneProps::standard_values.cgreen, 0.25); 220 cblue = new GenePropsOp_Legacy(0, 1, GeneProps::standard_values.cblue, 0.25); 221 } 222 223 GenePropsOps_AllChange05::GenePropsOps_AllChange05() 270 224 { 271 225 use_normalizebiol4 = false; 226 227 constexpr float CHANGE = 0.5; 272 228 auto fields = { length,curvedness,weight,friction,muscle_power,assimilation,stamina,ingestion,twist,energy,cred,cgreen,cblue }; 273 229 for (auto f : fields) 274 230 { 275 auto f_gpo = dynamic_cast<GenePropsOp_ Old*>(f);231 auto f_gpo = dynamic_cast<GenePropsOp_Legacy*>(f); 276 232 if (f_gpo) 277 f_gpo->change = f_gpo->revchange = 0.5; 278 } 233 f_gpo->change = f_gpo->revchange = CHANGE; 234 } 235 236 delete curvedness; 237 curvedness = new GenePropsOp_Legacy(-M_PI_2, M_PI_2, GeneProps::standard_values.curvedness, CHANGE); 279 238 } 280 239 … … 298 257 } 299 258 300 301 GenePropsOps* GeneProps::standard_ops = NULL; 302 GenePropsOps* GeneProps::getStandardOps() 303 { 304 if (!standard_ops) 305 standard_ops = new GenePropsOps_New05(); 306 return standard_ops; 307 } 259 GenePropsOps* GeneProps::getAllChange05Ops() 260 { 261 static GenePropsOps_AllChange05 ops; 262 return &ops; 263 } 264 265 GenePropsOps* GeneProps::getLegacyOps() 266 { 267 static GenePropsOps_Legacy ops; 268 return &ops; 269 } 270 271 static GenePropsOps* default_ops = NULL; 272 273 GenePropsOps* GeneProps::getDefaultOps() 274 { 275 if (!default_ops) 276 default_ops = getAllChange05Ops(); 277 return default_ops; 278 } 279 280 void GeneProps::setDefaultOps(GenePropsOps* ops) 281 { 282 default_ops = ops; 283 } -
cpp/frams/genetics/geneprops.h
r1249 r1260 28 28 }; 29 29 30 class GenePropsOp_ Old: public GenePropsOp30 class GenePropsOp_Legacy : public GenePropsOp 31 31 { 32 32 double minvalue, maxvalue, defvalue, change, revchange; 33 33 public: 34 GenePropsOp_ Old(double minvalue, double maxvalue, double defvalue, double change, double revchange = -1);34 GenePropsOp_Legacy(double minvalue, double maxvalue, double defvalue, double change, double revchange = -1); 35 35 double increase(double value) const; 36 36 double decrease(double value) const; 37 friend class GenePropsOps_ New05;37 friend class GenePropsOps_AllChange05; 38 38 }; 39 39 40 40 class GenePropsOp_NormalizedAndScaled : public GenePropsOp 41 41 { 42 GenePropsOp_ Oldnormalized;42 GenePropsOp_Legacy normalized; 43 43 public: 44 44 GenePropsOp_NormalizedAndScaled(double change) :normalized(-1, 1, 0, change) {} … … 79 79 }; 80 80 81 class GenePropsOps_ Old: public GenePropsOps81 class GenePropsOps_Legacy : public GenePropsOps 82 82 { 83 83 public: 84 GenePropsOps_ Old();84 GenePropsOps_Legacy(); 85 85 }; 86 86 87 class GenePropsOps_New05 : public GenePropsOps_Old 87 /** 88 * Just as legacy (before 2023-06), but the influence of each modifier is uniform and simpler (no normalizeBiol4()). 89 * This is what is currently used in Framsticks. 90 */ 91 class GenePropsOps_AllChange05 : public GenePropsOps_Legacy 88 92 { 89 93 public: 90 GenePropsOps_ New05();94 GenePropsOps_AllChange05(); 91 95 }; 92 96 97 /** 98 * Just an experiment with a different scaling of the influence of individual modifier characters to cover 99 * the entire range of parameter values. After investigations we decided that it does not 100 * provide any advantages over "AllChange05". 101 */ 93 102 class GenePropsOps_Exponential : public GenePropsOps 94 103 { … … 132 141 133 142 static GeneProps standard_values; 134 static GenePropsOps* standard_ops; 135 static GenePropsOps* getStandardOps(); 143 144 static GenePropsOps* getDefaultOps(); 145 static void setDefaultOps(GenePropsOps* ops); 136 146 147 static GenePropsOps* getAllChange05Ops(); 148 static GenePropsOps* getLegacyOps(); 149 137 150 /** 138 151 * Constructor initializing all properties with default values. … … 154 167 */ 155 168 int executeModifier(char modif, GenePropsOps* ops = NULL); 156 int executeModifier_Legacy(char modif);157 169 158 170 /**
Note: See TracChangeset
for help on using the changeset viewer.