Index: cpp/frams/genetics/genooperators.cpp
===================================================================
--- cpp/frams/genetics/genooperators.cpp	(revision 1232)
+++ cpp/frams/genetics/genooperators.cpp	(revision 1233)
@@ -8,4 +8,5 @@
 #include <common/nonstd_math.h>
 #include <frams/util/rndutil.h>
+#include <algorithm> // std::min, std::max
 
 //
@@ -355,20 +356,5 @@
 }
 
-int GenoOperators::getRandomChar(const char *choices, const char *excluded)
-{
-	int allowed_count = 0;
-	for (size_t i = 0; i < strlen(choices); i++) if (!strchrn0(excluded, choices[i])) allowed_count++;
-	if (allowed_count == 0) return -1; //no char is allowed
-	int rnd_index = rndUint(allowed_count) + 1;
-	allowed_count = 0;
-	for (size_t i = 0; i < strlen(choices); i++)
-	{
-		if (!strchrn0(excluded, choices[i])) allowed_count++;
-		if (allowed_count == rnd_index) return int(i);
-	}
-	return -1; //never happens
-}
-
-NeuroClass *GenoOperators::parseNeuroClass(char *&s, ModelEnum::ShapeType supported_shapetype)
+NeuroClass *GenoOperators::parseNeuroClass(char *&s, ModelEnum::ShapeType for_shape_type)
 {
 	int maxlen = (int)strlen(s);
@@ -378,5 +364,5 @@
 	{
 		NeuroClass *nci = Neuro::getClass(i);
-		if (!nci->isShapeTypeSupported(supported_shapetype))
+		if (!nci->isShapeTypeSupported(for_shape_type))
 			continue;
 		const char *nciname = nci->name.c_str();
@@ -434,4 +420,9 @@
 }
 
+bool GenoOperators::canStartNeuroClassName(const char firstchar)
+{
+	return isupper(firstchar) || firstchar == '|' || firstchar == '@' || firstchar == '*';
+}
+
 bool GenoOperators::isWS(const char c)
 {
@@ -466,6 +457,52 @@
 }
 
-bool GenoOperators::canStartNeuroClassName(const char firstchar)
-{
-	return isupper(firstchar) || firstchar == '|' || firstchar == '@' || firstchar == '*';
-}
+int GenoOperators::getRandomChar(const char *choices, const char *excluded)
+{
+	int allowed_count = 0;
+	for (size_t i = 0; i < strlen(choices); i++) if (!strchrn0(excluded, choices[i])) allowed_count++;
+	if (allowed_count == 0) return -1; //no char is allowed
+	int rnd_index = rndUint(allowed_count) + 1;
+	allowed_count = 0;
+	for (size_t i = 0; i < strlen(choices); i++)
+	{
+		if (!strchrn0(excluded, choices[i])) allowed_count++;
+		if (allowed_count == rnd_index) return int(i);
+	}
+	return -1; //never happens
+}
+
+//#include <cassert>
+string GenoOperators::simplifiedModifiers(const char *str_of_char_pairs, vector<int> &char_counts)
+{
+//	assert(strlen(str_of_char_pairs) == char_counts.size());
+//	assert(char_counts.size() % 2 == 0);
+	const int MAX_NUMBER_SAME_TYPE = 8; // max. number of modifiers of each type = 8 (mainly for Rr)
+	string simplified;
+	//#define CLUMP_IDENTICAL_MODIFIERS //not good because properties are calculated incrementally, non-linearly, and their values are updated after each modifier character, so these values may for example saturate after a large number of identical modifier symbols. The order of modifiers is in general relevant and extreme values of properties increase this relevance, so better keep the modifiers dispersed.
+#ifdef CLUMP_IDENTICAL_MODIFIERS
+	for (size_t i = 0; i < strlen(str_of_char_pairs); i++)
+		if ((i % 2) == 0) //only even index "i" in str_of_char_pairs
+			for (int j = 0; j < std::min(MAX_NUMBER_SAME_TYPE, abs(char_counts[i] - char_counts[i + 1])); j++) //assume that an even-index char and the following odd-index char have the opposite influence, so they cancel out.
+				simplified += str_of_char_pairs[i + (char_counts[i + 1] > char_counts[i])]; //inner loop adds a sequence of same chars such as rrrrr or QQQ
+#else
+	for (size_t i = 0; i < strlen(str_of_char_pairs); i++)
+		if ((i % 2) == 0) //only even index "i" in str_of_char_pairs
+		{
+			char_counts[i] -= char_counts[i + 1]; //from now on, even items in the vector store the difference between antagonistic modifier symbols; odd items are not needed
+			char_counts[i] = std::min(std::max(char_counts[i], -MAX_NUMBER_SAME_TYPE), MAX_NUMBER_SAME_TYPE);
+		}
+	int remaining;
+	do {
+		remaining = 0;
+		for (size_t i = 0; i < strlen(str_of_char_pairs); i++)
+			if ((i % 2) == 0) //only even index "i" in str_of_char_pairs
+				if (char_counts[i] != 0)
+				{
+					simplified += str_of_char_pairs[i + (char_counts[i] < 0)];
+					char_counts[i] += char_counts[i] > 0 ? -1 : +1; //decrease the difference towards zero
+					remaining += abs(char_counts[i]);
+				}
+	} while (remaining > 0);
+#endif
+	return simplified;
+}
Index: cpp/frams/genetics/genooperators.h
===================================================================
--- cpp/frams/genetics/genooperators.h	(revision 1232)
+++ cpp/frams/genetics/genooperators.h	(revision 1233)
@@ -121,6 +121,6 @@
 	\retval GENOPER_OPFAIL
 	\sa
-	Mutation example to illustrate the exchange of pointers for \e geno.
-	The mutation adds random letter at the beginning or removes last letter from \e geno.
+	Mutation example to illustrate the exchange of pointers for \a geno.
+	The mutation adds random letter at the beginning or removes last letter from \a geno.
 	\code
 	{
@@ -144,5 +144,5 @@
 	virtual int mutate(char *&geno, float& chg, int &method) { method = -1; chg = -1; return GENOPER_NOOPER; }
 
-	/**Crosses over two genotypes. It is sufficient to return only one child (in \e g1) and set \e chg1 only, then \e g2 must equal "".
+	/**Crosses over two genotypes. It is sufficient to return only one child (in \a g1) and set \a chg1 only, then \a g2 must equal "".
 
 	Avoid unnecessary calls in your code. Every genotype argument passed to this
@@ -167,5 +167,5 @@
 	\param geno genotype
 	\param pos 0-based char offset
-	\retval number-encoded visual style (and validity) of the genotype char at \e geno[pos].
+	\retval number-encoded visual style (and validity) of the genotype char at \a geno[pos].
 	Assume white background.
 	\sa GENSTYLE_* macros, like GENSTYLE_BOLD*/
@@ -183,19 +183,20 @@
 	static const int NEUROCLASS_PROP_OFFSET = 100; //a NeuroClass property is identified by some functions below as a single-value integer index, yet a property is either "standard" or "extra" (two separate lists), hence this offset to tell one case from the other.
 
-	static int roulette(const double *probtab, const int count); 	///<returns random index according to probabilities in the \e probtab table or -1 if all probs are zero. \e count is the number of elements in \e probtab.
+	static int roulette(const double *probtab, const int count); 	///<returns random index according to probabilities in the \a probtab table or -1 if all probs are zero. \a count is the number of elements in \a probtab.
 	static bool getMinMaxDef(ParamInterface *p, int propindex, double &mn, double &mx, double &def); ///<perhaps a more useful (higher-level) way to obtain min/max/def info for integer and double properties. Returns true if min/max/def was really available (otherwise it is just invented).
 	static bool mutateRandomNeuroClassProperty(Neuro* n); ///<high-level neuron mutation function, will select and mutate a random property of Neuron's NeuroClass. Returns true if successful and some property was actually mutated. Could return false when the NeuroClass of the Neuron have no properties, or when a randomly selected property was not suitable for mutation (for example a string or another non-number type).
 	static int selectRandomNeuroClassProperty(Neuro* n); ///<selects random property (either 0-based extraproperty of NeuroClass or NEUROCLASS_PROP_OFFSET-based standard property of NeuroClass). -1 if Neuroclass has no properties.
-	static double getMutatedNeuroClassProperty(double current, Neuro *n, int propindex); ///<returns value \e current mutated for the property \e propindex of Neuron's NeuroClass or for extraproperty (\e propindex - NEUROCLASS_PROP_OFFSET) of Neuron's NeuroClass. Neuro \e n is used as read-only.
-	static double getMutatedNeuronConnectionWeight(double current); ///<returns mutated value of \e current.
+	static double getMutatedNeuroClassProperty(double current, Neuro *n, int propindex); ///<returns value \a current mutated for the property \a propindex of Neuron's NeuroClass or for extraproperty (\a propindex - NEUROCLASS_PROP_OFFSET) of Neuron's NeuroClass. Neuro \a n is used as read-only.
+	static double getMutatedNeuronConnectionWeight(double current); ///<returns mutated value of \a current.
 	static bool mutatePropertyNaive(ParamInterface &p, int propindex); ///<creep-mutate selected property. Returns true when success. mutateProperty() should be used instead of this function.
 	static bool mutateProperty(ParamInterface &p, int propindex); ///<like mutatePropertyNaive(), but uses special probability distributions for some neuron properties.
-	static bool getMutatedProperty(ParamInterface &p, int i, double oldval, double &newval); ///<like mutateProperty(), but just returns \e newval, does not get nor set it using \e p.
-	static double mutateCreepNoLimit(char type, double current, double stddev, bool limit_precision_3digits); ///<returns \e current value creep-mutated with Gaussian distribution and \e stddev standard deviation. Precision limited to 3 digits after comma when \e limit_precision_3digits is true. \e type must be either 'd' (integer) or 'f' (float/double).
+	static bool getMutatedProperty(ParamInterface &p, int i, double oldval, double &newval); ///<like mutateProperty(), but just returns \a newval, does not get nor set it using \a p.
+	static double mutateCreepNoLimit(char type, double current, double stddev, bool limit_precision_3digits); ///<returns \a current value creep-mutated with Gaussian distribution and \a stddev standard deviation. Precision limited to 3 digits after comma when \a limit_precision_3digits is true. \a type must be either 'd' (integer) or 'f' (float/double).
 	static double mutateCreep(char type, double current, double mn, double mx, double stddev, bool limit_precision_3digits); ///<just as mutateCreepNoLimit(), but forces mutated value into the [mn,mx] range using the 'reflect' approach.
-	static double mutateCreep(char type, double current, double mn, double mx, bool limit_precision_3digits); ///<just as mutateCreepNoLimit(), but forces mutated value into the [\e mn,\e mx] range using the 'reflect' approach and assumes standard deviation to be a fraction of the mx-mn interval width.
+	static double mutateCreep(char type, double current, double mn, double mx, bool limit_precision_3digits); ///<just as mutateCreepNoLimit(), but forces mutated value into the [\a mn,\a mx] range using the 'reflect' approach and assumes standard deviation to be a fraction of the mx-mn interval width.
 	static void setIntFromDoubleWithProbabilisticDithering(ParamInterface &p, int index, double value); ///<sets a double value in an integer field; when a value is non-integer, applies random "dithering" so that both lower and higher integer value have some chance to be set.
 	static void linearMix(vector<double> &p1, vector<double> &p2, double proportion); ///<mixes two real-valued vectors; inherited proportion should be within [0,1]; 1.0 does not change values (all inherited), 0.5 causes both vectors to become their average, 0.0 swaps values (none inherited).
 	static void linearMix(ParamInterface &p1, int i1, ParamInterface &p2, int i2, double proportion); ///<mixes i1'th and i2'th properties of p1 and p2; inherited proportion should be within [0,1]; 1.0 does not change values (all inherited), 0.5 causes both properties to become their average, 0.0 swaps values (none inherited). For integer properties applies random "dithering" when necessary.
+
 	static int getActiveNeuroClassCount(Model::ShapeType for_shape_type); ///<returns active class count
 	static NeuroClass* getRandomNeuroClass(Model::ShapeType for_shape_type); ///<returns random neuroclass or NULL when no active classes.
@@ -204,17 +205,18 @@
 	static NeuroClass* getRandomNeuroClassWithOutputAndWantingNoInputs(Model::ShapeType for_shape_type); ///<returns random sensor or NULL when no active classes. Note: only neuroclasses that prefer 0 inputs are considered, not those that prefer any number of inputs (thus including 0) - see getRandomNeuroClassWithOutputAndWantingNoOrAnyInputs().
 	static NeuroClass* getRandomNeuroClassWithOutputAndWantingNoOrAnyInputs(Model::ShapeType for_shape_type); ///<returns random neuron or NULL when no active classes. Note: both neuroclasses that prefer 0 inputs and those that prefer any number of inputs (thus including 0) are considered.
-	static int getRandomNeuroClassWithOutput(const vector<NeuroClass*>& NClist); ///<returns index of random NeuroClass from the NClist or -1 when no neurons in the list provide output \e NClist list of available neuron classes
-	static int getRandomNeuroClassWithInput(const vector<NeuroClass*>& NClist); ///<returns index of random NeuroClass from the NClist or -1 when no neurons in the list want input(s) \e NClist list of available neuron classes
-	static int getRandomChar(const char *choices, const char *excluded); ///<returns index of a random character from \e choices excluding \e excluded, or -1 when everything is excluded or \e choices is empty.
-	static NeuroClass* parseNeuroClass(char *&s, ModelEnum::ShapeType supported_shapetype); ///<returns the longest matching neuroclass that satisfies supported_shapetype (ModelEnum::SHAPETYPE_BALL_AND_STICK or ModelEnum::SHAPETYPE_SOLIDS) or NULL if the string does not begin with an appropriate neuroclass name. Advances the \e s pointer if the neuroclass is found.
-	static Neuro* findNeuro(const Model *m, const NeuroClass *nc); ///<returns pointer to first Neuro of class \e nc, or NULL if there is no such Neuro.
-	static int neuroClassProp(char *&s, NeuroClass *nc, bool also_v1_N_props = false); ///<returns 0-based extraproperty of NeuroClass or NEUROCLASS_PROP_OFFSET-based standard property of NeuroClass, or -1 if the string does not begin with a valid property name. Advance the \e s pointer if success.
-	static bool isWS(const char c); ///<is \e c a whitespace char?
-	static void skipWS(char *&s); ///<advances pointer \e s skipping whitespaces.
+	static int getRandomNeuroClassWithOutput(const vector<NeuroClass*>& NClist); ///<returns index of random NeuroClass from the NClist or -1 when no neurons in the list provide output \a NClist list of available neuron classes
+	static int getRandomNeuroClassWithInput(const vector<NeuroClass*>& NClist); ///<returns index of random NeuroClass from the NClist or -1 when no neurons in the list want input(s) \a NClist list of available neuron classes
+	static NeuroClass* parseNeuroClass(char *&s, ModelEnum::ShapeType for_shape_type); ///<returns the longest matching neuroclass that supports for_shape_type (ModelEnum::SHAPETYPE_BALL_AND_STICK or ModelEnum::SHAPETYPE_SOLIDS) or NULL if the string does not begin with an appropriate neuroclass name. Advances the \a s pointer if the neuroclass is found.
+	static Neuro* findNeuro(const Model *m, const NeuroClass *nc); ///<returns pointer to first Neuro of class \a nc, or NULL if there is no such Neuro.
+	static int neuroClassProp(char *&s, NeuroClass *nc, bool also_v1_N_props = false); ///<returns 0-based extraproperty of NeuroClass or NEUROCLASS_PROP_OFFSET-based standard property of NeuroClass, or -1 if the string does not begin with a valid property name. Advance the \a s pointer if success.
+	static bool canStartNeuroClassName(const char firstchar); ///<determines if \a firstchar may start NeuroClass name. If not, it might start NeuroClass' (or Neuro's) property name.
+
+	static bool isWS(const char c); ///<is \a c a whitespace char?
+	static void skipWS(char *&s); ///<advances pointer \a s skipping whitespaces.
 	static bool areAlike(char*, char*); ///<compares two text strings skipping whitespaces. Returns 1 when equal, 0 when different.
-	static char* strchrn0(const char *str, char ch); ///<like strchr, but does not find zero char in \e str.
-	static bool canStartNeuroClassName(const char firstchar); ///<determines if \e firstchar may start NeuroClass name. If not, it might start NeuroClass' (or Neuro's) property name.
-
-
+	static char* strchrn0(const char *str, char ch); ///<like strchr, but does not find zero char in \a str.
+
+	static int getRandomChar(const char *choices, const char *excluded); ///<returns index of a random character from \a choices excluding \a excluded, or -1 when everything is excluded or \a choices is empty.
+	static string simplifiedModifiers(const char *str_of_char_pairs, vector<int> &char_counts); ///<returns a sequence of chars from \a str_of_char_pairs based on how many times each char occurred in \a char_counts. Assume that an even-index char and the following odd-index char have the opposite influence, so they cancel out.
 	//@}
 };
