Changeset 1242 for cpp/frams/genetics/geneprops.h
- Timestamp:
- 05/18/23 14:19:34 (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
cpp/frams/genetics/geneprops.h
r1039 r1242 1 1 // This file is a part of Framsticks SDK. http://www.framsticks.com/ 2 // Copyright (C) 1999-20 18Maciej Komosinski and Szymon Ulatowski.2 // Copyright (C) 1999-2023 Maciej Komosinski and Szymon Ulatowski. 3 3 // See LICENSE.txt for details. 4 4 … … 19 19 20 20 21 class GenePropsOp 22 { 23 public: 24 virtual ~GenePropsOp() {} 25 virtual double increase(double value) const = 0; 26 virtual double decrease(double value) const = 0; 27 void apply(double &value, char modif) const; 28 }; 21 29 30 class GenePropsOp_Old : public GenePropsOp 31 { 32 double minvalue, maxvalue, defvalue, change, revchange; 33 public: 34 GenePropsOp_Old(double minvalue, double maxvalue, double defvalue, double change, double revchange = -1); 35 double increase(double value) const; 36 double decrease(double value) const; 37 friend class GenePropsOps_New05; 38 }; 39 40 class GenePropsOp_NormalizedAndScaled : public GenePropsOp 41 { 42 GenePropsOp_Old normalized; 43 public: 44 GenePropsOp_NormalizedAndScaled(double change) :normalized(-1, 1, 0, change) {} 45 virtual double scale(double value) const { return value; } 46 virtual double scaleInv(double value) const { return value; } 47 double increase(double value) const { return scale(normalized.increase(scaleInv(value))); } 48 double decrease(double value) const { return scale(normalized.decrease(scaleInv(value))); } 49 }; 50 51 class GenePropsOp_Exponential : public GenePropsOp_NormalizedAndScaled 52 { 53 double a, b, c; 54 double log_a; 55 bool linear; 56 public: 57 GenePropsOp_Exponential(double minvalue, double maxvalue, double defvalue, double change = 0.5); 58 double scale(double) const; 59 double scaleInv(double) const; 60 }; 61 62 class GenePropsOps 63 { 64 public: 65 ~GenePropsOps(); 66 67 GenePropsOp* length; 68 GenePropsOp* curvedness; 69 GenePropsOp* weight; 70 GenePropsOp* friction; 71 GenePropsOp* muscle_power; 72 GenePropsOp* assimilation; 73 GenePropsOp* stamina; 74 GenePropsOp* ingestion; 75 GenePropsOp* twist; 76 GenePropsOp* energy; 77 GenePropsOp* cred, *cgreen, *cblue; 78 bool use_normalizebiol4; 79 }; 80 81 class GenePropsOps_Old : public GenePropsOps 82 { 83 public: 84 GenePropsOps_Old(); 85 }; 86 87 class GenePropsOps_New05 : public GenePropsOps_Old 88 { 89 public: 90 GenePropsOps_New05(); 91 }; 92 93 class GenePropsOps_Exponential : public GenePropsOps 94 { 95 public: 96 GenePropsOps_Exponential(); 97 }; 22 98 23 99 /** … … 29 105 * parents (prop) modified with the prop.propagateAlong() method. 30 106 * "Biological" properties (assimilation, stamina, muscle strength and 31 * ingestion) shouldbe normalized after modification with normalizeBiol4().107 * ingestion) can be normalized after modification with normalizeBiol4(). 32 108 */ 33 109 struct GeneProps … … 55 131 56 132 static GeneProps standard_values; 133 static GenePropsOps* standard_ops; 134 static GenePropsOps* getStandardOps(); 57 135 58 136 /** … … 62 140 63 141 /** 64 * Normalizes biological properties (muscle_power, 65 * assimilation, stamina, and ingestion). This method is called in 66 * executeModifier() when any of the biological properties is modified. All values 67 * of those properties sum up to 1. 142 * Normalizes biological properties (muscle_power, assimilation, stamina, and ingestion). 143 * This method is called in executeModifier() when any of the biological properties is modified 144 * and \a use_normalizebiol4 is true. All values of those properties sum up to 1. 68 145 */ 69 146 void normalizeBiol4(); … … 75 152 * @return 0 if the provided character was property modifier, -1 otherwise 76 153 */ 77 int executeModifier(char modif); 154 int executeModifier(char modif, GenePropsOps* ops = NULL); 155 int executeModifier_Legacy(char modif); 78 156 79 157 /**
Note: See TracChangeset
for help on using the changeset viewer.