Index: experiments/frams/foraminifera/data/scripts/foraminifera.expdef
===================================================================
--- experiments/frams/foraminifera/data/scripts/foraminifera.expdef	(revision 470)
+++ experiments/frams/foraminifera/data/scripts/foraminifera.expdef	(revision 474)
@@ -31,4 +31,5 @@
 global max_chamber_energ;
 global dir_change;
+global movePerStep;
 
 @include "foraminifera.inc"
@@ -81,4 +82,9 @@
 	ExpParams.autorestart = 0;
 
+	//time
+	ExpParams.secPerStep = 60;
+	ExpParams.foramSpeedMmPerMin = 0.1;
+	movePerStep = getMovePerStep();
+
 	//ExpParams.visualize = 1; //uncomment to visualize reticulopodia and indicate nutrients positions
 
@@ -87,11 +93,11 @@
 	//reproduction
 	ExpParams.foramPop = 10;	
-	ExpParams.crossprob = 0.4;
-	ExpParams.mutationprob = 0.2;
+	ExpParams.crossprob = 0;
+	ExpParams.mutationprob = 0;
 	ExpParams.repro_time = 20;
 	reprocounter = 0;
 
 	//morphology
-	dir_change = 500;
+	dir_change = 30000;
 	ExpParams.zone1_range = micronsToFrams(3000);
 	ExpParams.zone2_range = micronsToFrams(6000);
@@ -114,11 +120,11 @@
 	ExpParams.min_repro_energ_diplo = 6;
 
-	ExpParams.e_meta = 0.0002; 
-	ExpParams.energy_hib = 0.0001;
-	ExpParams.energy_move = 0.00025;
+	ExpParams.e_meta = 0.00005; 
+	ExpParams.energy_hib = 0.000025;
+	ExpParams.energy_move = 0.00005;
 
 	ExpParams.energies0_haplo = max_chamber_energ[0][0] - 0.001*max_chamber_energ[0][0];
 	ExpParams.energies0_diplo = max_chamber_energ[1][0] - 0.001*max_chamber_energ[1][0];
-	ExpParams.feedtrans = 0.5;
+	ExpParams.feedtrans = 0.125;
 	ExpParams.e_repro_cost_haplo = 0.7; 
 	ExpParams.e_repro_cost_diplo = 0.3;
@@ -128,6 +134,6 @@
 	ExpParams.energy_nut = 100 * Math.pow(ExpParams.nutrientsize, 3);
 	ExpParams.nutrientPop = 1;
-	ExpParams.feedrate = 0.1;
-	nutrientenergywaiting = ExpParams.energy_nut;
+	ExpParams.feedrate = 100;
+	nutrientenergywaiting = 0;
 	ExpState.totaltestedcr = 0;
 	ExpState.nutrient = "";
@@ -135,4 +141,9 @@
 
 @include "standard_placement.inc"
+
+function getMovePerStep()
+{
+	return micronsToFrams((ExpParams.foramSpeedMmPerMin/60)*1000)*ExpParams.secPerStep;
+}
 
 function micronsToFrams(micrometers)
@@ -247,5 +258,5 @@
 function setForamMeta(cr, gen)
 {
-	cr.idleen = ExpParams.e_meta * max_chamber_energ[gen][Math.min(lastChamberNum(cr), max_chamber_energ[gen].size-1)];
+	cr.idleen = (ExpParams.e_meta * max_chamber_energ[gen][Math.min(lastChamberNum(cr), max_chamber_energ[gen].size-1)])*ExpParams.secPerStep;
 }
 
@@ -295,19 +306,22 @@
 function foramGrow(cr, chamber_num)
 {
-	var geno = createForamGenotype(cr.user2["gen"], cr.user2["species"], chamber_num+1);
-	var cr2 = Populations[0].add(geno);
-
-	cr2.energy0 = cr.energy;
-	cr2.energy = cr2.energy0;
-
-	setGenotype({"cr" : cr2, "parent_user1" : cr.user1, "parent_user2" : cr.user2, "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"]);
-
-	if (visualization(cr))
-	{
-		Populations[2].delete(cr.user3);
-	}
-	Populations[0].delete(cr);
+	if ((chamber_num+1) < chambers[cr.user2["species"]].size)
+	{
+		var geno = createForamGenotype(cr.user2["gen"], cr.user2["species"], chamber_num+1);
+		var cr2 = Populations[0].add(geno);
+
+		cr2.energy0 = cr.energy;
+		cr2.energy = cr2.energy0;
+
+		setGenotype({"cr" : cr2, "parent_user1" : cr.user1, "parent_user2" : cr.user2, "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"]);
+
+		if (visualization(cr))
+		{
+			Populations[2].delete(cr.user3);
+		}
+		Populations[0].delete(cr);
+	}
 }
 
@@ -352,5 +366,5 @@
 		{
 			mindistvec.normalize();
-			mindistvec.scale(-0.08);
+			mindistvec.scale(-1*movePerStep);
 			cr.localDrive = mindistvec;
 			moveEnergyDec(cr);
@@ -361,5 +375,7 @@
 	
 	else
+	{
 		return 0;
+	}
 }
 
@@ -368,5 +384,5 @@
 	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)];
+		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;
 	}
 }
@@ -399,12 +415,22 @@
 	}
 	//random move
