Index: cpp/frams/Makefile-GDK
===================================================================
--- cpp/frams/Makefile-GDK	(revision 137)
+++ cpp/frams/Makefile-GDK	(revision 138)
@@ -5,5 +5,5 @@
 include frams/Makefile-GDK-files
 
-GDK_TESTS=genoconv_test gdk_test geno_test neuro_test loader_test serial_test multiline_f0_test f0_variants_test full_props part_shapes neuro_layout_test
+GDK_TESTS=genoconv_test gdk_test geno_test neuro_test loader_test serial_test multiline_f0_test f0_variants_test full_props part_shapes neuro_layout_test genooper_test
 
 gdk_tests: $(GDK_TESTS)
@@ -47,7 +47,10 @@
 	$(CXX) $(NEURO_LAYOUT_TEST_OBJS) -o $@
 
+genooper_test: $(GENOOPER_TEST_OBJS)
+	$(CXX) $(GENOOPER_TEST_OBJS) -o $@
+
 #############################################
 
-ALL_OBJS=$(GDK_TEST_OBJS) $(GENOCONV_TEST_OBJS) $(GENO_TEST_OBJS) $(NEURO_TEST_OBJS) $(LOADER_TEST_OBJS) $(SERIAL_TEST_OBJS) $(MULTILINE_F0_OBJS) $(F0_VARIANTS_OBJS) $(FULL_PROPS_OBJS) $(PART_SHAPES_OBJS) $(NEURO_LAYOUT_TEST_OBJS)
+ALL_OBJS=$(GDK_TEST_OBJS) $(GENOCONV_TEST_OBJS) $(GENO_TEST_OBJS) $(NEURO_TEST_OBJS) $(LOADER_TEST_OBJS) $(SERIAL_TEST_OBJS) $(MULTILINE_F0_OBJS) $(F0_VARIANTS_OBJS) $(FULL_PROPS_OBJS) $(PART_SHAPES_OBJS) $(NEURO_LAYOUT_TEST_OBJS) $(GENOOPER_TEST_OBJS)
 
 include frams/Makefile-maintain
Index: cpp/frams/Makefile-GDK-files
===================================================================
--- cpp/frams/Makefile-GDK-files	(revision 137)
+++ cpp/frams/Makefile-GDK-files	(revision 138)
@@ -5,4 +5,5 @@
 
 GENOCONV_GDK_OBJS=frams/genetics/f1/conv_f1.o frams/genetics/f9/conv_f9.o
+GENMAN_GDK_OBJS=frams/genetics/f9/oper_f9.o
 
 GDK_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/framsg.o frams/util/callbacks.o frams/param/syntparam.o frams/util/multirange.o frams/util/multimap.o frams/param/paramtabobj.o frams/genetics/defgenoconv.o frams/errmgr/errmanager.o frams/param/paramobj.o frams/genetics/oper_fx.o common/nonstd_math.o frams/errmgr/stderrors.o common/Convert.o frams/util/rndutil.o
@@ -34,2 +35,4 @@
 
 NEURO_LAYOUT_TEST_OBJS= frams/_demos/neuro_layout_test.o frams/virtfile/virtfile.o frams/errmgr/stdouterr.o $(GDK_OBJS) $(GENOCONV_GDK_OBJS) frams/canvas/nn_layout_model.o frams/canvas/nn_simple_layout.o frams/canvas/nn_smart_layout.o
+
+GENOOPER_TEST_OBJS=frams/_demos/genooper_test.o frams/virtfile/virtfile.o frams/errmgr/stdouterr.o $(GDK_OBJS) $(GENOCONV_GDK_OBJS) $(GENMAN_GDK_OBJS) frams/genetics/genman.o frams/param/mutableparam.o frams/param/mutparamlist.o frams/neuro/geneticneuroparam.o frams/neuro/neurolibparam.o frams/vm/classes/genoobj.o frams/model/autoname.o
Index: cpp/frams/_demos/genooper_test.cpp
===================================================================
--- cpp/frams/_demos/genooper_test.cpp	(revision 138)
+++ cpp/frams/_demos/genooper_test.cpp	(revision 138)
@@ -0,0 +1,50 @@
+// This file is a part of the Framsticks GDK.
+// Copyright (C) 2002-2014  Maciej Komosinski and Szymon Ulatowski.  See LICENSE.txt for details.
+// Refer to http://www.framsticks.com/ for further information.
+
+#include <frams/genetics/genman.h>
+#include <frams/errmgr/stdouterr.h>
+
+StdoutErrorHandler err;
+
+void printGen(Geno &g)
+{
+	printf("Genotype: %s\nFormat: %c\nValid: %s\nComment: %s\n",
+		(const char*)g.getGene(), g.getFormat(), g.isValid() ? "yes" : "no", g.getComment().len() == 0 ? "(empty)" : (const char*)g.getComment());
+}
+
+void printGenAndTitle(Geno &g, const char* title)
+{
+	printf("\n--------------------- %s: ---------------------\n", title);
+	printGen(g);
+}
+
+/* Demonstrates various genetic operators applied to a sample genotype. See also oper_fx.cpp. */
+int main(int argc, char *argv[])
+{
+	GenMan gm;
+	gm.p_report(NULL, NULL);
+
+	const char* src = (argc > 1) ? argv[1] : "/*9*/RRR";
+	Geno gsrc(src, -1, "First");
+	printGenAndTitle(gsrc, "source genotype (gsrc)");
+
+	Geno gmut = gm.Mutate(gsrc);
+	printGenAndTitle(gmut, "mutated (gmut)");
+
+	Geno gxover = gm.CrossOver(gsrc, gmut);
+	printGenAndTitle(gxover, "crossed over (gsrc and gmut)");
+
+	Geno gsimplest = gm.GetSimplest('9');
+	printGenAndTitle(gsimplest, "simplest");
+
+	Geno ginvalid("IT'S REALLY WRONG", '9');
+	printGenAndTitle(ginvalid, "invalid");
+
+	Geno fixed = gm.Validate(ginvalid);
+	printGenAndTitle(fixed, "validated");
+
+	printf("\nHTMLized: %s\n", (const char*)gm.HTMLize((const char*)fixed.getGene()));
+
+	return 0;
+}
Index: cpp/frams/genetics/gen-config-GDK.h
===================================================================
--- cpp/frams/genetics/gen-config-GDK.h	(revision 137)
+++ cpp/frams/genetics/gen-config-GDK.h	(revision 138)
@@ -26,2 +26,3 @@
 //#define USE_GENMAN_F4
 //#define USE_GENMAN_F5
