Index: experiments/frams/foraminifera/data/scripts/foraminifera.expdef
===================================================================
--- experiments/frams/foraminifera/data/scripts/foraminifera.expdef	(revision 525)
+++ experiments/frams/foraminifera/data/scripts/foraminifera.expdef	(revision 552)
@@ -27,5 +27,4 @@
 global retColors;
 global curColor;
-global dir_change_sec;
 global max_chamber_volume;
 global movePerStep;
@@ -91,5 +90,5 @@
 
 	//time
-	ExpProperties.secPerStep = 480;
+	ExpProperties.secPerStep = 300;
 	ExpProperties.foramSpeedMmPerMin = 0.05;
 	movePerStep = getMovePerStep();
@@ -106,5 +105,5 @@
 	ExpProperties.repro_time = 720;
 	ExpProperties.gametoPeriod = 21600;
-	ExpProperties.divisionCost = 15.6;
+	ExpProperties.divisionCost = 20;
 	reprocounter = 0;
 
@@ -115,5 +114,5 @@
 	curColor = retColors[0];
 	//morphology
-	dir_change_sec = 30000;
+	ExpProperties.dir_change_sec = 30000;
 	ExpProperties.zone1_range = micronsToFrams(1000);
 	ExpProperties.zone2_range = micronsToFrams(3000);
@@ -155,8 +154,8 @@
 	phase = "low";
 	nutrientSqrCm = 10;
-	ExpProperties.foodperiod = 19200;
+	ExpProperties.foodperiod = 14400;
 	ExpProperties.foodPeriodChange = 0;
 	ExpProperties.nutrientradius = micronsToFrams(10);
-	ExpProperties.energy_nut = 100 * energyFromVolume(ExpProperties.nutrientradius,1);
+	ExpProperties.energy_nut = 200 * energyFromVolume(ExpProperties.nutrientradius,1);
 	ExpProperties.nutrient_pop = Math.pow(framsToMicrons(World.wrldsiz)*0.0001,2)/nutrientSqrCm;
 	ExpProperties.ingestion = 0.25;
@@ -516,7 +515,8 @@
 	}
 	//random move
-	else if (Simulator.stepNumber%int(dir_change_sec/ExpProperties.secPerStep) == 0)
+	else if (cr.data->lifeparams->dir_counter >= int(ExpProperties.dir_change_sec/ExpProperties.secPerStep))
 	{
 		cr.data->lifeparams->dir = randomDir();
+		cr.data->lifeparams->dir_counter = 0;
 		cr.localDrive = cr.data->lifeparams->dir;
 		moveEnergyDec(cr);
@@ -632,8 +632,12 @@
 			{
 				log(createLogVector(cr, cr.data->lifeparams->max_energy_level),ExpProperties.logPref+"fossil_log.txt");
+				log(createLogVector(cr, cr.lifespan),ExpProperties.logPref+"lifespan_log.txt");
 			}			
 			Populations[0].kill(cr);
 			return;
 		}
+
+		//update direction change counter
+		cr.data->lifeparams->dir_counter += 1;
 
 		foramMove(cr);
@@ -882,5 +886,5 @@
 id:maxSteps
 name:Stop after the given number of simulation steps
-type:d 0 1000000 0
+type:d 0 10000000 0
 
 property:
@@ -900,4 +904,10 @@
 name:Ratio of successful gamets
 type:f 0.001
+group:Foraminifera
+
+property:
+id:dir_change_sec
+name:Number of seconds before direction change
+type:d 30000
 group:Foraminifera
 
Index: experiments/frams/foraminifera/data/scripts/foraminifera.inc
===================================================================
--- experiments/frams/foraminifera/data/scripts/foraminifera.inc	(revision 525)
+++ experiments/frams/foraminifera/data/scripts/foraminifera.inc	(revision 552)
@@ -5,5 +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"];
+	retColors = ["1.0,1.0,1.0", "1.0,1.0,0.0"];
 	chambers = [ ["p:sh=1, sx=0.2, sy=0.2, sz=0.2, rz=3.14159265358979,",
 "p:0.18421219587326, 0.13, sh=1, sx=0.21, sy=0.21, sz=0.21,",
@@ -55,9 +55,9 @@
 	{
 		mode->cr.data->genes = String.deserialize(String.serialize(mode->genes)); 
-		mode->cr.data->lifeparams = {"max_energy_level" : mode->energy0, "gen" : 0,  "hibernated" : 0, "species" : mode->species, "reproduce" : 0, "dir" : randomDir(), "chamber_growth" : -1, "division_time" : -1};
+		mode->cr.data->lifeparams = {"max_energy_level" : mode->energy0, "gen" : 0,  "hibernated" : 0, "species" : mode->species, "reproduce" : 0, "dir" : randomDir(), "dir_counter" : Math.random(ExpProperties.dir_change_sec), "chamber_growth" : -1, "division_time" : -1};
 	}
 	else if (mode->opt  == 1) //child
 	{
-		mode->cr.data->lifeparams = {"max_energy_level" : mode->energy0, "gen" : 1 - mode->parent_lifeparams->gen,  "hibernated" : 0, "species" : mode->parent_lifeparams->species, "reproduce" : 0, "dir" : randomDir(), "chamber_growth" : -1, "division_time" : -1};
+		mode->cr.data->lifeparams = {"max_energy_level" : mode->energy0, "gen" : 1 - mode->parent_lifeparams->gen,  "hibernated" : 0, "species" : mode->parent_lifeparams->species, "reproduce" : 0, "dir" : randomDir(), "dir_counter" : Math.random(ExpProperties.dir_change_sec), "chamber_growth" : -1, "division_time" : -1};
 		mode->cr.data->genes = String.deserialize(String.serialize(mode->parent_genes));
 	}
@@ -113,4 +113,6 @@
 				log(createLogVector(parent2, parent2.energy),ExpProperties.logPref+"repro_energies_log.txt");
 				log(createLogVector(parent, number),ExpProperties.logPref+"repro_num_log.txt");
+				log(createLogVector(parent, parent.lifespan),ExpProperties.logPref+"lifespan_log.txt");
+				log(createLogVector(parent2, parent2.lifespan),ExpProperties.logPref+"lifespan_log.txt");
 		}	
 	}
@@ -134,4 +136,5 @@
 			log(createLogVector(parent, parent.energy),ExpProperties.logPref+"repro_energies_log.txt");
 			log(createLogVector(parent, number),ExpProperties.logPref+"repro_num_log.txt");
+			log(createLogVector(parent, parent.lifespan),ExpProperties.logPref+"lifespan_log.txt");
 		}	
 