-	else if (cr.lifespan%dir_change == 0)
-	{
-		var dir = (Math.rndUni(-ExpParams.zone2_range, ExpParams.zone2_range), Math.rndUni(-ExpParams.zone2_range, ExpParams.zone2_range), 0);	
-		dir.normalize();
-		dir.scale(-0.08);
-		cr.localDrive = dir;
+	else if (cr.lifespan%(dir_change/ExpParams.secPerStep) == 0)
+	{
+		cr.user2["dir"] = randomDir();
+		cr.localDrive = cr.user2["dir"];
 		moveEnergyDec(cr);
 	}
+	else
+	{
+		cr.localDrive = cr.user2["dir"];
+	}
+}
+
+function randomDir()
+{
+	var dir = (Math.rndUni(-ExpParams.zone2_range, ExpParams.zone2_range), Math.rndUni(-ExpParams.zone2_range, ExpParams.zone2_range), 0);	
+	dir.normalize();
+	dir.scale(-1*movePerStep);
+	return dir;
 }
 
@@ -412,5 +438,5 @@
 {
 	cr1.localDrive = XYZ.new(0,0,0);
-	var e = cr2.getPart(0).ing * ExpParams.feedtrans; //TODO efficiency dependent on age
+	var e = ExpParams.feedtrans*ExpParams.secPerStep; //TODO efficiency dependent on age
 	e = Math.min(cr2.energy, e) + 0.0000001;
 	//Simulator.print("transferring "+e+" to "+cr1.name+" from "+cr2.name+" ("+cr2.energy+")");
@@ -431,5 +457,5 @@
 	else
 	{
-		cr.idleen = ExpParams.energy_hib * max_chamber_energ[cr.user2["gen"]][Math.min(lastChamberNum(cr), (max_chamber_energ[cr.user2["gen"]].size)-1)]; //hibernate
+		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.user2["hibernated"] = 1 - cr.user2["hibernated"];
@@ -536,6 +562,6 @@
 function nutrientGrowth()
 {
-	nutrientenergywaiting = nutrientenergywaiting + ExpParams.feedrate;
-	if (nutrientenergywaiting > ExpParams.energy_nut)
+	nutrientenergywaiting = nutrientenergywaiting + 1;
+	if (nutrientenergywaiting > ExpParams.feedrate/ExpParams.secPerStep)
 	{
 		for (var i = 0; i < ExpParams.nutrientPop; i++)
@@ -564,5 +590,5 @@
 	//reproduction --------------------------------------------
 	reprocounter += 1;
-	if (reprocounter > ExpParams.repro_time)
+	if (reprocounter*ExpParams.secPerStep > ExpParams.repro_time)
 	{
 		reprocounter = 0;
@@ -618,5 +644,5 @@
 
 	log(log_numbers, "forams_log.txt");
-        log(log_energies,  "energies_log.txt");
+    log(log_energies,  "energies_log.txt");
 }
 
@@ -649,4 +675,18 @@
 name:Stop after the given number of simulation steps
 type:d 0 1000000 0
+
+prop:
+id:foramSpeedMmPerMin
+name:Speed of foraminfera in mm/min
+type:f 0.1
+flags: 16
+group:Foraminifera
+
+prop:
+id:secPerStep
+name:Seconds per simulation step
+type:f 60.0
+flags: 16
+group:Foraminifera
 
 prop:
@@ -798,5 +838,5 @@
 id:feedrate
 name:Feeding rate
-type:f 0 100
+type:f 0 1000000
 group:Energy
 help:How fast energy is created in the world
@@ -841,5 +881,5 @@
 id:repro_time
 name:Time before reproduction
-type:d 0 1000
+type:d 0 10000
 
 prop:
Index: experiments/frams/foraminifera/data/scripts/foraminifera.inc
===================================================================
--- experiments/frams/foraminifera/data/scripts/foraminifera.inc	(revision 470)
+++ experiments/frams/foraminifera/data/scripts/foraminifera.inc	(revision 474)
@@ -56,9 +56,9 @@
 	{
 		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};
+		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};
+		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"];
 	}
Index: experiments/frams/foraminifera/data/scripts/foraminifera.show
===================================================================
--- experiments/frams/foraminifera/data/scripts/foraminifera.show	(revision 470)
+++ experiments/frams/foraminifera/data/scripts/foraminifera.show	(revision 474)
@@ -23,5 +23,5 @@
 	GLDisplay.minfps = 10;
 	TrackingCam.cam_h = 15; //more side view
-	Params = { "feedrate" : [0.05,0.1,0.2], "feedtrans" : [0.01,0.05,0.1],"energy_nut" :[0.5,1.5,3.0], "stress" : [0,1], "visualize" : [0,1]};
+	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]};
 	ShowParams.visualize=1;
 }
@@ -30,7 +30,6 @@
 {
 	//just a draft, this function and all constants in expdef need serious review
-	var foramSpeedMmPerMin=0.1; //0.1 mm/minute based on http://drs.nio.org/drs/bitstream/handle/2264/418/ONGC_Bull_37%281%29_53.pdf
-	var localDriveMicronsPerStep=framsToMicrons(0.08); //0.08 is used in expdef as distance (in frams units) per simulation step. TODO Use a variable/constant/function from expdef instead of copying this value here
-	var foramSpeedMmPerSec=foramSpeedMmPerMin/60;
+	var localDriveMicronsPerStep=framsToMicrons(getMovePerStep());
+	var foramSpeedMmPerSec=ExpParams.foramSpeedMmPerMin/60;
 	var localDriveMmPerStep=localDriveMicronsPerStep/1000;
 	var localDriveMmPerSec=localDriveMmPerStep*Simulator.simspeed;
@@ -93,5 +92,5 @@
 id:feedtrans
 name:Energy transfer
-type:d 0 2 1 ~0.01~0.05~0.1
+type:d 0 2 1 ~0.05~0.125~0.25
 
 prop:
