Index: /experiments/frams/foraminifera/data/scripts/foraminifera.expdef
===================================================================
--- /experiments/frams/foraminifera/data/scripts/foraminifera.expdef	(revision 492)
+++ /experiments/frams/foraminifera/data/scripts/foraminifera.expdef	(revision 493)
@@ -25,5 +25,7 @@
 global chambers;
 global colors;
-global dir_change;
+global retColors;
+global curColor;
+global dir_change_sec;
 global max_chamber_volume;
 global movePerStep;
@@ -33,4 +35,5 @@
 global changePeriod;
 global phase;
+global nutrientSqrCm;
 global species_genes; 
 
@@ -80,6 +83,6 @@
 	//world
 	SignalView.mode = 1;
-	World.wrldwat = 200;
-	World.wrldsiz = micronsToFrams(40000);
+	World.wrldwat = 500;
+	World.wrldsiz = micronsToFrams(100000);
 	World.wrldbnd = 1;
 	ExpProperties.stress = 1;
@@ -95,4 +98,5 @@
 
 	//ExpProperties.logging = 1; //uncomment to enable logging simulation parameters to log files	
+	ExpProperties.logPref = "";
 
 	//reproduction
@@ -101,5 +105,5 @@
 	ExpProperties.mutationprob = 0;
 	ExpProperties.repro_time = 720;
-	ExpProperties.gametoPeriod = 43200;
+	ExpProperties.gametoPeriod = 21600;
 	ExpProperties.divisionCost = 15.6;
 	reprocounter = 0;
@@ -109,6 +113,7 @@
 	init_chambers();
 
+	curColor = retColors[0];
 	//morphology
-	dir_change = 30000;
+	dir_change_sec = 30000;
 	ExpProperties.zone1_range = micronsToFrams(1000);
 	ExpProperties.zone2_range = micronsToFrams(3000);
@@ -137,6 +142,6 @@
 	ExpProperties.energy_move = 0.0000005;
 
-	ExpProperties.energies0_haplo = energyFromVolume(micronsToFrams(20),1);
-	ExpProperties.energies0_diplo = energyFromVolume(micronsToFrams(1.25),1);
+	ExpProperties.energies0_haplo = 20;
+	ExpProperties.energies0_diplo = 1.25;
 	ExpProperties.feedtrans = 0.001;
 	ExpProperties.e_repro_cost_haplo = 0.3; 
@@ -149,9 +154,10 @@
 	changePeriod = 0;
 	phase = "low";
-	ExpProperties.foodperiod = 3600;
-	ExpProperties.foodPeriodChange = 0;
+	nutrientSqrCm = 10;
+	ExpProperties.foodperiod = 25920;
+	ExpProperties.foodPeriodChange = 6;
 	ExpProperties.nutrientradius = micronsToFrams(10);
 	ExpProperties.energy_nut = energyFromVolume(ExpProperties.nutrientradius,1);
-	ExpProperties.feedrate = 1;
+	ExpProperties.nutrient_pop = Math.pow(framsToMicrons(World.wrldsiz)*0.0001,2)/nutrientSqrCm;
 	ExpProperties.ingestion = 0.25;
 	nutrientenergywaiting = 0;
@@ -159,6 +165,6 @@
 	ExpState.nutrient = "";
 	
-	addSpecies({"min_repro_energies" : [4,6]});
-	addSpecies({"min_repro_energies" : [4,8]});
+	//addSpecies({"min_repro_energies" : [4,6]});
+	//addSpecies({"min_repro_energies" : [4,8]});
 }
 
@@ -189,10 +195,10 @@
 function micronsToFrams(micrometers)
 {
-	return micrometers*0.025;
+	return micrometers*0.01;
 }
 
 function framsToMicrons(framsworldunits)
 {
-	return framsworldunits/0.025;
+	return framsworldunits/0.01;
 }
 
@@ -215,4 +221,5 @@
 {
 	var geno = createForamMorphology(species_genes[species]->morphotype, ploid, chambernum);
+	curColor = retColors[ploid];
 	var cr = Populations[0].add(geno);
 	cr.name = "Initial creature" + species + "_" + iter;
@@ -235,5 +242,5 @@
 		ploid = 1;
 	}	
-	//add new foram with random energy bewtween starting energy and reproduction treshold
+	//add new foram with random energy bewtween starting energy and reproduction threshold
 	addForam(species, iter, int(Math.rndUni(0,species_genes[species]->min_repro_energies[ploid])),ploid);
 }
