Index: /experiments/frams/foraminifera/data/scripts/foraminifera.expdef
===================================================================
--- /experiments/frams/foraminifera/data/scripts/foraminifera.expdef	(revision 475)
+++ /experiments/frams/foraminifera/data/scripts/foraminifera.expdef	(revision 476)
@@ -6,12 +6,12 @@
 
 Technical information:
-Genes and parameter values which control reproduction are stored in user1 and user2 fields.
-
-user1:
+Genes and parameter values which control reproduction are stored in data->genes and data->lifeparams fields.
+
+genes:
 genes which are not encoded in Ff genotype:
 min_repro_energy - Minimum energy necessary for reproduction
 hibernation - Defines foram behavior in the case of no nutrients
 
-user2:
+lifeparams:
 Physiological parameters of foraminifera:
 max_energy_level - maximum energy level reached so far
@@ -220,9 +220,9 @@
 		{
 			//cr.rotate(0,0,Math.rnd01*Math.twopi);
-			if ((typeof(g.user1) == "Vector") && (g.user1.size >= 3))
+			if ((typeof(g.data->genes) == "Vector") && (g.data->genes.size >= 3))
 			{
 				// [x,y,energy]
-				cr.move(g.user1[0] - cr.center_x, g.user1[1] - cr.center_y, 0);
-				cr.energy = g.user1[2];
+				cr.move(g.data->genes[0] - cr.center_x, g.data->genes[1] - cr.center_y, 0);
+				cr.energy = g.data->genes[2];
 			}
 			else
@@ -278,5 +278,5 @@
 	{
 		var ret = Populations[2].add("//0\np:sh=3,sx=0.01,sy="+ExpParams.zone1_range+",sz="+ExpParams.zone1_range+",ry=1.57,vr=1.0,1.0,1.0");
-		cr.user3 = ret;
+		cr.data->reticulopodiacreature = ret;
 	}
 }
@@ -299,7 +299,7 @@
 	var has_ret = 0;
 