+#define USE_GENMAN_F9
Index: cpp/frams/genetics/genman.cpp
===================================================================
--- cpp/frams/genetics/genman.cpp	(revision 138)
+++ cpp/frams/genetics/genman.cpp	(revision 138)
@@ -0,0 +1,563 @@
+// This file is a part of the Framsticks GDK.
+// Copyright (C) 2002-2014  Maciej Komosinski and Szymon Ulatowski.  See LICENSE.txt for details.
+// Refer to http://www.framsticks.com/ for further information.
+
+#include "genman.h"
+#include <frams/vm/classes/genoobj.h>
+#include GEN_CONFIG_FILE //configuration of active genetic operators
+#include "common/framsg.h"
+#include "common/nonstd_math.h"
+#include <frams/errmgr/errmanager.h>
+
+
+#ifdef USE_GENMAN_F0
+#include "f0/oper_f0.h"
+#endif
+#ifdef USE_GENMAN_F0FUZZY
+#include "f0/oper_f0Fuzzy.h"
+#endif
+#ifdef USE_GENMAN_F1
+#include "f1/oper_f1.h"
+#endif
+#ifdef USE_GENMAN_F2
+#include "f2/oper_f2.h"
+#endif
+#ifdef USE_GENMAN_F2
+#include "f3/oper_f3.h"
+#endif
+#ifdef USE_GENMAN_F4
+#include "f4/oper_f4.h"
+#endif
+#ifdef USE_GENMAN_F5
+#include "f5/oper_f5.h"
+#endif
+#ifdef USE_GENMAN_F6
+#include "f6/oper_f6.h"
+#endif
+#ifdef USE_GENMAN_F7
+#include "f7/oper_f7.h"
+#endif
+#ifdef USE_GENMAN_F8
+#include "f8/oper_f8.h"
+#endif
+#ifdef USE_GENMAN_F9
+#include "f9/oper_f9.h"
+#endif
+
+using namespace std; //string, vector
+
+//old code needs update:
+//#include "gengroups.h"
+//extern GenGroup *listaGen;
+//   GENGROUP(0)->l_del.add(sim->GM.onDelGen,&sim->GM); //before delete
+//   GENGROUP(0)->l_del.remove(sim->GM.onDelGen,&sim->GM); //before delete
+
+
+#define FIELDSTRUCT GenMan
+
+static ParamEntry GMparam_tab[] =
+{
+	{ "Genetics", 1, 10, "GenMan", },
+	{ "gen_hist", 0, PARAM_DONTSAVE, "Remember history of genetic operations", "d 0 1 0", FIELD(history), "Required for phylogenetic analysis", },
+	{ "gen_hilite", 0, 0, "Use syntax highlighting", "d 0 1 1", FIELD(hilite), "Use colors for genes?\n(slows down viewing/editing of huge genotypes)", },
+	{ "gen_extmutinfo", 0, 0, "Extended mutation info", "d 0 2 0 ~Off~Method ID~Method description", FIELD(extmutinfo), "If active, information about employed mutation method will be stored in the 'info' field of each mutated genotype.", },
+	{ "operReport", 0, PARAM_DONTSAVE, "Operators report", "p()", PROCEDURE(p_report), "Show available genetic operators", },
+	{ "toHTML", 0, PARAM_DONTSAVE, "HTMLize a genotype", "p s(s)", PROCEDURE(p_htmlize), "returns genotype expressed as colored HTML", },
+	{ "toHTMLshort", 0, PARAM_DONTSAVE, "HTMLize a genotype, shorten if needed", "p s(s)", PROCEDURE(p_htmlizeshort), "returns genotype (abbreviated if needed) expressed as colored HTML", },
+	{ "validate", 0, PARAM_DONTSAVE + PARAM_USERHIDDEN, "Validate", "p oGeno(oGeno)", PROCEDURE(p_validate), "returns validated (if possible) Geno object from supplied Geno", },
+	{ "mutate", 0, PARAM_DONTSAVE + PARAM_USERHIDDEN, "Mutate", "p oGeno(oGeno)", PROCEDURE(p_mutate), "returns mutated Geno object from supplied Geno", },
+	{ "crossOver", 0, PARAM_DONTSAVE + PARAM_USERHIDDEN, "Crossover", "p oGeno(oGeno,oGeno)", PROCEDURE(p_crossover), "returns crossed over genotype", },
+	{ "getSimplest", 0, PARAM_DONTSAVE + PARAM_USERHIDDEN, "Get simplest genotype", "p oGeno(d format)", PROCEDURE(p_getsimplest), "returns the simplest genotype for a given encoding (format). 0 means f0, 4 means f4, etc.", },
+	{ 0, },
+};
+
+static ParamEntry GMstats_tab[] =
+{
+	{ "Genetics", 1, 12, "GenManStats", "Statistics for genetic operations." },
+	{ "gen_count", 0, PARAM_READONLY, "Number of genetic operations so far", "d", FIELD(count), "", },
+	{ "gen_mvalid", 0, PARAM_READONLY, "Mutations valid", "d", FIELD(valid_m), "", },
+	{ "gen_mvalidated", 0, PARAM_READONLY, "Mutations validated", "d", FIELD(validated_m), "", },
+	{ "gen_minvalid", 0, PARAM_READONLY, "Mutations invalid", "d", FIELD(invalid_m), "couldn't be repaired", },
+	{ "gen_mfailed", 0, PARAM_READONLY, "Mutations failed", "d", FIELD(failed_m), "couldn't be performed", },
+	{ "gen_xovalid", 0, PARAM_READONLY, "Crossovers valid", "d", FIELD(valid_xo), "", },
+	{ "gen_xovalidated", 0, PARAM_READONLY, "Crossovers validated", "d", FIELD(validated_xo), "", },
+	{ "gen_xoinvalid", 0, PARAM_READONLY, "Crossovers invalid", "d", FIELD(invalid_xo), "couldn't be repaired", },
+	{ "gen_xofailed", 0, PARAM_READONLY, "Crossovers failed", "d", FIELD(failed_xo), "couldn't be performed", },
+	{ "gen_mutimpr", 0, PARAM_READONLY, "Mutations total effect", "f", FIELD(mutchg), "total cumulative mutation change", },
+	{ "gen_xoimpr", 0, PARAM_READONLY, "Crossovers total effect", "f", FIELD(xochg), "total cumulative crossover change", },
+	{ "clrstats", 0, PARAM_DONTSAVE, "Clear stats and history", "p()", PROCEDURE(p_clearStats), "", },
+	{ 0, },
+};
+
+#undef FIELDSTRUCT
+
+GenMan::GenMan() : localpar(GMparam_tab, this), localstats(GMstats_tab, this),
+seloperpar("GenOperators", "Genetics: Active operators"),
+par("GenMan", "Manages various genetic operations, using appropriate operators for the argument genotype format."),
+neuronsparam("Genetics: Neurons to add", "neuronsAdd", "neuadd_")
+{
+	history = 0;
+	hilite = 1;
+	clearStats();
+
+#ifdef USE_GENMAN_F0
+	geno_fx_list.push_back(new Geno_f0);
+#endif
+#ifdef USE_GENMAN_F0FUZZY
+	geno_fx_list.push_back(new Geno_f0Fuzzy);
+#endif
+#ifdef USE_GENMAN_F1
+	geno_fx_list.push_back(new Geno_f1);
+#endif
+#ifdef USE_GENMAN_F2
+	geno_fx_list.push_back(new Geno_f2);
+#endif
+#ifdef USE_GENMAN_F3
+	geno_fx_list.push_back(new Geno_f3);
+#endif
+#ifdef USE_GENMAN_F4
+	geno_fx_list.push_back(new Geno_f4);
+#endif
+#ifdef USE_GENMAN_F5
+	geno_fx_list.push_back(new Geno_f5);
+#endif
+#ifdef USE_GENMAN_F6
+	geno_fx_list.push_back(new Geno_f6);
+#endif
+#ifdef USE_GENMAN_F7
+	geno_fx_list.push_back(new Geno_f7);
+#endif
+#ifdef USE_GENMAN_F8
+	geno_fx_list.push_back(new Geno_f8);
+#endif
+#ifdef USE_GENMAN_F9
+	geno_fx_list.push_back(new GenoOper_f9);
+#endif
+
+	seloper = new int[geno_fx_list.size()]; //may result in a little overhead if some of the operators on the geno_fx_list concern the same genetic format
+	int selopercount = 0;
+	for (unsigned int i = 0; i < geno_fx_list.size(); i++)
+	{
+		if (operformats.find(geno_fx_list[i]->supported_format) != -1) continue;
+		char tmp[10];
+		SString id, name, type = "~";
+		type += geno_fx_list[i]->name;
+		int dup = 0;
+		for (unsigned int j = i + 1; j < geno_fx_list.size(); j++)
+			if (geno_fx_list[i]->supported_format == geno_fx_list[j]->supported_format)
+			{
+				type += "~"; type += geno_fx_list[j]->name; dup++;
+			}
+		sprintf(tmp, "d 0 %d ", dup);
+		type = SString(tmp) + type;
+		sprintf(tmp, "%c", geno_fx_list[i]->supported_format);
+		id = "genoper_f"; id += tmp;
+		name = "Operators for f"; name += tmp;
+		seloper[selopercount] = 0;
+		operformats += geno_fx_list[i]->supported_format;
+		//printf("%x %s %s %s\n",&seloper[selopercount],(const char*)id,(const char*)type,(const char*)name);
+		seloperpar.addProperty(&seloper[selopercount++], id, type, name, "", PARAM_READONLY*(dup == 0));
+	}
+
+	par += &localpar;
+	par += &seloperpar;
+	par += &neuronsparam;
+	for (unsigned int i = 0; i < geno_fx_list.size(); i++)
+		if (geno_fx_list[i]->par.getParamTab()) par += &geno_fx_list[i]->par;
+}
+
+GenMan::~GenMan()
+{
+	for (unsigned int i = 0; i < geno_fx_list.size(); i++) delete geno_fx_list[i];
+	delete[] seloper;
+}
+
+void GenMan::setDefaults()
+{
+	for (unsigned int i = 0; i < geno_fx_list.size(); i++)
+	{
+		geno_fx_list[i]->par.setDefault();
+		geno_fx_list[i]->setDefaults();
+	}
+	localpar.setDefault();
+	//...and we do not reset others that are linked to 'par',
+	//because there quite a few of them, and not every of them defines defaults for each of its parameters.
+}
+
+int GenMan::testValidity(Geno &g, bool &canvalidate)
+{
+	const char *gg = g.getGene();
+	GenoOperators *gf = getGeno_f(g.getFormat());
+	int check1;
+	if (!gf) { canvalidate = false; return GENOPER_NOOPER; }
+	else check1 = gf->checkValidity(gg);
+	if (!canvalidate) return check1; //just checking
+	if (check1 == GENOPER_OK) { canvalidate = false; return check1; }
+	char *g2 = strdup(gg);
+	if (gf->validate(g2) == GENOPER_NOOPER) { free(g2); canvalidate = false; return check1; }
+	if (check1 == GENOPER_NOOPER) //disaster: cannot check because there is no check operator
+	{
+		g.setGene(g2); free(g2); canvalidate = false; return GENOPER_NOOPER;
+	}
+	int check2 = gf->checkValidity(g2);
+	if (check2 == GENOPER_OK) g.setGene(g2);
+	free(g2);
+	if (check2 == GENOPER_OK) return check1;
+	canvalidate = false;
+	return check1; //could not validate.
+}
+
+int GenMan::testGenoValidity(Geno& g)
+{
+	bool fix = false;
+	switch (testValidity(g, fix))
+	{
+	case GENOPER_OK: return 1;
+	case GENOPER_NOOPER: return -1;
+	default: return 0;
+	}
+}
+
+Geno GenMan::Validate(const Geno& geny)
+{
+	char format=geny.getFormat();
+	GenoOperators *gf=getGeno_f(format);
+	if (gf==NULL)
+		return Geno(SString::empty(),-1,SString::empty(),SString::sprintf("GENOPER_NOOPER: Validate(): don't know how to handle genetic format %c",format));
+	char *g2=strdup(geny.getGene()); //copy for validation
+	int res=gf->validate(g2);
+	SString sg2=g2;
+	free(g2);
+	if (res==GENOPER_OK)
+		return Geno(sg2,format,geny.getName(),geny.getComment());
+	else
+		return Geno(SString::empty(),-1,SString::empty(),SString::sprintf("GENOPER_NOOPER: validate() for format %c returned invalid value",format));
+}
+
+Geno GenMan::Mutate(const Geno& g)
+{
+	float chg; //how many changes
+	int method; //mutation method
+	char format=g.getFormat();
+	GenoOperators *gf=getGeno_f(format);
+	if (gf==NULL)
+		return Geno(SString::empty(),-1,SString::empty(),SString::sprintf("GENOPER_NOOPER: Mutate(): don't know how to handle genetic format %c",format));
+	Geno gv=g;
+	bool canvalidate=true;
+	if (testValidity(gv,canvalidate)>0 && canvalidate==false)
+		return Geno("",-1,"","GENOPER_OPFAIL: Mutate(): cannot validate invalid source genotype");
+	bool ok=false;
+	int pcount=count;
+	while (!ok)
+	{
+		char *gn=strdup(gv.getGene()); //copy for mutation
+		chg=0;
+		if (gf->mutate(gn,chg,method)==GENOPER_OK)
+		{
+			ErrorHandler eh(ErrorHandler::StoreFirstMessage); //mute testValidity()
+			Geno G(gn,gv.getFormat(),"","");
+			canvalidate=true;
+			int res=testValidity(G,canvalidate);
+			if (res==GENOPER_OK && canvalidate==false) {valid_m++; ok=true;} else
+				if (res>0 && canvalidate==false) invalid_m++; else
+				{validated_m++; ok=true;}
+				if (ok) gv=G;
+		} else failed_m++;
+		free(gn);
+		count++;
+		if (!ok && (count-pcount>100))
+		{
+			FMprintf("GenMan","Mutate",2,"Tried 100x and failed: %s",(const char*)g.getGene());
+			return Geno("",-1,"","GENOPER_OPFAIL: Mutate() tried 100x and failed");
+		}
+	}
+	mutchg+=chg;
+	if (history) saveLink((const char*)g.getGene(),(const char*)gv.getGene(),chg);
+	SString mutinfo;
+	if (extmutinfo == 0) mutinfo = SString::sprintf("%.2f%% mutation of '%s'",100*chg,(const char*)g.getName()); else
+		if (extmutinfo == 1) mutinfo = SString::sprintf("%.2f%% mutation(%d) of '%s'", 100 * chg, method, (const char*)g.getName()); else
+			mutinfo = SString::sprintf("%.2f%% mutation(%s) of '%s'", 100 * chg, gf->mutation_method_names ? gf->mutation_method_names[method] : "unspecified method name", (const char*)g.getName());
+	gv.setComment(mutinfo);
+	return gv;
+}
+
+Geno GenMan::CrossOver(const Geno& g1, const Geno& g2)
+{
+	char format = g1.getFormat();
+	if (format != g2.getFormat()) return Geno(SString::empty(), -1, SString::empty(), SString::sprintf("GENOPER_NOOPER: CrossOver() does not know how to handle parents with differing genetic formats (%c and %c)", format, g2.getFormat()));
+	GenoOperators *gf = getGeno_f(format);
+	if (gf == NULL)
+		return Geno(SString::empty(), -1, SString::empty(), SString::sprintf("GENOPER_NOOPER: CrossOver(): don't know how to handle genetic format %c", format));
+	Geno g1v = g1, g2v = g2;
+
+	{
+		ErrorHandler eh(ErrorHandler::StoreFirstMessage); //mute testValidity()
+		bool canvalidate = true;
+		if (testValidity(g1v, canvalidate) > 0 && canvalidate == false)
+			return Geno("", -1, "", "GENOPER_OPFAIL: CrossOver(): cannot validate invalid source genotype #1");
+		canvalidate = true;
+		if (testValidity(g2v, canvalidate) > 0 && canvalidate == false)
+			return Geno("", -1, "", "GENOPER_OPFAIL: CrossOver(): cannot validate invalid source genotype #2");
+	}
+
+	float chg;
+	bool ok = false;
+	int pcount = count;
+
+	while (!ok)
+	{
+		float chg1, chg2;
+		char *g1n = strdup(g1.getGene()); //copy for crossover
+		char *g2n = strdup(g2.getGene()); //copy for crossover
+		chg1 = chg2 = 0;
+		if (gf->crossOver(g1n, g2n, chg1, chg2) == GENOPER_OK)
+		{
+			char *gn;
+			if (g1n[0] && g2n[0]) if (randomN(2) == 0) g1n[0] = 0; else g2n[0] = 0; //we want only one
+			if (g1n[0]) { gn = g1n; chg = chg1; }
+			else { gn = g2n; chg = chg2; }
+			ErrorHandler eh(ErrorHandler::StoreFirstMessage); //mute testValidity()
+			Geno G(gn, g1v.getFormat(), "", "");
+			bool canvalidate = true;
+			int res = testValidity(G, canvalidate);
+			if (res == GENOPER_OK && canvalidate == false) { valid_xo++; ok = true; }
+			else
+				if (res > 0 && canvalidate == false) invalid_xo++; else
+				{
+					validated_xo++; ok = true;
+				}
+			if (ok) g1v = G;
+		}
+		else failed_xo++;
+		free(g1n);
+		free(g2n);
+		count++;
+		if (!ok && (count - pcount > 100))
+		{
+			FMprintf("GenMan", "CrossOver", 2, "Tried 100x and failed: %s and %s", (const char*)g1.getGene(), (const char*)g2.getGene());
+			return Geno("", -1, "", "GENOPER_OPFAIL: CrossOver() tried 100x and failed");
+		}
+	}
+	// result in g1v
+	xochg += chg;
+	if (history) saveLink((const char*)g1.getGene(), (const char*)g1v.getGene(), chg);
+	SString xoinfo = SString::sprintf("Crossing over of '%s' (%.2f%%) and '%s' (%.2f%%)",
+		(const char*)g1.getName(), 100 * chg, (const char*)g2.getName(), 100 * (1 - chg));
+	g1v.setComment(xoinfo);
+	return g1v;
+}
+
+float GenMan::Similarity(const Geno& g1, const Geno& g2)
+{
+	char format = g1.getFormat();
+	if (format != g2.getFormat()) return GENOPER_NOOPER;
+	GenoOperators *gf = getGeno_f(format);
+	if (!gf) return GENOPER_NOOPER; else return gf->similarity(g1.getGene(), g2.getGene());
+}
+
+unsigned long GenMan::Style(const char *g, int pos)
+{
+	Geno G(g);
+	if ((pos = G.mapStringToGen(pos)) == -1) return GENSTYLE_COMMENT;
+	GenoOperators *gf = getGeno_f(G.getFormat());
+	if (!gf) return GENSTYLE_CS(0, 0); //black & valid
+	else return gf->style(G.getGene(), pos);
+}
+
+void GenMan::GetFullStyle(const char *g, unsigned long *styletab)
+{
+	Geno G(g);
+	GenoOperators *gf = getGeno_f(G.getFormat());
+	SString geny = G.getGene();
+	for (unsigned int pos = 0; pos < strlen(g); pos++)
+	{
+		int posmapped = G.mapStringToGen(pos);
+		if (posmapped == -1) styletab[pos] = GENSTYLE_COMMENT;
+		else if (!gf) styletab[pos] = GENSTYLE_CS(0, 0); //black & valid
+		else styletab[pos] = gf->style(geny, posmapped);
+	}
+}
+
+SString GenMan::HTMLize(const char *g) { return HTMLize(g, false); }
+
+SString GenMan::HTMLizeShort(const char *g) { return HTMLize(g, true); }
+
+SString GenMan::HTMLize(const char *g, bool shorten)
+{
+	char buf[50];
+	int len = strlen(g);
+	int chars = 0, lines = 0;
+	bool shortened = false;
+	unsigned long *styletab = new unsigned long[len];
+	GetFullStyle(g, styletab);
+	SString html = "\n<div style=\"background:white;padding:0.2em;font-family:arial,helvetica,sans-serif;font-size:90%\">";
+	unsigned long prevstyle, prevcolor, style = 0, color = 0;
+	for (int i = 0; i<len; i++)
+	{
+		if (shorten && ((lines == 0 && chars>160) || (lines > 5 || chars > 300))) { shortened = true; break; }
+		if (g[i] == '\r') continue;
+		if (g[i] == '\n') { html += "<br>\n"; lines++; continue; }
+		chars++;
+		prevstyle = style;
+		prevcolor = color;
+		style = GENGETSTYLE(styletab[i]);
+		color = GENGETCOLOR(styletab[i]);
+		if ((i != 0 && (color != prevcolor))) html += "</font>";
+		if ((style&GENSTYLE_INVALID) != (prevstyle&GENSTYLE_INVALID))
+		{
+			html += "<"; if (!(style&GENSTYLE_INVALID)) html += "/"; html += "u>";
+		}
+		if ((style&GENSTYLE_BOLD) != (prevstyle&GENSTYLE_BOLD))
+		{
+			html += "<"; if (!(style&GENSTYLE_BOLD)) html += "/"; html += "b>";
+		}
+		if ((style&GENSTYLE_ITALIC) != (prevstyle&GENSTYLE_ITALIC))
+		{
+			html += "<"; if (!(style&GENSTYLE_ITALIC)) html += "/"; html += "i>";
+		}
+		if ((i == 0 || (color != prevcolor)))
+		{
+			sprintf(buf, "<font color=#%02x%02x%02x>", GENGET_R(color), GENGET_G(color), GENGET_B(color)); html += buf;
+		}
+		if (g[i] == '<') html += "&lt;"; else if (g[i] == '>') html += "&gt;"; else html += g[i];
+		if ((i % 3) == 0 && g[i] == ' ') html += "\n"; //for readability, insert some newlines into html...
+	}
+	delete[] styletab;
+	html += "</u></b></i></font>";
+	if (shortened) html += " [etc...]";
+	html += "</div>\n";
+	return html;
+}
+
+void GenMan::p_htmlize(ExtValue *args, ExtValue *ret)
+{
+	ret->setString(HTMLize(args->getString()));
+}
+
+void GenMan::p_htmlizeshort(ExtValue *args, ExtValue *ret)
+{
+	ret->setString(HTMLizeShort(args->getString()));
+}
+
+Geno GenMan::GetSimplest(char format)
+{
+	GenoOperators *gf = getGeno_f(format);
+	if (!gf) return Geno();
+	SString info = "The simplest genotype of format f"; info += format;
+	info += " for operators '"; info += gf->name; info += "'.";
+	return Geno(gf->getSimplest(), format, "Root", (const char*)info);
+}
+
+void GenMan::p_getsimplest(ExtValue *args, ExtValue *ret)
+{
+	int format = args[0].getInt() + 48;
+	if (!getGeno_f(format))
+		ret->setEmpty();
+	else
+		*ret = GenoObj::makeDynamicObjectAndDecRef(new Geno(GetSimplest(format)));
+}
+
+const char *GenMan::GetOpName(char format)
+{
+	GenoOperators *gf = getGeno_f(format);
+	if (!gf) return "n/a"; else return gf->name;
+}
+
+GenoOperators* GenMan::getGeno_f(char format)
+{
+	int ind = operformats.find(format);
+	if (ind == -1) return NULL;
+	int ktoryopformatu = seloper[ind];
+	for (unsigned int i = 0; i < geno_fx_list.size(); i++)
+		if (geno_fx_list[i]->supported_format == format)
+			if (ktoryopformatu == 0) return geno_fx_list[i]; else ktoryopformatu--;
+	return NULL; //should never happen
+}
+
+void GenMan::saveLink(string prz, string pot, float& chg)
+{
+	GenoLink l;
+	l.count = count;
+	l.g1 = prz;
+	l.g2 = pot;
+	l.chg = chg;
+	l.fit = 0; //temporarily. Will be set when the genotype dies
+	GenoLinkList.push_back(l);
+}
+
+void GenMan::onDelGen(void *obj, long n)
+{
+	//old code needs update:
+	//   ((SpeciesList*)obj)->przyDodaniu(i);
+	/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+	   GenMan *gm=(GenMan*)obj;
+	   Genotype *gt=(Genotype*)(*listaGen)(n); //there is no more "listaGen"
+	   string g=(const char*)gt->genotype.getGene();
+	   float fit=gt->getFinalFitness();
+	   for(int i=0;i<gm->GenoLinkList.size();i++) //find genotype
+	   if (gm->GenoLinkList[i].g1==g) {gm->GenoLinkList[i].fit=fit; break;}
+	   */
+}
+
+void GenMan::clearStats()
+{
+	count = 0;
+	valid_m = valid_xo = validated_m = validated_xo = invalid_m = invalid_xo = failed_m = failed_xo = 0;
+	mutchg = xochg = 0;
+	GenoLinkList.clear();
+}
+
+void GenMan::p_clearStats(ExtValue *args, ExtValue *ret) { clearStats(); }
+
+void GenMan::p_report(ExtValue *args, ExtValue *ret)
+{                      //should be updated to handle multiple operators for a single format
+	char *g, *g2;
+	float f; int m;
+	FramMessage("GenMan", "Report", "The following genetic operators are available:", 0);
+	for (unsigned int i = 0; i < geno_fx_list.size(); i++)
+	{
+		SString l;
+		if (geno_fx_list[i]->checkValidity("") != GENOPER_NOOPER) l += " checkValidity";
+		if (geno_fx_list[i]->getSimplest())
+		{
+			g = strdup(geno_fx_list[i]->getSimplest());
+			g2 = strdup(g);
+			if (geno_fx_list[i]->validate(g) != GENOPER_NOOPER) l += " validate";
+			if (geno_fx_list[i]->mutate(g, f, m) != GENOPER_NOOPER) l += " mutate";
+			if (geno_fx_list[i]->crossOver(g, g2, f, f) != GENOPER_NOOPER) l += " crossover";
+			l += " getSimplest";
+			free(g); free(g2);
+		}
+		//      if (geno_fx_list[i]->similarity("","")!=GENOPER_NOOPER) l+=" similarity";
+		FMprintf("GenMan", "Report", 0, "format f%c (%s):%s",
+			geno_fx_list[i]->supported_format, (const char*)geno_fx_list[i]->name, (const char*)l);
+	}
+}
+
+void GenMan::p_validate(ExtValue *args, ExtValue *ret)
+{
+	Geno *g = GenoObj::fromObject(args[0]);
+	if (g == NULL)
+		ret->setEmpty();
+	else
+		*ret = GenoObj::makeDynamicObjectAndDecRef(new Geno(Validate(*g)));
+}
+
+void GenMan::p_mutate(ExtValue *args, ExtValue *ret)
+{
+	Geno *g = GenoObj::fromObject(args[0]);
+	if (g == NULL)
+		ret->setEmpty();
+	else
+		*ret = GenoObj::makeDynamicObjectAndDecRef(new Geno(Mutate(*g)));
+}
+
+void GenMan::p_crossover(ExtValue *args, ExtValue *ret)
+{
+	Geno *g1 = GenoObj::fromObject(args[1]);
+	Geno *g2 = GenoObj::fromObject(args[0]);
+	if (g1 == NULL || g2 == NULL)
+		ret->setEmpty();
+	else
+		*ret = GenoObj::makeDynamicObjectAndDecRef(new Geno(CrossOver(*g1, *g2)));
+}
Index: cpp/frams/genetics/genman.h
===================================================================
--- cpp/frams/genetics/genman.h	(revision 138)
+++ cpp/frams/genetics/genman.h	(revision 138)
@@ -0,0 +1,89 @@
+// This file is a part of the Framsticks GDK.
+// Copyright (C) 2002-2014  Maciej Komosinski and Szymon Ulatowski.  See LICENSE.txt for details.
+// Refer to http://www.framsticks.com/ for further information.
+
+#ifndef _GENMAN_H_
+#define _GENMAN_H_
+
+#include <common/nonstd.h>
+#include <frams/param/mutableparam.h>
+#include <frams/param/mutparamlist.h>
+#include <frams/neuro/geneticneuroparam.h>
+#include "geno.h"
+#include "oper_fx.h"
+#include <string>
+#include <vector>
+
+#define GENSTYLE_COMMENT GENSTYLE_RGBS(0,150,0,GENSTYLE_BOLD)
+
+struct GenoLink
+{
+	int count;
+	std::string g1, g2;
+	float chg;
+	float fit;
+};
+
+class GenMan : public GenoValidator
+{
+public:
+	GenMan();
+	~GenMan();
+	void setDefaults();
+	/**
+	if canvalidate==false, returns GENOPER_NOOPER (cannot test), GENOPER_OK (\e g is valid), or 1-based error position.
+	if canvalidate==true, returns
+	- GENOPER_OK and canvalidate==false if \e g was already valid
+	- GENOPER_NOOPER and canvalidate==false if \e g was (probably) validated but couldn't checkValidity
+	- 1-based error position and canvalidate==false if \e g was invalid and couldn't validate
+	- 1-based error position and canvalidate==true if \e g was invalid and was validated successfully
+
+	Note: 1-based error position is always related to pure genotype (g.GetGene()), without the leading comment
+	*/
+	int testValidity(Geno &g, bool &canvalidate);
+	int testGenoValidity(Geno& g); //class GenoValidator (geno.h)
+	Geno Validate(const Geno&); ///<returns validated (if possible) genotype
+	Geno Mutate(const Geno&); //returns mutated genotype or empty if errors
+	Geno CrossOver(const Geno&, const Geno&); //returns xover genotype ("child") or empty if errors
+	float Similarity(const Geno&, const Geno&); //returns GENOPER_NOOPER or normalized similarity (1: identical, 0: different)
+	unsigned long Style(const char* g, int pos); //returns Style (and validity) of a genotype char.
+	void GetFullStyle(const char *g, unsigned long *styletab); //optimized. Fills styletab with styles for all genotype chars. sizeof(*styletab) must be at least strlen(g).
+	SString HTMLize(const char *g); //returns colored genotype in HTML.
+	SString HTMLizeShort(const char *g); //returns colored genotype (abbreviated if needed) in HTML.
+	Geno GetSimplest(char format); ///<returns pointer to the simplest genotype of \e format or empty Geno()
+	const char *GetOpName(char format); ///<returns pointer to the active operator set for \e format
+private:
+	std::vector<GenoOperators*> geno_fx_list;
+	void saveLink(std::string prz, std::string pot, float& chg);
+	GenoOperators* getGeno_f(char format);
+	SString HTMLize(const char *g, bool shorten);
+public:
+	std::vector<GenoLink> GenoLinkList;
+	int history; //remember history?
+	int hilite; //syntax highlighting (Style)
+	int extmutinfo; //extended info: the info field of the genotype will contain the name of the mutation method
+	int count; //# of the last genetic operation
+	int valid_m, valid_xo, validated_m, validated_xo, invalid_m, invalid_xo, failed_m, failed_xo;
+	double mutchg, xochg;
+	SListTempl<char> operformats; //the list of supported_format, in the order same as in seloperpar
+	int* seloper; //fields for seloperpar
+	Param localpar, localstats;
+	MutableParam seloperpar;
+	GeneticNeuroParam neuronsparam;
+	MutableParamList par;
+#define STATRICKCLASS GenMan
+	PARAMPROCDEF(p_clearStats);
+	PARAMPROCDEF(p_report);
+	PARAMPROCDEF(p_htmlize);
+	PARAMPROCDEF(p_htmlizeshort);
+	PARAMPROCDEF(p_validate);
+	PARAMPROCDEF(p_mutate);
+	PARAMPROCDEF(p_crossover);
+	PARAMPROCDEF(p_getsimplest);
+#undef STATRICKCLASS
+	void clearStats();
+	static void onDelGen(void*, long);
+};
+
+
+#endif
Index: cpp/frams/model/autoname.cpp
===================================================================
--- cpp/frams/model/autoname.cpp	(revision 138)
+++ cpp/frams/model/autoname.cpp	(revision 138)
@@ -0,0 +1,131 @@
+// This file is a part of the Framsticks GDK.
+// Copyright (C) 2002-2014  Maciej Komosinski and Szymon Ulatowski.  See LICENSE.txt for details.
+// Refer to http://www.framsticks.com/ for further information.
+
+#include "autoname.h"
+#include "common/nonstd_stl.h"
+#include <ctype.h>
+
+SString AutoName::makeName(Model &model)
+{
+SString t;
+t=firstName(model);
+t+=' ';
+t+=lastName(model);
+return t;
+}
+
+///////////////////////////
+
+static char* cat_syl(char* str,unsigned int x)
+{
+static char sp[]="bcdfghklmnprstwz",sa[]="aeiouy";
+x%=6*16;
+str[0]=sa[x%6];
+if (x>5)
+	{str[1]=sp[x/6]; str[2]=0; return str+2;}
+else
+	{str[1]=0; return str+1;}
+}
+
+SString AutoName::firstName(Model& model)
+{
+char buf[8];
+unsigned int s1=0,s2=0,s3=0;
+const char *x=model.getGeno().getGene();
+for (;*x;x++) { s1+=*x; s2=s2**x+*x; s3=(s3^*x)+*x; }
+char* t=buf;
+t=cat_syl(t,s1);
+t=cat_syl(t,s2);
+t=cat_syl(t,s3);
+buf[0]=(char)toupper(buf[0]);
+return SString(buf);
+}
+
+static void przeplatanka(char *out,char *in1,char *in2)
+{
+int d1=strlen(in1),d2=strlen(in2);
+int p1=0,p2=0;
+int pp=d1+d2;
+int i,p;
+if (d2<d1)
+	{
+	int t=d2; d2=d1; d1=t;
+	char *c=in1; in1=in2; in2=c;
+	}
+if (pp)
+for (i=0;i<=pp;i++)
+	{
+	p=(i*d1)/pp-1; for (;p1<=p;p1++) *(out++)=*(in1++);
+	p=(i*d2)/pp-1; for (;p2<=p;p2++) *(out++)=*(in2++);
+	}
+*out=0;
+}
+
+SString AutoName::lastName(Model& model)
+{
+char Sam[]="yeaou";
+char Sp[]="shtkdgmr";
+
+#define NAME_MAXLENBODY 5
+#define NAME_MAXLENBRAIN 5
+#define NAME_BODYLEN 0.8
+#define NAME_BRAINLEN 0.8
+#define NAME_BODYMASS 1.0
+#define NAME_BRAININP 1.0
+
+char naz[NAME_MAXLENBODY+NAME_MAXLENBRAIN+1];
+int poz,nextpoz,i;
+
+double w;
+int cialo=-1;
+int mozg=-1;
+
+char tmpc[NAME_MAXLENBODY+1],tmpm[NAME_MAXLENBRAIN+1];
+
+if (model.getPartCount()>0)
+{
+cialo=min((int)(sqrt(double(model.getPartCount())-1)*NAME_BODYLEN),NAME_MAXLENBODY-1);
+poz=0;
+for (i=0;i<=cialo;i++) // budowanie "opisu" ciala
+	{
+	nextpoz=((model.getPartCount())*(i+1))/(cialo+1)-1;
+	w=1.0;
+	for (;poz<=nextpoz;poz++) w=max(w,model.getPart(poz)->mass);
+	tmpc[i]=Sp[min(int((w-1.0)*NAME_BODYMASS),int(sizeof(Sp))-2)];
+	}
+tmpc[i]=0;
+}
+else tmpc[0]=0;
+
+int wint;
+
+if (model.getNeuroCount()>0)
+{
+mozg=min((int)(sqrt((double)model.getNeuroCount())*NAME_BRAINLEN),NAME_MAXLENBRAIN-1);
+poz=0;
+for (i=0;i<=mozg;i++) // budowanie "opisu" mozgu
+	{
+	nextpoz=(model.getNeuroCount()*(i+1))/(mozg+1)-1;
+	wint=0;
+	for (;poz<=nextpoz;poz++) wint=max(wint,model.getNeuro(poz)->getInputCount());
+	tmpm[i]=Sam[min(int(wint*NAME_BRAININP),int(sizeof(Sam))-2)];
+	}
+tmpm[i]=0;
+}
+else tmpm[0]=0;
+
+if ((mozg+1) < ((cialo+2)/2))
+	{
+	for (i=mozg+1;i<=cialo/2;i++) tmpm[i]='i';
+	tmpm[i]=0;
+	}
+
+przeplatanka(naz,tmpc,tmpm);
+
+naz[0]=(char)toupper(naz[0]);
+return SString(naz);
+}
+
+
+
Index: cpp/frams/model/autoname.h
===================================================================
--- cpp/frams/model/autoname.h	(revision 138)
+++ cpp/frams/model/autoname.h	(revision 138)
@@ -0,0 +1,20 @@
+// This file is a part of the Framsticks GDK.
+// Copyright (C) 2002-2014  Maciej Komosinski and Szymon Ulatowski.  See LICENSE.txt for details.
+// Refer to http://www.framsticks.com/ for further information.
+
+#ifndef _AUTONAME_H_
+#define _AUTONAME_H_
+
+#include <frams/model/model.h>
+
+/// generate human readable (and human like-able) name for the model
+class AutoName
+{
+static SString firstName(Model&);
+static SString lastName(Model&);
+public:
+static SString makeName(Model&);
+};
+
+#endif
+
Index: cpp/frams/neuro/geneticneuroparam.cpp
===================================================================
--- cpp/frams/neuro/geneticneuroparam.cpp	(revision 138)
+++ cpp/frams/neuro/geneticneuroparam.cpp	(revision 138)
@@ -0,0 +1,18 @@
+// This file is a part of the Framsticks GDK.
+// Copyright (C) 2002-2014  Maciej Komosinski and Szymon Ulatowski.  See LICENSE.txt for details.
+// Refer to http://www.framsticks.com/ for further information.
+
+#include "geneticneuroparam.h"
+#include <frams/neuro/neurolibrary.h>
+
+GeneticNeuroParam::GeneticNeuroParam(const char* groupname,const char* myname,
+				   const char* prefix,const char* typ)
+	:NeuroLibParam(groupname,myname,prefix),types(typ)
+{}
+
+long GeneticNeuroParam::getInt(int i)
+{return Neuro::getClass(i)->genactive;}
+
+int GeneticNeuroParam::setInt(int i,long v)
+{Neuro::getClass(i)->genactive=v;return PSET_CHANGED;}
+
Index: cpp/frams/neuro/geneticneuroparam.h
===================================================================
--- cpp/frams/neuro/geneticneuroparam.h	(revision 138)
+++ cpp/frams/neuro/geneticneuroparam.h	(revision 138)
@@ -0,0 +1,22 @@
+// This file is a part of the Framsticks GDK.
+// Copyright (C) 2002-2014  Maciej Komosinski and Szymon Ulatowski.  See LICENSE.txt for details.
+// Refer to http://www.framsticks.com/ for further information.
+
+#ifndef _GENETICNEUROPARAM_H_
+#define _GENETICNEUROPARAM_H_
+
+#include "neurolibparam.h"
+
+class GeneticNeuroParam: public NeuroLibParam
+{
+  protected:
+const char* types;
+  public:
+GeneticNeuroParam(const char* groupname,const char* myname, const char* prefix,const char* typ=0);
+
+long getInt(int i);
+int setInt(int i,long v);
+const char *type(int i) {return types?types:NeuroLibParam::type(i);}
+};
+
+#endif
Index: cpp/frams/neuro/neurolibparam.cpp
===================================================================
--- cpp/frams/neuro/neurolibparam.cpp	(revision 138)
+++ cpp/frams/neuro/neurolibparam.cpp	(revision 138)
@@ -0,0 +1,78 @@
+// This file is a part of the Framsticks GDK.
+// Copyright (C) 2002-2014  Maciej Komosinski and Szymon Ulatowski.  See LICENSE.txt for details.
+// Refer to http://www.framsticks.com/ for further information.
+
+#include <ctype.h>
+#include "neurolibparam.h"
+#include <frams/neuro/neurolibrary.h>
+
+NeuroLibParam::NeuroLibParam(const char* gr, const char* name, const char* pref)
+	:mygroup(gr),myname(name),myprefix(pref)
+{
+anode=NeuroLibrary::staticlibrary.classes.l_add.add(
+	STATRICKCALLBACK(this,&NeuroLibParam::neuroclassAdded,0));
+dnode=NeuroLibrary::staticlibrary.classes.l_postdel.add(
+	STATRICKCALLBACK(this,&NeuroLibParam::neuroclassRemoved,0));
+}
+
+NeuroLibParam::~NeuroLibParam()
+{
+NeuroLibrary::staticlibrary.classes.l_add.removeNode(anode);// remove(anode) tez powinno byc ok - do sprawdzenia
+NeuroLibrary::staticlibrary.classes.l_postdel.removeNode(dnode);
+}
+
+void NeuroLibParam::neuroclassAdded(void* data,long i)
+{onadd.action(i);}
+void NeuroLibParam::neuroclassRemoved(void* data,long i)
+{ondelete.action(i);}
+
+static bool isGoodName(const SString& name)
+{
+for(int i=0;i<name.len();i++)
+	if (!isalnum(name[i])) return false;
+return true;
+}
+
+const char *NeuroLibParam::id(int i)
+{
+static SString t;
+if (i>=Neuro::getClassCount()) return 0;
+t=myprefix;
+SString n=Neuro::getClass(i)->getName();
+if (isGoodName(n))
+	t+=n;
+else
+	{//jezeli w nazwie klasy neuronu sa "dziwne" znaki to zamiast tego uzywamy long name
+	// * -> Constant, | -> Bend_muscle, @ -> Rotation_muscle
+	n=Neuro::getClass(i)->getLongName();
+	for(char* p=n.directWrite();*p;p++)
+		if (*p==' ') *p='_';
+	n.endWrite();
+	t+=n;
+	}
+return t;
+}
+
+const char *NeuroLibParam::name(int i)
+{
+static SString t;
+t=Neuro::getClass(i)->getLongName();
+t+=" ("; t+=Neuro::getClassName(i); t+=")";
+return t;
+}
+
+const char *NeuroLibParam::help(int i)
+{
+static SString t;
+t=Neuro::getClass(i)->getSummary();
+return t;
+}
+
+int NeuroLibParam::grmember(int gi,int n)
+{
+return (gi==0)?
+	((n>=getPropCount())?-9999:n)
+	:
+	-9999;
+}
+
Index: cpp/frams/neuro/neurolibparam.h
===================================================================
--- cpp/frams/neuro/neurolibparam.h	(revision 138)
+++ cpp/frams/neuro/neurolibparam.h	(revision 138)
@@ -0,0 +1,52 @@
+// This file is a part of the Framsticks GDK.
+// Copyright (C) 2002-2014  Maciej Komosinski and Szymon Ulatowski.  See LICENSE.txt for details.
+// Refer to http://www.framsticks.com/ for further information.
+
+#ifndef _NEUROLIBPARAM_H_
+#define _NEUROLIBPARAM_H_
+
+#include <frams/param/mutparamiface.h>
+#include <frams/model/modelparts.h>
+
+class NeuroLibParam: public MutableParamInterface
+{
+const char* mygroup;
+const char* myname;
+const char* myprefix;
+CallbackNode *anode,*dnode;
+
+  public:
+NeuroLibParam(const char* gr=0, const char* name=0, const char* pref=0);
+~NeuroLibParam();
+
+#define STATRICKCLASS NeuroLibParam
+VIRTCALLBACKDEF(neuroclassAdded);
+VIRTCALLBACKDEF(neuroclassRemoved);
+#undef STATRICKCLASS
+
+int getGroupCount() {return 1;}
+int getPropCount()  {return Neuro::getClassCount();}
+
+const char* getName() {return myname;}
+const char *grname(int gi) {return (gi==0)?mygroup:0;}
+
+const char *id(int i);
+const char *name(int i);
+const char *help(int i);
+const char *type(int i) {return "d 0 1";}
+int flags(int i)        {return 0;}
+int group(int i)        {return 0;}
+int grmember(int gi,int n);
+void call(int i,ExtValue* args,ExtValue *ret) {}
+
+SString getString(int i) {return SString();}
+double getDouble(int) {return 0;}
+ExtObject getObject(int i) {return ExtObject();}
+ExtValue getExtValue(int i) {return ExtValue();}
+int setDouble(int i, double) {return 0;}
+int setString(int i, const SString &v) {return 0;}
+int setObject(int i, const ExtObject &v) {return 0;}
+int setExtValue(int i, const ExtValue &v) {return 0;}
+};
+
+#endif
Index: cpp/frams/param/mutableparam.cpp
===================================================================
--- cpp/frams/param/mutableparam.cpp	(revision 138)
+++ cpp/frams/param/mutableparam.cpp	(revision 138)
@@ -0,0 +1,291 @@
+// This file is a part of the Framsticks GDK.
+// Copyright (C) 2002-2014  Maciej Komosinski and Szymon Ulatowski.  See LICENSE.txt for details.
+// Refer to http://www.framsticks.com/ for further information.
+
+#include "mutableparam.h"
+#include <frams/util/extvalue.h>
+
+#define FIELDSTRUCT MutableParam
+ParamEntry MutableParam::pe_tab[]=
+{
+{"clear",0,PARAM_DONTSAVE+PARAM_USERHIDDEN,"remove all properties","p",PROCEDURE(p_clear),},
+{"add",0,PARAM_DONTSAVE+PARAM_USERHIDDEN,"add property (id,type,name,help)","p",PROCEDURE(p_addprop),},
+{"remove",0,PARAM_DONTSAVE+PARAM_USERHIDDEN,"remove property (index)","p",PROCEDURE(p_remprop),},
+{"addGroup",0,PARAM_DONTSAVE+PARAM_USERHIDDEN,"add group (name)","p",PROCEDURE(p_addgroup),},
+{"removeGroup",0,PARAM_DONTSAVE+PARAM_USERHIDDEN,"remove group (index)","p",PROCEDURE(p_remgroup),},
+{"changedProperty",0,PARAM_DONTSAVE+PARAM_USERHIDDEN+PARAM_READONLY,"last changed property #","d",FIELD(changed),},
+{"changedPropertyId",0,PARAM_DONTSAVE+PARAM_USERHIDDEN+PARAM_READONLY,"last changed property id","s",GETONLY(changedname),},
+};
+#undef FIELDSTRUCT
+
+MutableParam::MutableParam(const char*n,const char*g,int gr0)
+	:SimpleAbstractParam(this,n),persistgroup0(gr0),grprefix(g)
+{
+if (persistgroup0)
+	addGroup(grprefix,1);
+}
+
+int MutableParam::findGroup(const SString name,int ignoreprefix)
+{
+int skipprefix=grprefix.len()?grprefix.len()+2:0;
+for (int i=0;i<groups.size();i++)
+	{
+	if (ignoreprefix)
+		{
+      const char *noprefix=(const char*)groupname(i);
+      if ((int)strlen(noprefix) < skipprefix) continue;
+		noprefix+=skipprefix;
+		if (!strcmp(noprefix,(const char*)name)) return i;
+		}
+		else
+			if (groupname(i)==name) return i;
+	}
+return -1;
+}
+
+int MutableParam::addGroup(const SString& gname,int noprefix)
+{
+SString tmp;
+if (noprefix)
+	tmp=gname;
+else
+	{
+	tmp=grprefix;
+	if (tmp.len()) tmp+=": ";
+	tmp+=gname;
+	}
+groups+=new SString(tmp);
+int position=groups.size()-1;
+ongroupadd.action(position);
+return position;
+}
+
+void MutableParam::removeGroup(int g)
+{
+if ((g<0)||(g>=MutableParam::getGroupCount())) return;
+ParamEntry *e;
+for (int i=MutableParam::getPropCount()-1;i>=staticprops;i--)
+	{
+	e=entry(i);
+	if (g==e->group)
+		removeProperty(i);
+	}
+SString *s=(SString *)groups(g);
+if (s) delete s;
+groups-=g;
+ongroupdelete.action(g);
+}
+
+int MutableParam::grmember(int g,int a)
+{
+if (g==0)
+	{
+	if (getGroupCount()<2)
+		return (a<getPropCount())?a:-9999;
+	if (a<staticprops) return a;
+	a-=staticprops;
+	}
+ParamEntry *e;
+for (int i=staticprops;e=entry(i);i++)
+	if (g==e->group)
+		if (!a--) return i;
+return -9999;
+}
+
+int MutableParam::addProperty(ParamEntry *pe,int position)
+{
+DB(printf("MutableParam::add(%s)\n",pe->id));
+if (position<0)
+	position=entries.size()+staticprops;
+entries.insert(position-staticprops,pe);
+
+if (pe->offset)
+	pe->flags &= ~MUTPARAM_ALLOCDATA;
+else
+	{
+	pe->flags |= MUTPARAM_ALLOCDATA;
+	void *d=0;
+	switch(pe->type[0])
+		{
+		case 'd': d=new int(); *((int*)d)=0; break;
+		case 'f': d=new double(); *((double*)d)=0; break;
+		case 's': d=new SString(); break;
+		case 'x': d=new ExtValue(); break;
+		case 'o': d=new ExtObject(); break;
+		}
+	pe->offset=(int)d;
+	}
+onadd.action(position);
+return position;
+}
+
+ParamEntry * MutableParam::removeProperty(ParamEntry *pe)
+{
+   int index=entries.find(pe);
+   if (index>=0) return removeProperty(index); else return pe;
+}
+
+ParamEntry * MutableParam::removeProperty(int i)
+{
+ParamEntry *pe=(ParamEntry *)entries(i-staticprops);
+DB(printf("MutableParam::remove(%d)\n",i));
+void *d=(void*)pe->offset;
+if (d && (pe->flags & MUTPARAM_ALLOCDATA))
+	switch(pe->type[0])
+		{
+		case 'd': delete (int*)d; break;
+		case 'f': delete (double*)d; break;
+		case 's': delete (SString*)d; break;
+		case 'x': delete (ExtValue*)d; break;
+		case 'o': delete (ExtObject*)d; break;
+		}
+entries-=i-staticprops;
+if (pe->flags & MUTPARAM_ALLOCENTRY)
+	{
+	if (pe->name) free((void*)pe->name);
+	if (pe->id) free((void*)pe->id);
+	if (pe->help) free((void*)pe->help);
+	if (pe->type) free((void*)pe->type);
+	delete pe;
+	}
+ondelete.action(i);
+return pe;
+}
+
+void MutableParam::clear(int everything)
+{
+DB(printf("MutableParam::clear\n"));
+for (int i=entries.size()-1;i>=0;i--)
+	removeProperty(i+staticprops);
+int lastgroup=(everything || (persistgroup0==0))?0:1;
+for (int i=groups.size()-1;i>=lastgroup;i--)
+	removeGroup(i);
+}
+
+void MutableParam::p_clear(ExtValue *args,ExtValue *ret)
+{ clear(); }
+
+int MutableParam::addProperty(void* data,const char* id,const char* type,const char* name,const char* help,int flags,int group,int position)
+{
+if ((!id)&&(!type)) return -1;
+ParamEntry *pe=new ParamEntry();
+pe->fun1=0; pe->fun2=0;
+pe->group=(short)group;
+pe->flags=(short)(flags | MUTPARAM_ALLOCENTRY);
+pe->offset=(long)data;
+pe->id=strdup(id);
+pe->type=strdup(type);
+pe->name=name?strdup(name):0;
+pe->help=help?strdup(help):0;
+return addProperty(pe,position);
+}
+
+void MutableParam::p_addprop(ExtValue *args,ExtValue *ret)
+{
+int i=addProperty(0,args[2].getString(),args[1].getString(),args[0].getString());
+ret->setInt(i);
+}
+
+void MutableParam::p_remprop(ExtValue *args,ExtValue *ret)
+{
+removeProperty(args[0].getInt());
+}
+
+void MutableParam::p_addgroup(ExtValue *args,ExtValue *ret)
+{
+int i=addGroup(args[0].getString());
+ret->setInt(i);
+}
+
+void MutableParam::p_remgroup(ExtValue *args,ExtValue *ret)
+{
+removeGroup(args[0].getInt());
+}
+
+void MutableParam::notify(int id)
+{
+changed=id;
+onactivate.action(id);
+}
+
+int MutableParam::setInt(int i,long v)
+{
+int ret=SimpleAbstractParam::setInt(i,v);
+if (ret & PSET_CHANGED) notify(i);
+return ret;
+}
+
+int MutableParam::setDouble(int i,double v)
+{
+int ret=SimpleAbstractParam::setDouble(i,v);
+if (ret & PSET_CHANGED) notify(i);
+return ret;
+}
+
+int MutableParam::setString(int i,const SString &v)
+{
+int ret=SimpleAbstractParam::setString(i,v);
+if (ret & PSET_CHANGED) notify(i);
+return ret;
+}
+
+int MutableParam::setObject(int i,const ExtObject &v)
+{
+int ret=SimpleAbstractParam::setObject(i,v);
+if (ret & PSET_CHANGED) notify(i);
+return ret;
+}
+
+int MutableParam::setExtValue(int i,const ExtValue &v)
+{
+int ret=SimpleAbstractParam::setExtValue(i,v);
+if (ret & PSET_CHANGED) notify(i);
+return ret;
+}
+
+void MutableParam::call(int i,ExtValue* args,ExtValue *ret)
+{
+if (i<staticprops) return SimpleAbstractParam::call(i,args,ret);
+notify(i);
+}
+
+///////////////////
+
+void ParamSaver::clear()
+{
+for(int i=0;i<store.size();i+=2)
+	{
+	SString *n=(SString*)store(i);
+	ExtValue *v=(ExtValue*)store(i+1);
+	delete n;
+	delete v;
+	}	
+store.clear();
+}
+
+void ParamSaver::loadFrom(ParamInterface& p)
+{
+int N=p.getPropCount();
+for(int i=0;i<N;i++)
+	{
+	if (shouldLoad(p,i))
+		{
+		ExtValue v;
+		p.get(i,v);
+		store+=new SString(p.id(i));
+		store+=new ExtValue(v);
+		}
+	}
+}
+
+void ParamSaver::saveTo(MutableParam& p)
+{
+for(int i=0;i<store.size();i+=2)
+	{
+	SString *n=(SString*)store(i);
+	int prop=p.findId((const char*)*n);
+	if (prop<0)
+		prop=p.addProperty(0,(const char*)*n,"x",0,0,0,0,-1);
+	p.setExtValue(prop,*(ExtValue*)store(i+1));
+	}
+}
Index: cpp/frams/param/mutableparam.h
===================================================================
--- cpp/frams/param/mutableparam.h	(revision 138)
+++ cpp/frams/param/mutableparam.h	(revision 138)
@@ -0,0 +1,86 @@
+// This file is a part of the Framsticks GDK.
+// Copyright (C) 2002-2014  Maciej Komosinski and Szymon Ulatowski.  See LICENSE.txt for details.
+// Refer to http://www.framsticks.com/ for further information.
+
+#ifndef _MUTABLEPARAM_H_
+#define _MUTABLEPARAM_H_
+
+#include "mutparamiface.h"
+#include <frams/util/extvalue.h>
+#include "param.h"
+#include <frams/util/callbacks.h>
+
+class VMachine;
+class VMCode;
+
+class MutableParam: public SimpleAbstractParam, public MutableParamInterface 
+{
+static const int staticprops=7;
+static ParamEntry pe_tab[];
+/** group #0 cannot be removed by scripting  */
+int persistgroup0;
+SString grprefix;
+SList entries;
+SList groups;
+long changed;
+ParamEntry *entry(int i) {return (i<staticprops)? pe_tab+i : ((ParamEntry*)entries(i-staticprops));}
+void *getTarget(int i) {return (i<staticprops)? SimpleAbstractParam::getTarget(i) : (void*)entry(i)->offset;}
+void call(int i,ExtValue* args,ExtValue *ret);
+  public:
+void clear(int everything=0);
+int firstMutableIndex() {return staticprops;}
+SString& groupname(int g) {return *((SString*)groups(g));}
+MutableParam(const char*n=0,const char*g=0,int gr0=1);
+void setGroupName(const SString &n,int g=0) {groupname(g)=n;}
+~MutableParam() {clear(1);}
+int getGroupCount() {return groups.size();}
+int getPropCount() {return entries.size()+staticprops;}
+const char *grname(int i) {return (i>=groups.size()) ? 0 : (const char*)groupname(i);}
+int grmember(int g,int a);
+
+int addGroup(const SString& gname,int noprefix=0);
+void removeGroup(int pos);
+
+int findGroup(const SString name,int ignoreprefix=0);
+
+/** @param data pointer to the variable. 0 will allocate new variable
+    @param position -1 = after the last one  */
+int addProperty(void* data,const char* id,const char* type,const char* name,const char* help=0,int flags=0,int group=0,int position=-1);
+
+int addProperty(ParamEntry *pe,int position=-1);
+ParamEntry * removeProperty(ParamEntry *pe);
+ParamEntry * removeProperty(int i);
+
+void notify(int id);
+
+int setInt(int,long);
+int setDouble(int,double);
+int setString(int,const SString &);
+int setObject(int,const ExtObject &);
+int setExtValue(int,const ExtValue &);
+
+#define STATRICKCLASS MutableParam
+PARAMPROCDEF(p_clear);
+PARAMPROCDEF(p_addprop);
+PARAMPROCDEF(p_remprop);
+PARAMPROCDEF(p_addgroup);
+PARAMPROCDEF(p_remgroup);
+PARAMGETDEF(changedname) {arg1->setString(id(changed));}
+#undef STATRICKCLASS
+};
+
+class ParamSaver
+{
+SList store;
+  public:
+virtual bool shouldLoad(ParamInterface &pi,int i) {return true;}
+ParamSaver() {}
+ParamSaver(ParamInterface &pi) {loadFrom(pi);}
+~ParamSaver() {clear();}
+void loadFrom(ParamInterface& p);
+void saveTo(MutableParam& p);
+void clear();
+};
+
+
+#endif
Index: cpp/frams/param/mutparamiface.h
===================================================================
--- cpp/frams/param/mutparamiface.h	(revision 138)
+++ cpp/frams/param/mutparamiface.h	(revision 138)
@@ -0,0 +1,23 @@
+// This file is a part of the Framsticks GDK.
+// Copyright (C) 2002-2014  Maciej Komosinski and Szymon Ulatowski.  See LICENSE.txt for details.
+// Refer to http://www.framsticks.com/ for further information.
+
+#ifndef _MUTPARAM_H_
+#define _MUTPARAM_H_
+
+#include <frams/util/callbacks.h>
+#include "param.h"
+
+class MutableParamInterface: public virtual ParamInterface
+{
+public:
+Callback onadd;
+Callback ondelete;
+Callback onchange;
+Callback ongroupadd;
+Callback ongroupdelete;
+Callback ongroupchange;
+Callback onactivate;
+};
+
+#endif
Index: cpp/frams/param/mutparamlist.cpp
===================================================================
--- cpp/frams/param/mutparamlist.cpp	(revision 138)
+++ cpp/frams/param/mutparamlist.cpp	(revision 138)
@@ -0,0 +1,366 @@
+// This file is a part of the Framsticks GDK.
+// Copyright (C) 2002-2014  Maciej Komosinski and Szymon Ulatowski.  See LICENSE.txt for details.
+// Refer to http://www.framsticks.com/ for further information.
+
+#include "mutparamlist.h"
+#include <frams/util/extvalue.h>
+
+struct ParamInfo
+{
+ParamInterface *pi;
+MutableParamInterface *mpi;
+CallbackNode *anode,*dnode,*ganode,*gdnode,*cnode,*gcnode,*panode;
+int firstprop, firstgroup;
+int propcount, groupcount;
+};
+
+ParamInfo* MutableParamList::getParamInfo(int i)
+{
+return (ParamInfo*)list(i);
+}
+
+void MutableParamList::addPI(int pos,ParamInfo *pi)
+{
+int propcount=pi->propcount;
+int groupcount=pi->groupcount;
+if (pos==0)
+	{ pi->firstprop=0; pi->firstgroup=0; }
+else
+	{
+	ParamInfo *prev_pi=getParamInfo(pos-1);
+	pi->firstprop=prev_pi->firstprop+prev_pi->propcount;
+	pi->firstgroup=prev_pi->firstgroup+prev_pi->groupcount;
+	}
+list.insert(pos,pi);
+pi->propcount=0;
+pi->groupcount=0;
+for (int i=0;i<groupcount;i++)
+	{
+	pi->groupcount=i+1;
+	adjustPI(pos+1,0,1);
+	ongroupadd.action(pi->firstgroup+i);
+	}
+for (int i=0;i<propcount;i++)
+	{
+	pi->propcount=i+1;
+	adjustPI(pos+1,1,0);
+	onadd.action(pi->firstprop+i);
+	}
+if (pi->mpi)
+	{
+	pi->anode=pi->mpi->onadd.add(STATRICKCALLBACK(this,&MutableParamList::onPropAdd,pi));
+	pi->ganode=pi->mpi->ongroupadd.add(STATRICKCALLBACK(this,&MutableParamList::onGroupAdd,pi));
+	pi->dnode=pi->mpi->ondelete.add(STATRICKCALLBACK(this,&MutableParamList::onPropDelete,pi));
+	pi->gdnode=pi->mpi->ongroupdelete.add(STATRICKCALLBACK(this,&MutableParamList::onGroupDelete,pi));
+	pi->cnode=pi->mpi->onchange.add(STATRICKCALLBACK(this,&MutableParamList::onPropChange,pi));
+	pi->gcnode=pi->mpi->ongroupchange.add(STATRICKCALLBACK(this,&MutableParamList::onGroupChange,pi));
+	pi->panode=pi->mpi->onactivate.add(STATRICKCALLBACK(this,&MutableParamList::onPropActivate,pi));
+	}
+}
+
+int MutableParamList::findPI(ParamInfo *pi)
+{
+return list.find((void*)pi);
+}
+
+int MutableParamList::findPI(ParamInterface *p)
+{
+ParamInfo *pi;
+for(int i=0;pi=(ParamInfo*)list(i);i++)
+	if ((!pi->mpi)&&(pi->pi==p)) return i;
+return -1;
+}
+
+int MutableParamList::findPI(MutableParamInterface *p)
+{
+ParamInfo *pi;
+for(int i=0;pi=(ParamInfo*)list(i);i++)
+	if ((pi->mpi)&&(pi->mpi==p)) return i;
+return -1;
+}
+
+void MutableParamList::adjustPI(int firstPI,int addprop,int addgroup)
+{
+ParamInfo *pi;
+for (int i=firstPI;pi=getParamInfo(i);i++)
+	{
+	pi->firstprop+=addprop;
+	pi->firstgroup+=addgroup;
+	}
+}
+
+void MutableParamList::removePI(int pi_index)
+{
+if (pi_index<0) return;
+ParamInfo *pi=getParamInfo(pi_index);
+for (int i=pi->propcount-1;i>=0;i--)
+	{
+	pi->propcount=i;
+	adjustPI(pi_index+1,-1,0);
+	ondelete.action(i);
+	}
+for (int i=pi->groupcount-1;i>=0;i--)
+	{
+	pi->groupcount=i;
+	adjustPI(pi_index+1,0,-1);
+	ongroupdelete.action(i);
+	}
+list-=(pi_index);
+if (pi->mpi)
+	{
+	pi->mpi->onadd.remove(pi->anode);
+	pi->mpi->ongroupadd.remove(pi->ganode);
+	pi->mpi->ondelete.remove(pi->dnode);
+	pi->mpi->ongroupdelete.remove(pi->gdnode);
+	pi->mpi->onchange.remove(pi->cnode);
+	pi->mpi->ongroupchange.remove(pi->gcnode);
+	pi->mpi->onactivate.remove(pi->panode);
+	}
+delete pi;
+}
+
+MutableParamList::~MutableParamList()
+{
+for (int i=list.size()-1;i>=0;i--)
+	removePI(i);
+}
+
+void MutableParamList::onPropAdd(void* data,long i)
+{
+ParamInfo *pi=(ParamInfo*)data;
+pi->propcount++;
+int j=findPI(pi);
+if (j>=0)
+	adjustPI(j+1,1,0);
+onadd.action(pi->firstprop+i);
+}
+
+void MutableParamList::onPropDelete(void* data,long i)
+{
+ParamInfo *pi=(ParamInfo*)data;
+pi->propcount--;
+int j=findPI(pi);
+if (j>=0)
+	adjustPI(j+1,-1,0);
+ondelete.action(pi->firstprop+i);
+}
+
+void MutableParamList::onPropChange(void* data,long i)
+{
+ParamInfo *pi=(ParamInfo*)data;
+onchange.action(pi->firstprop+i);
+}
+
+void MutableParamList::onPropActivate(void* data,long i)
+{
+ParamInfo *pi=(ParamInfo*)data;
+onactivate.action(pi->firstprop+i);
+}
+
+void MutableParamList::onGroupAdd(void* data,long i)
+{
+ParamInfo *pi=(ParamInfo*)data;
+pi->groupcount++;
+int j=findPI(pi);
+if (j>=0)
+	adjustPI(j+1,0,1);
+ongroupadd.action(pi->firstgroup+i);
+}
+
+void MutableParamList::onGroupDelete(void* data,long i)
+{
+ParamInfo *pi=(ParamInfo*)data;
+pi->groupcount--;
+int j=findPI(pi);
+if (j>=0)
+	adjustPI(j+1,0,-1);
+ongroupdelete.action(pi->firstgroup+i);
+}
+
+void MutableParamList::onGroupChange(void* data,long i)
+{
+ParamInfo *pi=(ParamInfo*)data;
+ongroupchange.action(pi->firstgroup+i);
+}
+
+void MutableParamList::insert(int pos,MutableParamInterface *p)
+{
+ParamInfo *pi=new ParamInfo();
+pi->pi=(ParamInterface*)p;
+pi->mpi=p;
+pi->propcount=p->getPropCount();
+pi->groupcount=p->getGroupCount();
+addPI(pos,pi);
+}
+
+void MutableParamList::insert(int pos,ParamInterface *p)
+{
+ParamInfo *pi=new ParamInfo();
+pi->pi=p;
+pi->mpi=0;
+pi->propcount=p->getPropCount();
+pi->groupcount=p->getGroupCount();
+addPI(pos,pi);
+}
+
+
+void MutableParamList::operator+=(ParamInterface *p)
+{
+insert(list.size(),p);
+}
+
+void MutableParamList::operator+=(MutableParamInterface *p)
+{
+insert(list.size(),p);
+}
+
+
+void MutableParamList::operator-=(ParamInterface *p)
+{
+int i=findPI(p);
+removePI(i);
+}
+
+void MutableParamList::operator-=(MutableParamInterface *p)
+{
+int i=findPI(p);
+removePI(i);
+}
+
+void MutableParamList::operator-=(int i)
+{
+removePI(i);
+}
+
+int MutableParamList::getGroupCount()
+{
+int count=0;
+FOREACH(ParamInfo*,pi,list)
+	count+=pi->groupcount;
+return count;
+}
+
+int MutableParamList::getPropCount()
+{
+int count=0;
+FOREACH(ParamInfo*,pi,list)
+	count+=pi->propcount;
+return count;
+}
+
+int MutableParamList::getSubParam(int i,ParamInterface **sub_p,int *sub_i)
+{
+int n;
+FOREACH(ParamInfo*,pi,list)
+	{
+	if (i<(n=pi->propcount))
+		{
+		*sub_p=pi->pi;
+		*sub_i=i;
+		return 1;
+		}
+	i-=n;
+	}
+return 0;
+}
+
+int MutableParamList::getSubGroup(int i,ParamInterface **sub_p,int *sub_i)
+{
+int n;
+FOREACH(ParamInfo*,pi,list)
+	{
+	if (i<(n=pi->groupcount))
+		{
+		*sub_p=pi->pi;
+		*sub_i=i;
+		return 1;
+		}
+	i-=n;
+	}
+return 0;
+}
+
+#define FUN(_type_,_name_,_ret_) \
+_type_ MutableParamList:: _name_ (int i) \
+{ \
+int j; ParamInterface *pi; \
+if (!getSubParam(i,&pi,&j)) return _ret_; \
+return pi-> _name_ (j); \
+}
+
+FUN(const char*,id,0)
+FUN(const char*,name,0)
+FUN(const char*,type,0)
+FUN(const char*,help,0)
+FUN(int,flags,0)
+FUN(SString,getString,SString())
+FUN(long,getInt,0)
+FUN(double,getDouble,0)
+FUN(ExtValue,getExtValue,ExtValue((long)0))
+FUN(ExtObject,getObject,ExtObject())
+
+int MutableParamList::group(int i)
+{
+int n;
+int g=0;
+FOREACH(ParamInfo*,pi,list)
+	{
+	if (i<(n=pi->propcount))
+		return g + pi->pi->group(i);
+	g+=pi->groupcount;
+	i-=n;
+	}
+return 0;
+}
+
+#define FUN2(_type_,_name_,_argt_) \
+_type_ MutableParamList:: _name_ (int i,_argt_ v) \
+{ \
+int j; ParamInterface *pi; \
+if (!getSubParam(i,&pi,&j)) return 0; \
+return pi-> _name_ (j,v); \
+}
+
+FUN2(int,setInt,long)
+FUN2(int,setDouble,double)
+FUN2(int,setString,const SString &)
+FUN2(int,setObject,const ExtObject &)
+FUN2(int,setExtValue,const ExtValue &)
+
+void MutableParamList::call(int i,ExtValue* args,ExtValue *ret)
+{
+int j; ParamInterface *pi;
+if (!getSubParam(i,&pi,&j)) return;
+pi->call(j,args,ret);
+}
+
+const char *MutableParamList::grname(int i)
+{
+int j; ParamInterface *pi;
+if (!getSubGroup(i,&pi,&j)) return 0;
+return pi->grname(j);
+}
+
+int MutableParamList::grmember(int gi,int i)
+{
+int n;
+int count=0;
+FOREACH(ParamInfo*,pi,list)
+	{
+	if (gi<(n=pi->groupcount))
+		{
+		int prop=pi->pi->grmember(gi,i);
+		if (prop>=pi->propcount) return -9999;
+		return count+prop;
+		}
+	count+=pi->propcount;
+	gi-=n;
+	}
+return -9999;
+}
+
+void MutableParamList::clear()
+{
+for (int i=list.size()-1;i>=0;i--)
+	operator-=(i);
+}
Index: cpp/frams/param/mutparamlist.h
===================================================================
--- cpp/frams/param/mutparamlist.h	(revision 138)
+++ cpp/frams/param/mutparamlist.h	(revision 138)
@@ -0,0 +1,97 @@
+// This file is a part of the Framsticks GDK.
+// Copyright (C) 2002-2014  Maciej Komosinski and Szymon Ulatowski.  See LICENSE.txt for details.
+// Refer to http://www.framsticks.com/ for further information.
+
+#ifndef _MUTPARAMLIST_H_
+#define _MUTPARAMLIST_H_
+
+#include "param.h"
+#include "mutparamiface.h"
+#include <frams/util/list.h>
+
+struct ParamInfo;
+
+class MutableParamList: public virtual ParamInterface, public MutableParamInterface
+{
+SList list;
+const char *objname;
+int getSubParam(int i,ParamInterface **sub_p,int *sub_i);
+int getSubGroup(int i,ParamInterface **sub_p,int *sub_i);
+
+ParamInfo* getParamInfo(int i);
+void addPI(int pos,ParamInfo *pi);
+int findPI(ParamInfo *pi);
+int findPI(ParamInterface *p);
+int findPI(MutableParamInterface *p);
+void adjustPI(int firstPI,int addprop,int addgroup);
+void removePI(int pi_index);
+
+#define STATRICKCLASS MutableParamList
+STCALLBACKDEF(onPropAdd);
+STCALLBACKDEF(onPropDelete);
+STCALLBACKDEF(onGroupAdd);
+STCALLBACKDEF(onGroupDelete);
+STCALLBACKDEF(onPropChange);
+STCALLBACKDEF(onGroupChange);
+STCALLBACKDEF(onPropActivate);
+#undef STATRICKCLASS
+
+public:
+
+void firePropChange(int i) {onchange.action(i);}
+void fireGroupChange(int i) {ongroupchange.action(i);}
+
+MutableParamList(const char* n=0,const char* d=0):objname(n),description(d) {}
+~MutableParamList();
+
+void operator+=(ParamInterface *p);
+void operator-=(ParamInterface *p);
+void operator+=(MutableParamInterface *p);
+void operator-=(MutableParamInterface *p);
+void insert(int i,ParamInterface *p);
+void insert(int i,MutableParamInterface *p);
+void operator-=(int i);
+
+/** remove all sub params */
+void clear();
+
+const char* getName() {return objname;}
+const char* description;
+const char* getDescription() {return description;}
+
+int getGroupCount();
+int getPropCount();
+
+const char *id(int i);
+const char *name(int i);
+const char *type(int i);
+const char *help(int i);
+int flags(int i);
+int group(int i);
+void call(int i,ExtValue* args,ExtValue *ret);
+const char *grname(int i);
+
+int grmember(int gi,int n);
+
+SString getString(int);
+long getInt(int);
+double getDouble(int);
+ExtValue getExtValue(int);
+ExtObject getObject(int);
+
+int setInt(int,long);
+int setDouble(int,double);
+int setString(int,const SString &);
+int setObject(int,const ExtObject&);
+int setExtValue(int,const ExtValue&);
+};
+
+#endif
+
+
+
+
+
+
+
+
Index: cpp/frams/vm/classes/genoobj.cpp
===================================================================
--- cpp/frams/vm/classes/genoobj.cpp	(revision 138)
+++ cpp/frams/vm/classes/genoobj.cpp	(revision 138)
@@ -0,0 +1,115 @@
+// This file is a part of the Framsticks GDK.
+// Copyright (C) 2002-2014  Maciej Komosinski and Szymon Ulatowski.  See LICENSE.txt for details.
+// Refer to http://www.framsticks.com/ for further information.
+
+#include "genoobj.h"
+#include <frams/util/extvalue.h>
+#include <frams/model/autoname.h>
+
+#define FIELDSTRUCT GenoObj
+ParamEntry geno_paramtab[]=
+{
+{"Geno",1,12,"Geno","All information about a single genotype.\nThis is a genetics-only object which does not contain any performance data. See also: Genotype class"},
+{"name",0,PARAM_NOSTATIC,"Name","s 0 40",GETSET(name),},
+{"rawgenotype",0,PARAM_NOSTATIC+PARAM_READONLY,"Raw genotype","s 1",GETONLY(genotype),"Genotype, excluding the format specifier"},
+{"info",0,PARAM_NOSTATIC,"Info","s 1",GETSET(info),"Additional information or comments",},
+{"format",0,PARAM_NOSTATIC+PARAM_READONLY,"Format","d",GETONLY(format),"Genotype format",},
+{"genotype",0,PARAM_NOSTATIC+PARAM_READONLY,"Genotype","s 1",GETONLY(string),},
+{"isValid",0,PARAM_NOSTATIC+PARAM_READONLY,"Valid","d 0 1",GETONLY(isvalid),},
+{"getConverted",0,PARAM_NOSTATIC,"get converted genotype","p oGeno(d format)",PROCEDURE(p_getconvert),},
+{"f0genotype",0,PARAM_NOSTATIC+PARAM_READONLY,"f0 genotype","s 1",GETONLY(f0genotype),"converted to f0 genotype",},
+{"new",0,0,"create new empty object","p oGeno()",PROCEDURE(p_new),},
+{"newFromString",0,0,"create new object from supplied string argument","p oGeno(s genotype)",PROCEDURE(p_newfromstring),},
+{"newFrom",0,0,"create new object","p oGeno(s genotype,d format,s name,s description)",PROCEDURE(p_newfrom),},
+{"autoname",0,PARAM_NOSTATIC+PARAM_READONLY,"Autogenerated name","s",GETONLY(autoname),},
+{0,0,0,},
+};
+#undef FIELDSTRUCT
+
+void GenoObj::get_isvalid(ExtValue *ret)
+{ret->setInt(isValid());}
+
+void GenoObj::get_genotype(ExtValue *ret)
+{ret->setString(getGene());}
+
+void GenoObj::get_name(ExtValue *ret)
+{ret->setString(getName());}
+
+void GenoObj::get_autoname(ExtValue *ret)
+{
+Model m(*this);
+ret->setString(AutoName::makeName(m));
+}
+
+int GenoObj::set_name(const ExtValue *v)
+{setName(v->getString());
+return PSET_CHANGED;}
+
+void GenoObj::get_info(ExtValue *ret)
+{ret->setString(getComment());}
+
+void GenoObj::get_string(ExtValue *ret)
+{ret->setString(shortString());}
+
+void GenoObj::get_format(ExtValue *ret)
+{ret->setInt(getFormat());}
+
+int GenoObj::set_info(const ExtValue *v)
+{setComment(v->getString());
+return PSET_CHANGED;}
+
+void GenoObj::get_f0genotype(ExtValue *ret)
+{ret->setString(getConverted('0').getGene());}
+
+void GenoObj::p_getconvert(ExtValue *args,ExtValue *ret)
+{*ret=makeDynamicObjectAndDecRef(new Geno(getConverted((char)args[0].getInt())));}
+
+void GenoObj::p_new(ExtValue *args,ExtValue *ret)
+{*ret=makeDynamicObjectAndDecRef(new Geno());}
+
+void GenoObj::p_newfromstring(ExtValue *args,ExtValue *ret)
+{*ret=makeDynamicObjectAndDecRef(new Geno(args[0].getString()));}
+
+void GenoObj::p_newfrom(ExtValue *args,ExtValue *ret)
+{*ret=makeDynamicObjectAndDecRef(new Geno(args[3].getString(),(char)args[2].getInt(),
+				 args[1].getString(),args[0].getString()));}
+
+Param& GenoObj::getStaticParam()
+{
+#ifdef __CODEGUARD__
+static GenoObj static_genoobj;
+static Param static_genoparam(geno_paramtab,&static_genoobj);
+#else
+static Param static_genoparam(geno_paramtab);
+#endif
+return static_genoparam;
+}
+
+Param& GenoObj::getDynamicParam()
+{
+static Param dynamic_genoparam(geno_paramtab);
+return dynamic_genoparam;
+}
+
+ParamInterface* GenoObj::getInterface() {return &getStaticParam();}
+
+ExtObject GenoObj::makeStaticObject(Geno* g)
+{return ExtObject(&getStaticParam(),(void*)g);}
+
+ExtObject GenoObj::makeDynamicObject(Geno* g)
+{return ExtObject(&getDynamicParam(),(DestrBase*)g);}
+
+ExtObject GenoObj::makeDynamicObjectAndDecRef(Geno* g)
+{
+const ExtObject& o=makeDynamicObject(g);
+g->decref();
+return o;
+}
+
+Geno* GenoObj::fromObject(const ExtValue& v)
+{
+if (v.type!=TObj) return 0;
+const ExtObject& o=v.getObject();
+//if ((o.param!=&getStaticParam())&&(o.param!=&getDynamicParam())) return 0;
+return (Geno*)o.getTarget(getStaticParam().getName());
+}
Index: cpp/frams/vm/classes/genoobj.h
===================================================================
--- cpp/frams/vm/classes/genoobj.h	(revision 138)
+++ cpp/frams/vm/classes/genoobj.h	(revision 138)
@@ -0,0 +1,45 @@
+// This file is a part of the Framsticks GDK.
+// Copyright (C) 2002-2014  Maciej Komosinski and Szymon Ulatowski.  See LICENSE.txt for details.
+// Refer to http://www.framsticks.com/ for further information.
+
+#ifndef _GENOOBJ_H_
+#define _GENOOBJ_H_
+
+#include <frams/genetics/geno.h>
+
+extern ParamEntry geno_paramtab[];
+
+class GenoObj: public Geno
+{
+  public:
+#define STATRICKCLASS GenoObj
+PARAMGETDEF(isvalid);
+PARAMGETDEF(genotype);
+PARAMGETDEF(name);
+PARAMSETDEF(name);
+PARAMGETDEF(autoname);
+PARAMGETDEF(info);
+PARAMSETDEF(info);
+PARAMGETDEF(format);
+PARAMGETDEF(string);
+PARAMPROCDEF(p_getconvert);
+PARAMGETDEF(f0genotype);
+PARAMPROCDEF(p_new);
+PARAMPROCDEF(p_newfrom);
+PARAMPROCDEF(p_newfromstring);
+#undef STATRICKCLASS
+
+static ExtObject makeStaticObject(Geno* g);
+static ExtObject makeDynamicObject(Geno* g);
+static ExtObject makeDynamicObjectAndDecRef(Geno* g);
+static Geno* fromObject(const ExtValue& v);
+static ParamInterface* getInterface();
+
+static Param& getStaticParam();
+static Param& getDynamicParam();
+};
+
+#endif
+
+
+