@@ -242,5 +249,5 @@
 function addSpecies(new_genes)
 {
-	species_genes.add({"min_repro_energies" : [4,6], "energies0" : [20, 1.25], "hibernation" : 0, "morphotype" : 0});
+	species_genes.add({"min_repro_energies" : [ExpProperties.min_repro_energ_haplo,ExpProperties.min_repro_energ_diplo], "energies0" : [ExpProperties.energies0_haplo, ExpProperties.energies0_diplo], "hibernation" : 0, "morphotype" : 0});
 	for (var i = 0; i < new_genes.size; i++)
 	{
@@ -358,5 +365,5 @@
 	if (ExpProperties.visualize == 1)
 	{
-		var ret = Populations[2].add("//0\np:sh=3,sx=0.01,sy="+getZoneRange(cr,1)+",sz="+getZoneRange(cr,1)+",ry=1.57,vr=1.0,1.0,1.0");
+		var ret = Populations[2].add("//0\np:sh=3,sx=0.01,sy="+getZoneRange(cr,1)+",sz="+getZoneRange(cr,1)+",ry=1.57,vr="+curColor);
 		cr.data->reticulopodiacreature = ret;
 	}
@@ -395,4 +402,5 @@
 	if ((chamber_num+1) < chambers[cr.data->lifeparams->species].size)
 	{
+		curColor = retColors[cr.data->lifeparams->gen];
 		var geno = createForamMorphology(getGene(cr, "morphotype", 0), cr.data->lifeparams->gen, chamber_num+1);
 		var cr2 = Populations[0].add(geno);
@@ -476,7 +484,7 @@
 }
 
-function fence(pos)
-{
-	return Math.min(Math.max(0,pos),World.wrldsiz);
+function fence(pos, zone)
+{
+	return Math.min(Math.max(0+zone,pos),World.wrldsiz-zone);
 }
 
@@ -486,5 +494,5 @@
 
 	//adjustment in z axis
-	cr.moveAbs(fence(cr.pos_x), fence(cr.pos_y), 0);
+	cr.moveAbs(fence(cr.pos_x, getZoneRange(cr, 1)), fence(cr.pos_y,getZoneRange(cr, 1)), 0);
 
 	//are there any nutrients in zone 1 or 2?
@@ -504,5 +512,5 @@
 	}
 	//random move
-	else if (Simulator.stepNumber%int(dir_change/ExpProperties.secPerStep) == 0)
+	else if (Simulator.stepNumber%int(dir_change_sec/ExpProperties.secPerStep) == 0)
 	{
 		cr.data->lifeparams->dir = randomDir();
@@ -552,4 +560,20 @@
 }
 
+function createLogVector(cr, value)
+{
+	var vec = Vector.new();
+	for (var i = 0; i < species_genes.size; i++)
+	{
+		for (var j = 0; j < 2; j++)
+		{
+			vec.add(0);
+		}
+		if (cr.data->lifeparams->species == i)
+		{
+			vec[i*2+cr.data->lifeparams->gen] = value;		
+		}
+	}
+	return vec;
+}
 
 function onForamsStep(cr)
@@ -592,9 +616,13 @@
 		if (visualization(cr))
 		{
-			cr.data->reticulopodiacreature.moveAbs(cr.center_x-getZoneRange(cr,1), cr.center_y-getZoneRange(cr,1), cr.center_z-getZoneRange(cr,1)-getProperty(cr.data->lifeparams->gen, "chamber_proculus"));
+			cr.data->reticulopodiacreature.moveAbs(cr.center_x-getZoneRange(cr,1), cr.center_y-getZoneRange(cr,1), cr.center_z-getZoneRange(cr,1));
 		}
 
 		if (deathConditions(cr) == 1)
 		{
+			if (ExpProperties.logging == 1)
+			{
+				log(createLogVector(cr, cr.data->lifeparams->max_energy_level),ExpProperties.logPref+"fossil_log.txt");
+			}			
 			Populations[0].kill(cr);
 			return;
@@ -712,5 +740,5 @@
 	if (nutrientenergywaiting*ExpProperties.secPerStep >= ExpProperties.foodperiod)
 	{
-		for (var i = 0; i < ExpProperties.feedrate; i++)
+		for (var i = 0; i < ExpProperties.nutrient_pop; i++)
 		{    
 			addNutrient();
@@ -719,5 +747,11 @@
 		nutrientenergywaiting = 0.0;
 		Simulator.checkpoint();
-	}
+
+		if (ExpProperties.logging == 1)
+		{
+			log([ExpProperties.nutrient_pop],ExpProperties.logPref+"nutrients_log.txt");
+		}
+	}
+
 }
 
@@ -808,6 +842,6 @@
 	log_energies.add(e_nut);
 
-	log(log_numbers, "forams_log.txt");
-    log(log_energies,  "energies_log.txt");
+	log(log_numbers, ExpProperties.logPref+"forams_log.txt");
+    log(log_energies,  ExpProperties.logPref+"energies_log.txt");
 }
 
@@ -841,4 +875,9 @@
 name:Stop after the given number of simulation steps
 type:d 0 1000000 0
+
+property:
+id:logPref
+name:Log prefix
+type:s
 
 property:
@@ -1044,5 +1083,5 @@
 
 property:
-id:feedrate
+id:nutrient_pop
 name:Feeding rate
 type:f 0 1000000
@@ -1065,5 +1104,5 @@
 id:energy_nut
 name:Nutrient energy
-type:f 0 100000
+type:f 0 10000000
 group:Energy
 
@@ -1083,5 +1122,5 @@
 id:nutrientradius
 name:Nutrient size
-type:f 0.1 0.9 0.1
+type:f 0.001 0.9 0.1
 group:Energy
 
Index: /experiments/frams/foraminifera/data/scripts/foraminifera.inc
===================================================================
--- /experiments/frams/foraminifera/data/scripts/foraminifera.inc	(revision 492)
+++ /experiments/frams/foraminifera/data/scripts/foraminifera.inc	(revision 493)
@@ -5,4 +5,5 @@
 {
 	colors = ["1.0,1.0,0.0","1.0,0.5,0.0"];
+	retColors = ["1.0,1.0,1.0", "1.0,0.0,0.0"];
 	chambers = [ ["0.0,0.0,0.0,",  //coiled
 	"1.08020961284637, -0.0597195439040661, -0.0393781512975693,",
@@ -108,4 +109,11 @@
 		new_genes = [parent.data->genes, parent2.data->genes];
 		gen = 1 - parent.data->lifeparams->gen;
+
+		if (ExpProperties.logging == 1)
+		{
+				log(createLogVector(parent, parent.energy),ExpProperties.logPref+"repro_energies_log.txt");
+				log(createLogVector(parent2, parent2.energy),ExpProperties.logPref+"repro_energies_log.txt");
+				log(createLogVector(parent, number),ExpProperties.logPref+"repro_num_log.txt");
+		}	
 	}
 
@@ -122,4 +130,10 @@
 	var energy0 =getEnergy0( getGene(parent,"energies0", 0)[0]); 
 	var number = ((1 - (getProperty(parent.data->lifeparams->gen, "e_repro_cost"))) * parent.energy) / energy0;
+
+		if (ExpProperties.logging == 1)
+		{
+			log(createLogVector(parent, parent.energy),ExpProperties.logPref+"repro_energies_log.txt");
+			log(createLogVector(parent, number),ExpProperties.logPref+"repro_num_log.txt");
+		}	
 
 	Simulator.print("diploid number of offspring: " + number+ " energ0: " + energy0);
@@ -189,10 +203,8 @@
 						print_repro_info(parent1);
 						print_repro_info(parent2);
-						//Simulator.print("parents "+parent1.uid + " " + parent2.uid + " reproduced: "+Simulator.stepNumber);
 						pop.kill(parent1);
 						pop.kill(parent2);
 						parent1 = null;
 						parent2 = null;
-						
 					}
 				}	
@@ -280,4 +292,5 @@
 function createOffspring(geno, energy, parent_genes, parent_lifeparams)
 {
+	curColor = retColors[1-parent_lifeparams->gen];
 	var cr = Populations[0].add(geno);
 	cr.energy0 = energy;
Index: /experiments/frams/foraminifera/data/scripts/foraminifera.show
===================================================================
--- /experiments/frams/foraminifera/data/scripts/foraminifera.show	(revision 492)
+++ /experiments/frams/foraminifera/data/scripts/foraminifera.show	(revision 493)
@@ -23,5 +23,5 @@
 	GLDisplay.minfps = 10;
 	TrackingCam.cam_h = 15; //more side view
-	Params = { "feedrate" : [200,100,50], "feedtrans" : [0.05,0.125,0.25],"energy_nut" :[0.5,1.5,3.0], "stress" : [0,1], "visualize" : [0,1]};
+	Params = { "foodperiod" : [43200,25920,10800], "feedtrans" : [0.001,0.001,0.001],"energy_nut" :[144.54,544.54,944.54], "stress" : [0,1], "visualize" : [0,1]};
 	ShowProperties.visualize=1;
 }
@@ -57,7 +57,7 @@
 }
 
-function ShowProperties_feedrate_set()
+function ShowProperties_foodperiod_set()
 {
-	setShowParam("feedrate");
+	setShowParam("foodperiod");
 }
 
@@ -85,6 +85,6 @@
 
 property:
-id:feedrate
-name:Feeding rate
+id:foodperiod
+name:Feeding period
 type:d 0 2 1 ~Low~Medium~High
 