-	if (cr.user3 != null)
-	{
-		if (Populations[2].findUID(cr.user3.uid) != null)
+	if (cr.data->reticulopodiacreature != null)
+	{
+		if (Populations[2].findUID(cr.data->reticulopodiacreature.uid) != null)
 		{
 			has_ret = 1;
@@ -312,7 +312,7 @@
 function foramGrow(cr, chamber_num)
 {
-	if ((chamber_num+1) < chambers[cr.user2["species"]].size)
-	{
-		var geno = createForamGenotype(cr.user2["gen"], cr.user2["species"], chamber_num+1);
+	if ((chamber_num+1) < chambers[cr.data->lifeparams->species].size)
+	{
+		var geno = createForamGenotype(cr.data->lifeparams->gen, cr.data->lifeparams->species, chamber_num+1);
 		var cr2 = Populations[0].add(geno);
 
@@ -320,11 +320,11 @@
 		cr2.energy = cr2.energy0;
 
-		setGenotype({"cr" : cr2, "parent_user1" : cr.user1, "parent_user2" : cr.user2, "opt" : 2});
+		setGenotype({"cr" : cr2, "parent_genes" : cr.data->genes, "parent_lifeparams" : cr.data->lifeparams, "opt" : 2});
 		cr2.moveAbs(cr.center_x - cr2.size_x / 2, cr.center_y - cr2.size_y / 2, cr.pos_z);
-		setForamMeta(cr2, cr2.user2["gen"]);
+		setForamMeta(cr2, cr2.data->lifeparams->gen);
 
 		if (visualization(cr))
 		{
-			Populations[2].delete(cr.user3);
+			Populations[2].delete(cr.data->reticulopodiacreature);
 		}
 		Populations[0].delete(cr);
@@ -362,5 +362,5 @@
 				}
 			}
-			else if (eating == 0 && cr.user2["hibernated"] == 0 && dist < mindist)
+			else if (eating == 0 && cr.data->lifeparams->hibernated == 0 && dist < mindist)
 			{
 				mindist = dist;
@@ -369,5 +369,5 @@
 		}
 
-		if (!eating && cr.user2["hibernated"] == 0)
+		if (!eating && cr.data->lifeparams->hibernated == 0)
 		{
 			mindistvec.normalize();
@@ -388,7 +388,7 @@
 function moveEnergyDec(cr)
 {
-	if (cr.user2["hibernated"] == 0)
-	{
-		//cr.energy_m += (ExpParams.energy_move * max_chamber_energ[cr.user2["gen"]][Math.min(lastChamberNum(cr), (max_chamber_energ[cr.user2["gen"]].size)-1)])*ExpParams.secPerStep;
+	if (cr.data->lifeparams->hibernated == 0)
+	{
+		//cr.energy_m += (ExpParams.energy_move * max_chamber_energ[cr.data->lifeparams->gen][Math.min(lastChamberNum(cr), (max_chamber_energ[cr.data->lifeparams->gen].size)-1)])*ExpParams.secPerStep;
 		cr.energy_m += (ExpParams.energy_move * cr.energy)*ExpParams.secPerStep;
 	}
@@ -413,6 +413,6 @@
 	//no nutrients in zone 2
 	var hibernation = 0;
-	if (cr.user2["gen"] == 0) hibernation =  cr.user1["hibernation"];
-	else hibernation =  cr.user1[0]["hibernation"];
+	if (cr.data->lifeparams->gen == 0) hibernation =  cr.data->genes->hibernation;
+	else hibernation =  cr.data->genes[0]->hibernation;
 	//hibernation
 	if (hibernation == 1)
@@ -424,11 +424,11 @@
 	else if (cr.lifespan%(dir_change/ExpParams.secPerStep) == 0)
 	{
-		cr.user2["dir"] = randomDir();
-		cr.localDrive = cr.user2["dir"];
+		cr.data->lifeparams->dir = randomDir();
+		cr.localDrive = cr.data->lifeparams->dir;
 		moveEnergyDec(cr);
 	}
 	else
 	{
-		cr.localDrive = cr.user2["dir"];
+		cr.localDrive = cr.data->lifeparams->dir;
 	}
 }
@@ -450,5 +450,5 @@
 	cr2.energy_m = cr2.energy_m + e;
 	cr1.energy_p = cr1.energy_p + e;
-	if (cr1.user2["hibernated"] == 1)
+	if (cr1.data->lifeparams->hibernated == 1)
 	{
 		reverseHib(cr1);
@@ -458,14 +458,14 @@
 function reverseHib(cr)
 {
-	if (cr.user2["hibernated"] == 1)
-	{
-		setForamMeta(cr, cr.user2["gen"]); //unhibernate
+	if (cr.data->lifeparams->hibernated == 1)
+	{
+		setForamMeta(cr, cr.data->lifeparams->gen); //unhibernate
 	} 
 	else
 	{
-		//cr.idleen = (ExpParams.energy_hib * max_chamber_energ[cr.user2["gen"]][Math.min(lastChamberNum(cr), (max_chamber_energ[cr.user2["gen"]].size)-1)])*ExpParams.secPerStep; //hibernate
+		//cr.idleen = (ExpParams.energy_hib * max_chamber_energ[cr.data->lifeparams->gen][Math.min(lastChamberNum(cr), (max_chamber_energ[cr.data->lifeparams->gen].size)-1)])*ExpParams.secPerStep; //hibernate
 		cr.idleen = (ExpParams.energy_hib * cr.energy)*ExpParams.secPerStep; //hibernate
 	}
-	cr.user2["hibernated"] = 1 - cr.user2["hibernated"];
+	cr.data->lifeparams->hibernated = 1 - cr.data->lifeparams->hibernated;
 }
 
@@ -475,5 +475,5 @@
 	if (visualization(cr))
 	{
-		cr.user3.moveAbs(cr.center_x-ExpParams.zone1_range, cr.center_y-ExpParams.zone1_range, cr.center_z-ExpParams.zone1_range-getProperty(cr.user2["gen"], "chamber_proculus"));
+		cr.data->reticulopodiacreature.moveAbs(cr.center_x-ExpParams.zone1_range, cr.center_y-ExpParams.zone1_range, cr.center_z-ExpParams.zone1_range-getProperty(cr.data->lifeparams->gen, "chamber_proculus"));
 	}
 
@@ -492,8 +492,8 @@
 	}
 
-	cr.user2["max_energy_level"] = Math.max(cr.energy, cr.user2["max_energy_level"]);
+	cr.data->lifeparams->max_energy_level = Math.max(cr.energy, cr.data->lifeparams->max_energy_level);
 	if  (lastChamberNum(cr) <= chambers[0].size-1)
 	{
-		if ((cr.user2["max_energy_level"] >= max_chamber_energ[cr.user2["gen"]][lastChamberNum(cr)])) 	
+		if ((cr.data->lifeparams->max_energy_level >= max_chamber_energ[cr.data->lifeparams->gen][lastChamberNum(cr)])) 	
 		{
 			foramGrow(cr, lastChamberNum(cr)); 
@@ -504,5 +504,5 @@
 function deathConditions(cr)
 {
-	if ((cr.energy <= getProperty(cr.user2["species"],"e_death_level")) || (Math.rnd01 < ExpParams.hunted_prob))
+	if ((cr.energy <= getProperty(cr.data->lifeparams->species,"e_death_level")) || (Math.rnd01 < ExpParams.hunted_prob))
 		return 1;
 	else
@@ -514,10 +514,10 @@
 	if (visualization(cr))
 	{
-		Populations[2].delete(cr.user3);
+		Populations[2].delete(cr.data->reticulopodiacreature);
 	}
 	//fossilization
 	var geno = GenePools[0].add(cr.genotype);
-	geno.user1 = cr.user1;
-	geno.user2 = cr.user2;
+	geno.data->genes = cr.data->genes;
+	geno.data->lifeparams = cr.data->lifeparams;
 	if (ExpParams.logging == 1) Simulator.print("\"" + cr.name + "\" died...");
 	ExpState.totaltestedcr++;
@@ -555,5 +555,5 @@
 		var nutsize = ExpParams.nutrientsize*10;
 		var nut = Populations[2].add("//0\np:sh=2,sx="+nutsize+",sy="+nutsize+",sz="+nutsize+",ry=1.5,vr=0.0,1.0,0.0");
-		cr.user3 = nut;
+		cr.data->reticulopodiacreature = nut;
 		nut.moveAbs(cr.pos_x-1.5*nutsize, cr.pos_y-1.5*nutsize, 0.5);
 	}
@@ -564,5 +564,5 @@
 	if (visualization(cr))
 	{
-		Populations[2].delete(cr.user3);
+		Populations[2].delete(cr.data->reticulopodiacreature);
 	}
 }
@@ -635,6 +635,6 @@
 	{
 		var cr = Populations[0].get(i);
-		var gen = cr.user2["gen"];
-		var species = cr.user2["species"];
+		var gen = cr.data->lifeparams->gen;
+		var species = cr.data->lifeparams->species;
 
 		number[species][gen] = number[species][gen] + 1; 
Index: /experiments/frams/foraminifera/data/scripts/foraminifera.inc
===================================================================
--- /experiments/frams/foraminifera/data/scripts/foraminifera.inc	(revision 475)
+++ /experiments/frams/foraminifera/data/scripts/foraminifera.inc	(revision 476)
@@ -53,18 +53,18 @@
 function setGenotype(mode)
 {
-	if (mode["opt"] == 0) //initial
-	{
-		mode["cr"].user1 = {"min_repro_energies" : [max_chamber_energ[0][getProperty(0, "min_repro_energ")], max_chamber_energ[1][getProperty(1, "min_repro_energ")]], "hibernation" : mode["species"]};
-		mode["cr"].user2 = {"max_energy_level" : getProperty(0,"energies0"), "gen" : 0,  "hibernated" : 0, "species" : mode["species"], "reproduce" : 0, "dir" : randomDir()};
-	}
-	else if (mode["opt"]  == 1) //child
-	{
-		mode["cr"].user2 = {"max_energy_level" : getProperty(1 - mode["parent_user2"]["gen"],"energies0"), "gen" : 1 - mode["parent_user2"]["gen"],  "hibernated" : 0, "species" : mode["parent_user2"]["species"], "reproduce" : 0, "dir" : randomDir()};
-		mode["cr"].user1 = mode["parent_user1"];
+	if (mode->opt == 0) //initial
+	{
+		mode->cr.data->genes = {"min_repro_energies" : [max_chamber_energ[0][getProperty(0, "min_repro_energ")], max_chamber_energ[1][getProperty(1, "min_repro_energ")]], "hibernation" : mode->species};
+		mode->cr.data->lifeparams = {"max_energy_level" : getProperty(0,"energies0"), "gen" : 0,  "hibernated" : 0, "species" : mode->species, "reproduce" : 0, "dir" : randomDir()};
+	}
+	else if (mode->opt  == 1) //child
+	{
+		mode->cr.data->lifeparams = {"max_energy_level" : getProperty(1 - mode->parent_lifeparams->gen,"energies0"), "gen" : 1 - mode->parent_lifeparams->gen,  "hibernated" : 0, "species" : mode->parent_lifeparams->species, "reproduce" : 0, "dir" : randomDir()};
+		mode->cr.data->genes = mode->parent_genes;
 	}
 	else //grow
 	{
-		mode["cr"].user1 = mode["parent_user1"];
-		mode["cr"].user2 = mode["parent_user2"];
+		mode->cr.data->genes = mode->parent_genes;
+		mode->cr.data->lifeparams = mode->parent_lifeparams;
 	}
 }
@@ -72,19 +72,19 @@
 function reproduce_haploid(parent, parent2, clone)
 {	
-	var number, energy0, new_user1, gen;
+	var number, energy0, new_genes, gen;
 	if (clone == 1)
 	{
 		energy0 = getProperty(0,"energies0");
 		number = (( 1 - getProperty(1, "e_repro_cost")) * parent.energy) / energy0;
-		new_user1 = parent.user1;
-		parent.user2["gen"] = 1 - parent.user2["gen"]; //because of reversal of "gen" in createOffspring function
-		gen = parent.user2["gen"];
+		new_genes = parent.data->genes;
+		parent.data->lifeparams->gen = 1 - parent.data->lifeparams->gen; //because of reversal of "gen" in createOffspring function
+		gen = parent.data->lifeparams->gen;
 	}
 	else
 	{
 		energy0 = getProperty(1,"energies0"); 
-		number = (((1 - getProperty(parent.user2["gen"], "e_repro_cost")) * parent.energy) + ((1 -(getProperty(parent.user2["gen"], "e_repro_cost"))) * parent2.energy)) / energy0;
-		new_user1 = [parent.user1, parent2.user1];
-		gen = 1 - parent.user2["gen"];
+		number = (((1 - getProperty(parent.data->lifeparams->gen, "e_repro_cost")) * parent.energy) + ((1 -(getProperty(parent.data->lifeparams->gen, "e_repro_cost"))) * parent2.energy)) / energy0;
+		new_genes = [parent.data->genes, parent2.data->genes];
+		gen = 1 - parent.data->lifeparams->gen;
 	}
 
@@ -93,5 +93,5 @@
 	for (var j = 0; j < number; j++)
 	{
-		createOffspring(createForamGenotype(gen, parent.user2["species"], 0), energy0, new_user1, parent.user2); 
+		createOffspring(createForamGenotype(gen, parent.data->lifeparams->species, 0), energy0, new_genes, parent.data->lifeparams); 
 	}
 }
@@ -100,5 +100,5 @@
 {
 	var energy0 = getProperty(0,"energies0");
-	var number = ((1 - (getProperty(parent.user2["gen"], "e_repro_cost"))) * parent.energy) / energy0;
+	var number = ((1 - (getProperty(parent.data->lifeparams->gen, "e_repro_cost"))) * parent.energy) / energy0;
 
 	Simulator.print("diploid number of offspring: " + number+ " energ0: " + energy0);
@@ -116,5 +116,5 @@
 		for (var k = 0; k < 2; k++)
 		{
-			createOffspring(createForamGenotype(1 - parent.user2["gen"], parent.user2["species"], 0), energy0, parent.user1[0], parent.user2); 
+			createOffspring(createForamGenotype(1 - parent.data->lifeparams->gen, parent.data->lifeparams->species, 0), energy0, parent.data->genes[0], parent.data->lifeparams); 
 		}
 
@@ -136,7 +136,7 @@
 		for (var i = pop.size-1; i >= 0; i--)
 		{
-   			if (pop[i].user2["reproduce"] == 1 && pop[i].user2["species"] == species) 
+   			if (pop[i].data->lifeparams->reproduce == 1 && pop[i].data->lifeparams->species == species) 
    			{ 
-				if ((pop[i].user2["gen"]==1) || ((pop[i].user2["gen"]==0) && ExpParams.stress == 0))
+				if ((pop[i].data->lifeparams->gen==1) || ((pop[i].data->lifeparams->gen==0) && ExpParams.stress == 0))
 				{
 					continue;
@@ -169,5 +169,5 @@
 	
 	
-	if (cr.user2["gen"] == 1)
+	if (cr.data->lifeparams->gen == 1)
 	{
 		reproduce_diploid(cr);
@@ -183,9 +183,9 @@
 		if (cr.signals.size == 0)
 		{
-			cr.signals.add("repro"+cr.user2["species"]);
+			cr.signals.add("repro"+cr.data->lifeparams->species);
 			cr.signals[0].power = 1;
 		}
 		reproduced = 0;
-		cr.user2["reproduce"] = 1;
+		cr.data->lifeparams->reproduce = 1;
 	}
 
@@ -201,5 +201,5 @@
 function print_repro_info(cr)
 {
-	Simulator.print("Reproduced " + cr.user2["gen"] + " of species " + cr.user2["species"] + " energy: " + cr.energy);
+	Simulator.print("Reproduced " + cr.data->lifeparams->gen + " of species " + cr.data->lifeparams->species + " energy: " + cr.energy);
 }
 
@@ -211,11 +211,11 @@
 	var reproduced = 0;
 
-	if (cr.user2["gen"] == 0)
-	{
-		properEnergy = ( cr.energy >= cr.user1["min_repro_energies"][cr.user2["gen"]] );
+	if (cr.data->lifeparams->gen == 0)
+	{
+		properEnergy = ( cr.energy >= cr.data->genes->min_repro_energies[cr.data->lifeparams->gen] );
 	}
 	else
 	{
-		properEnergy = ( cr.energy >= cr.user1[0]["min_repro_energies"][cr.user2["gen"]] ); //TODO gene selection
+		properEnergy = ( cr.energy >= cr.data->genes[0]->min_repro_energies[cr.data->lifeparams->gen] ); //TODO gene selection
 	}
 
@@ -228,5 +228,5 @@
 			reproduced = readyToRepro(cr);
 		}
-		else if (cr.signals.receive("repro"+cr.user2["species"]) > 0)
+		else if (cr.signals.receive("repro"+cr.data->lifeparams->species) > 0)
 		{
 			reproduced = readyToRepro(cr);
@@ -239,5 +239,5 @@
 	{
 		cr.signals.clear();
-		cr.user2["reproduce"] = 0; 
+		cr.data->lifeparams->reproduce = 0; 
 	}
 
@@ -247,15 +247,15 @@
 function crossover(parent, gene)
 {
-	var tmp = parent.user1[0][gene];
-	parent.user1[0][gene] = parent.user1[1][gene];
-	parent.user1[1][gene] = tmp;
-}
-
-function createOffspring(geno, energy, parent_user1, parent_user2)
+	var tmp = parent.data->genes[0][gene];
+	parent.data->genes[0][gene] = parent.data->genes[1][gene];
+	parent.data->genes[1][gene] = tmp;
+}
+
+function createOffspring(geno, energy, parent_genes, parent_lifeparams)
 {
 	var cr = Populations[0].add(geno);
 	cr.energy0 = energy;
 	cr.energy = cr.energy0;
-	setGenotype({"cr" : cr, "parent_user1" : parent_user1, "parent_user2" : parent_user2, "opt" : 1});
+	setGenotype({"cr" : cr, "parent_genes" : parent_genes, "parent_lifeparams" : parent_lifeparams, "opt" : 1});
 	placeRandomlyNotColliding(cr);
 }
