1 | expdef:
|
---|
2 | name:Reproduction of benthic foraminifera
|
---|
3 | info:~
|
---|
4 | Genes and parameter values which control reproduction are stored in user1 and user2 fields.
|
---|
5 |
|
---|
6 | user1:
|
---|
7 | genes which are not encoded in Ff genotype:
|
---|
8 | min_repro_energy - Minimum energy necessary for reproduction
|
---|
9 | hibernation - Defines foram behavior in the case of no nutrients
|
---|
10 |
|
---|
11 | user2:
|
---|
12 | Physiological parameters of foraminifera:
|
---|
13 | max_energy_level - maximum energy level reached so far
|
---|
14 | gen - generation: 0 haploid, 1 diploid
|
---|
15 | species - species: 0 hibernating 1 not hibernating
|
---|
16 | hibernated - 0/1 foram isn't/is hibernated
|
---|
17 | reproduce - 0/1 foram isn't/is ready for reproduction
|
---|
18 | ~
|
---|
19 | code:~
|
---|
20 |
|
---|
21 | /*
|
---|
22 | changes 2015-06-24:
|
---|
23 | - xxx.get(...) changed to xxx[...]
|
---|
24 | - xxx.set(...,...) changed to xxx[...]=...
|
---|
25 | - function placeRandomlyNotColliding(cr) explicitly called when adding a new creature, and removed collision checking from onForamsBorn() which is also called when "growing" (since "growing" is implemented as creating a new creature in place of the old one, so onForamsBorn() is also called)
|
---|
26 | - use creature's center (not the bbox corner) when growing
|
---|
27 | - added "S" receptor to visualize the difference between diplo and haplo generations
|
---|
28 | - signal.value is a MechPart (a reference) so it does not have to be updated after changing the object location
|
---|
29 | */
|
---|
30 |
|
---|
31 | global nutrientenergywaiting;
|
---|
32 | global reprocounter;
|
---|
33 | global colors;
|
---|
34 | global chambers;
|
---|
35 | global o;
|
---|
36 | global max_chamber_energ;
|
---|
37 | global dir_change;
|
---|
38 |
|
---|
39 | @include "foraminifera.inc"
|
---|
40 |
|
---|
41 | // -------------------------------- experiment begin --------------------------------
|
---|
42 |
|
---|
43 | function onExpDefLoad()
|
---|
44 | {
|
---|
45 | // define genotype and creature groups
|
---|
46 | GenePools.clear();
|
---|
47 | Populations.clear();
|
---|
48 | GenePools[0].name = "Unused";
|
---|
49 |
|
---|
50 | var pop = Populations[0];
|
---|
51 | pop.name = "Forams";
|
---|
52 | pop.en_assim = 0;
|
---|
53 | pop.nnsim = 0;
|
---|
54 | pop.enableperf = 1;
|
---|
55 | pop.death = 1;
|
---|
56 | pop.energy = 1;
|
---|
57 | pop.selfmask = 0x10001;
|
---|
58 | pop.othermask = 0x20001;
|
---|
59 | //pop.selfmask = 0x20002; pop.othermask = 0x10002;
|
---|
60 | pop.perfperiod = 25;
|
---|
61 |
|
---|
62 | pop = Populations.addGroup("Nutrients");
|
---|
63 | pop.nnsim = 0;
|
---|
64 | pop.enableperf = 0;
|
---|
65 | pop.death = 1;
|
---|
66 | pop.energy = 1;
|
---|
67 | pop.selfmask = 0x20002;
|
---|
68 | pop.othermask = 0x10000;
|
---|
69 | //pop.othermask = 0x10002;
|
---|
70 |
|
---|
71 | //ExpParams.showRet = 1; //uncomment to show reticulopodia
|
---|
72 |
|
---|
73 | pop = Populations.addGroup("Reticulopodia");
|
---|
74 | pop.nnsim = 0;
|
---|
75 | pop.enableperf = 0;
|
---|
76 | pop.death = 0;
|
---|
77 | pop.energy = 0;
|
---|
78 | pop.selfmask = 0x20002;
|
---|
79 | pop.othermask = 0x10000;
|
---|
80 |
|
---|
81 | //world
|
---|
82 | SignalView.mode = 1;
|
---|
83 | ExpParams.world_size = scale(40000);
|
---|
84 | World.wrldwat = 200;
|
---|
85 | World.wrldsiz = ExpParams.world_size;
|
---|
86 | World.wrldbnd = 1;
|
---|
87 | ExpParams.stress = 1;
|
---|
88 | ExpParams.creath = -0.99; //just above the bottom
|
---|
89 | ExpParams.autorestart = 0;
|
---|
90 |
|
---|
91 | //ExpParams.logging = 1; //uncomment to enable logging simulation parameters to log files
|
---|
92 |
|
---|
93 | //reproduction
|
---|
94 | ExpParams.foramPop = 10;
|
---|
95 | ExpParams.crossprob = 0.4;
|
---|
96 | ExpParams.mutationprob = 0.2;
|
---|
97 | ExpParams.repro_time = 20;
|
---|
98 | reprocounter = 0;
|
---|
99 |
|
---|
100 | //morphology
|
---|
101 | dir_change = 500;
|
---|
102 | ExpParams.zone1_range = scale(5000);
|
---|
103 | ExpParams.zone2_range = scale(8000);
|
---|
104 | init_chambers();
|
---|
105 | ExpParams.chamber_proculus_haplo = scale(50);
|
---|
106 | ExpParams.chamber_difference_haplo = 0.0;
|
---|
107 | ExpParams.chamber_proculus_diplo = scale(20);
|
---|
108 | ExpParams.chamber_difference_diplo = 0.2;
|
---|
109 | max_chamber_energ = [Vector.new(), Vector.new()];
|
---|
110 | for (var j = 0; j < 2; j++)
|
---|
111 | {
|
---|
112 | for (var i = 0; i < chambers[0].size; i++)
|
---|
113 | {
|
---|
114 | max_chamber_energ[j].add(((Math.pow(getProperty(j, "chamber_proculus"),3) + Math.pow(getProperty(j, "chamber_proculus") + (i) * getProperty(j, "chamber_difference"),3))*(i+1))/2);
|
---|
115 | }
|
---|
116 | }
|
---|
117 |
|
---|
118 | //energetics
|
---|
119 | ExpParams.min_repro_energ_haplo = 4;
|
---|
120 | ExpParams.min_repro_energ_diplo = 6;
|
---|
121 |
|
---|
122 | ExpParams.e_meta = 0.0002;
|
---|
123 | ExpParams.energy_hib = 0.0001;
|
---|
124 | ExpParams.energy_move = 0.00025;
|
---|
125 |
|
---|
126 | ExpParams.energies0_haplo = max_chamber_energ[0][0] - 0.001*max_chamber_energ[0][0];
|
---|
127 | ExpParams.energies0_diplo = max_chamber_energ[1][0] - 0.001*max_chamber_energ[1][0];
|
---|
128 | ExpParams.feedtrans = 0.5;
|
---|
129 | ExpParams.e_repro_cost_haplo = 0.7;
|
---|
130 | ExpParams.e_repro_cost_diplo = 0.3;
|
---|
131 |
|
---|
132 | //nutrients
|
---|
133 | ExpParams.nutrientsize = scale(10);
|
---|
134 | ExpParams.energy_nut = 100 * Math.pow(ExpParams.nutrientsize, 3);
|
---|
135 | ExpParams.nutrientPop = 1;
|
---|
136 | ExpParams.feedrate = 0.1;
|
---|
137 | nutrientenergywaiting = ExpParams.energy_nut;
|
---|
138 | ExpState.totaltestedcr = 0;
|
---|
139 | ExpState.nutrient = "";
|
---|
140 | }
|
---|
141 |
|
---|
142 | @include "standard_placement.inc"
|
---|
143 |
|
---|
144 | function scale(x)
|
---|
145 | {
|
---|
146 | return x*0.025;
|
---|
147 | }
|
---|
148 |
|
---|
149 | function getProperty(gen, prop_id)
|
---|
150 | {
|
---|
151 | var ploid = "haplo";
|
---|
152 | if (gen == 1) ploid = "diplo";
|
---|
153 | return ExpParams.[prop_id + "_" + ploid];
|
---|
154 | }
|
---|
155 |
|
---|
156 | function addInitialForam(species, i)
|
---|
157 | {
|
---|
158 | var geno = createForamGenotype(0, species, 0);
|
---|
159 | var cr = Populations[0].add(geno);
|
---|
160 | cr.name = "Initial creature" + species + "_" + i;
|
---|
161 | placeCreatureRandomly(cr, 0, 0);
|
---|
162 | cr.energy0 = getProperty(0, "energies0");
|
---|
163 | cr.energy = cr.energy0;
|
---|
164 | setGenotype({"opt" : 0, "cr" : cr, "species" : species});
|
---|
165 | }
|
---|
166 |
|
---|
167 | function onExpInit()
|
---|
168 | {
|
---|
169 | Populations[0].clear();
|
---|
170 | Populations[1].clear();
|
---|
171 | Populations[2].clear();
|
---|
172 |
|
---|
173 | for (var i = 0; i < ExpParams.foramPop; i++)
|
---|
174 | {
|
---|
175 | addInitialForam(0, i);
|
---|
176 | addInitialForam(1, i);
|
---|
177 | }
|
---|
178 | o = Populations[0][0].getMechPart(0).orient.clone();
|
---|
179 | ExpState.totaltestedcr = 0;
|
---|
180 | nutrientenergywaiting = ExpParams.energy_nut;
|
---|
181 | }
|
---|
182 |
|
---|
183 | function onExpLoad()
|
---|
184 | {
|
---|
185 | for (var pop in Populations)
|
---|
186 | pop.clear();
|
---|
187 |
|
---|
188 | Loader.addClass(sim_params.*);
|
---|
189 | Loader.setBreakLabel(Loader.BeforeUnknown, "onExpLoad_Unknown");
|
---|
190 | Loader.run();
|
---|
191 |
|
---|
192 | Simulator.print("Loaded " + Populations[0].size + " Forams and " + Populations[1].size + " nutrient objects");
|
---|
193 | }
|
---|
194 |
|
---|
195 | function onExpLoad_Unknown()
|
---|
196 | {
|
---|
197 | if (Loader.objectName == "org") // saved by the old expdef
|
---|
198 | {
|
---|
199 | var g = Genotype.newFromString("");
|
---|
200 | Loader.currentObject = g;
|
---|
201 | Interface.makeFrom(g).setAllDefault();
|
---|
202 | Loader.loadObject();
|
---|
203 | var cr = Populations[0].add(g);
|
---|
204 | if (cr != null)
|
---|
205 | {
|
---|
206 | //cr.rotate(0,0,Math.rnd01*Math.twopi);
|
---|
207 | if ((typeof(g.user1) == "Vector") && (g.user1.size >= 3))
|
---|
208 | {
|
---|
209 | // [x,y,energy]
|
---|
210 | cr.move(g.user1[0] - cr.center_x, g.user1[1] - cr.center_y, 0);
|
---|
211 | cr.energy = g.user1[2];
|
---|
212 | }
|
---|
213 | else
|
---|
214 | {
|
---|
215 | cr.move(Math.rnd01 * World.wrldsiz - cr.center_x, Math.rnd01 * World.wrldsiz - cr.center_y, 0);
|
---|
216 | }
|
---|
217 | }
|
---|
218 | }
|
---|
219 | else if (Loader.objectName == "Creature")
|
---|
220 | {
|
---|
221 | Loader.currentObject = CreatureSnapshot.new();
|
---|
222 | Loader.loadObject();
|
---|
223 | Populations[0].add(Loader.currentObject);
|
---|
224 | }
|
---|
225 | }
|
---|
226 |
|
---|
227 | function onExpSave()
|
---|
228 | {
|
---|
229 | File.writeComment("saved by '%s.expdef'" % Simulator.expdef);
|
---|
230 |
|
---|
231 | var tmpvec = [], i;
|
---|
232 |
|
---|
233 | for(var cr in Populations[1])
|
---|
234 | tmpvec.add([cr.center_x, cr.center_y, cr.energy]);
|
---|
235 |
|
---|
236 | ExpState.nutrient = tmpvec;
|
---|
237 | File.writeObject(sim_params.*);
|
---|
238 | ExpState.nutrient = null; //vectors are only created for saving and then discardedsetForam
|
---|
239 |
|
---|
240 | for (var cr in Populations[0])
|
---|
241 | File.writeObject(cr);
|
---|
242 | }
|
---|
243 |
|
---|
244 | // -------------------------------- experiment end --------------------------------
|
---|
245 |
|
---|
246 | // -------------------------------- foram begin -----------------------------------
|
---|
247 |
|
---|
248 | function setForamMeta(cr, gen)
|
---|
249 | {
|
---|
250 | cr.idleen = ExpParams.e_meta * max_chamber_energ[gen][Math.min(lastChamberNum(cr), max_chamber_energ[gen].size-1)];
|
---|
251 | }
|
---|
252 |
|
---|
253 | function lastChamberNum(cr)
|
---|
254 | {
|
---|
255 | return cr.numparts-1;
|
---|
256 | }
|
---|
257 |
|
---|
258 | function onForamsBorn(cr)
|
---|
259 | {
|
---|
260 | setForamMeta(cr, 1);
|
---|
261 | if (ExpParams.showRet == 1)
|
---|
262 | {
|
---|
263 | var ret = Populations[2].add("//0\np:sh=3,sx=0.01,sy="+ExpParams.zone1_range+",sz="+ExpParams.zone1_range+",ry=1.57");
|
---|
264 | cr.user3 = ret;
|
---|
265 | }
|
---|
266 | }
|
---|
267 |
|
---|
268 | function placeRandomlyNotColliding(cr)
|
---|
269 | {
|
---|
270 | var retry = 100; //try 100 times
|
---|
271 | while (retry--)
|
---|
272 | {
|
---|
273 | placeCreatureRandomly(cr, 0, 0);
|
---|
274 | if (!cr.boundingBoxCollisions(0))
|
---|
275 | return cr;
|
---|
276 | }
|
---|
277 |
|
---|
278 | Populations[0].delete(cr);
|
---|
279 | }
|
---|
280 |
|
---|
281 | function foramGrow(cr, chamber_num)
|
---|
282 | {
|
---|
283 | var geno = createForamGenotype(cr.user2["gen"], cr.user2["species"], chamber_num+1);
|
---|
284 | var cr2 = Populations[0].add(geno);
|
---|
285 |
|
---|
286 | cr2.energy0 = cr.energy;
|
---|
287 | cr2.energy = cr2.energy0;
|
---|
288 |
|
---|
289 | setGenotype({"cr" : cr2, "parent_user1" : cr.user1, "parent_user2" : cr.user2, "opt" : 2});
|
---|
290 | cr2.moveAbs(cr.center_x - cr2.size_x / 2, cr.center_y - cr2.size_y / 2, cr.pos_z);
|
---|
291 | setForamMeta(cr2, cr2.user2["gen"]);
|
---|
292 |
|
---|
293 | if (ExpParams.showRet == 1)
|
---|
294 | {
|
---|
295 | Populations[2].delete(cr.user3);
|
---|
296 | }
|
---|
297 | Populations[0].delete(cr);
|
---|
298 | }
|
---|
299 |
|
---|
300 | function stepToNearest(cr, range)
|
---|
301 | {
|
---|
302 | var p = cr.getMechPart(0);
|
---|
303 | var n = cr.signals.receiveSet("nutrient", ExpParams.zone2_range);
|
---|
304 |
|
---|
305 | //if signals are received find the source of the nearest
|
---|
306 | if (n.size > 0)
|
---|
307 | {
|
---|
308 | var i;
|
---|
309 | var mp;
|
---|
310 | var distvec = XYZ.new(0, 0, 0);
|
---|
311 | var dist;
|
---|
312 | var mindist = 100000000000;
|
---|
313 | var mindistvec = null;
|
---|
314 | var eating = 0;
|
---|
315 |
|
---|
316 | for (i = 0; i < n.size; i++)
|
---|
317 | {
|
---|
318 | mp = n[i].value.getMechPart(0);
|
---|
319 | distvec.set(mp.pos);
|
---|
320 | distvec.sub(p.pos);
|
---|
321 | dist = distvec.length;
|
---|
322 | if (dist < ExpParams.zone1_range)
|
---|
323 | {
|
---|
324 | if (n[i].value != null)
|
---|
325 | {
|
---|
326 | energyTransfer(cr, n[i].value);
|
---|
327 | eating = 1;
|
---|
328 | }
|
---|
329 | }
|
---|
330 | else if (eating == 0 && cr.user2["hibernated"] == 0 && dist < mindist)
|
---|
331 | {
|
---|
332 | mindist = dist;
|
---|
333 | mindistvec = distvec.clone();
|
---|
334 | }
|
---|
335 | }
|
---|
336 |
|
---|
337 | if (!eating && cr.user2["hibernated"] == 0)
|
---|
338 | {
|
---|
339 | mindistvec.normalize();
|
---|
340 | mindistvec.scale(-0.08);
|
---|
341 | cr.localDrive = mindistvec;
|
---|
342 | moveEnergyDec(cr);
|
---|
343 | }
|
---|
344 |
|
---|
345 | return 1;
|
---|
346 | }
|
---|
347 |
|
---|
348 | else
|
---|
349 | return 0;
|
---|
350 | }
|
---|
351 |
|
---|
352 | function moveEnergyDec(cr)
|
---|
353 | {
|
---|
354 | if (cr.user2["hibernated"] == 0)
|
---|
355 | {
|
---|
356 | cr.energy_m += ExpParams.energy_move * max_chamber_energ[cr.user2["gen"]][Math.min(lastChamberNum(cr), (max_chamber_energ[cr.user2["gen"]].size)-1)];
|
---|
357 | }
|
---|
358 | }
|
---|
359 |
|
---|
360 | function foramMove(cr)
|
---|
361 | {
|
---|
362 | //TODO moving inside sediment?
|
---|
363 |
|
---|
364 | //adjustment in z axis
|
---|
365 | cr.moveAbs(cr.pos_x, cr.pos_y, 0);
|
---|
366 |
|
---|
367 | //are there any nutrients in zone 1 or 2?
|
---|
368 | {
|
---|
369 | var moved = stepToNearest(ExpParams.zone2_range); //TODO weighted sum of distance and energy
|
---|
370 | if (moved==1)
|
---|
371 | {
|
---|
372 | return;
|
---|
373 | }
|
---|
374 | }
|
---|
375 |
|
---|
376 | //no nutrients in zone 2
|
---|
377 | var hibernation = 0;
|
---|
378 | if (cr.user2["gen"] == 0) hibernation = cr.user1["hibernation"];
|
---|
379 | else hibernation = cr.user1[0]["hibernation"];
|
---|
380 | //hibernation
|
---|
381 | if (hibernation == 1)
|
---|
382 | {
|
---|
383 | reverseHib(cr);
|
---|
384 | cr.localDrive = XYZ.new(0,0,0);
|
---|
385 | }
|
---|
386 | //random move
|
---|
387 | else if (cr.lifespan%dir_change == 0)
|
---|
388 | {
|
---|
389 | var dir = (Math.rndUni(-ExpParams.zone2_range, ExpParams.zone2_range), Math.rndUni(-ExpParams.zone2_range, ExpParams.zone2_range), 0);//(0.1 * Math.rnd01, 0.1 * Math.rnd01, 0);
|
---|
390 | dir.normalize();
|
---|
391 | dir.scale(-0.08);
|
---|
392 | cr.localDrive = dir;
|
---|
393 | moveEnergyDec(cr);
|
---|
394 | }
|
---|
395 | }
|
---|
396 |
|
---|
397 | function energyTransfer(cr1, cr2)
|
---|
398 | {
|
---|
399 | cr1.localDrive = XYZ.new(0,0,0);
|
---|
400 | var e = cr2.getPart(0).ing * ExpParams.feedtrans; //TODO efficiency dependent on age
|
---|
401 | e = Math.min(cr2.energy, e) + 0.0000001;
|
---|
402 | //Simulator.print("transferring "+e+" to "+cr1.name+" from "+cr2.name+" ("+cr2.energy+")");
|
---|
403 | cr2.energy_m = cr2.energy_m + e;
|
---|
404 | cr1.energy_p = cr1.energy_p + e;
|
---|
405 | if (cr1.user2["hibernated"] == 1)
|
---|
406 | {
|
---|
407 | reverseHib(cr1);
|
---|
408 | }
|
---|
409 | }
|
---|
410 |
|
---|
411 | function reverseHib(cr)
|
---|
412 | {
|
---|
413 | if (cr.user2["hibernated"] == 1)
|
---|
414 | {
|
---|
415 | setForamMeta(cr, cr.user2["gen"]); //unhibernate
|
---|
416 | }
|
---|
417 | else
|
---|
418 | {
|
---|
419 | cr.idleen = ExpParams.energy_hib * max_chamber_energ[cr.user2["gen"]][Math.min(lastChamberNum(cr), (max_chamber_energ[cr.user2["gen"]].size)-1)]; //hibernate
|
---|
420 | }
|
---|
421 | cr.user2["hibernated"] = 1 - cr.user2["hibernated"];
|
---|
422 | }
|
---|
423 |
|
---|
424 | function onForamsStep(cr)
|
---|
425 | {
|
---|
426 | cr.getMechPart(0).orient.set(o);
|
---|
427 | if (ExpParams.showRet == 1)
|
---|
428 | 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"));
|
---|
429 |
|
---|
430 | if (deathConditions(cr) == 1)
|
---|
431 | {
|
---|
432 | Populations[0].kill(cr);
|
---|
433 | return;
|
---|
434 | }
|
---|
435 |
|
---|
436 | foramMove(cr);
|
---|
437 |
|
---|
438 | var repro = foramReproduce(cr);
|
---|
439 | if (repro == 1)
|
---|
440 | {
|
---|
441 | return;
|
---|
442 | }
|
---|
443 |
|
---|
444 | cr.user2["max_energy_level"] = Math.max(cr.energy, cr.user2["max_energy_level"]);
|
---|
445 | if (lastChamberNum(cr) <= chambers[0].size-1)
|
---|
446 | {
|
---|
447 | if ((cr.user2["max_energy_level"] >= max_chamber_energ[cr.user2["gen"]][lastChamberNum(cr)]))
|
---|
448 | {
|
---|
449 | foramGrow(cr, lastChamberNum(cr));
|
---|
450 | }
|
---|
451 | }
|
---|
452 | }
|
---|
453 |
|
---|
454 | function deathConditions(cr)
|
---|
455 | {
|
---|
456 | if ((cr.energy <= ExpParams.e_death_level) || (Math.rnd01 < ExpParams.hunted_prob))
|
---|
457 | return 1;
|
---|
458 | else
|
---|
459 | return 0;
|
---|
460 | }
|
---|
461 |
|
---|
462 | function onForamsDied(cr)
|
---|
463 | {
|
---|
464 | if (ExpParams.showRet == 1)
|
---|
465 | {
|
---|
466 | Populations[2].delete(cr.user3);
|
---|
467 | }
|
---|
468 | //fossilization
|
---|
469 | var geno = GenePools[0].add(cr.genotype);
|
---|
470 | geno.user1 = cr.user1;
|
---|
471 | geno.user2 = cr.user2;
|
---|
472 | if (ExpParams.logging == 1) Simulator.print("\"" + cr.name + "\" died...");
|
---|
473 | ExpState.totaltestedcr++;
|
---|
474 | }
|
---|
475 |
|
---|
476 | // --------------------------------foram end -------------------------------------
|
---|
477 |
|
---|
478 | // -------------------------------- nutrient begin --------------------------------
|
---|
479 |
|
---|
480 | function createNutrientGenotype(nutrientsize, zone1_range)
|
---|
481 | {
|
---|
482 | return "//0\np:sh=3,sx="+(nutrientsize+25)+",sy="+nutrientsize+",sz="+nutrientsize+",ry=1.5,vr=0.0,1.0,0.0";
|
---|
483 | }
|
---|
484 |
|
---|
485 | function onNutrientsStep(cr)
|
---|
486 | {
|
---|
487 | cr.moveAbs(cr.pos_x % ExpParams.world_size, cr.pos_y % ExpParams.world_size, -ExpParams.zone1_range+0.5);
|
---|
488 | }
|
---|
489 |
|
---|
490 | function addNutrient()
|
---|
491 | {
|
---|
492 | var cr = Populations[1].add(createNutrientGenotype(ExpParams.nutrientsize, ExpParams.zone1_range));
|
---|
493 |
|
---|
494 | cr.name = "Nutrients";
|
---|
495 | cr.idleen = 0;
|
---|
496 | cr.energy0 = ExpParams.energy_nut;
|
---|
497 | cr.energy = cr.energy0;
|
---|
498 | cr.signals.add("nutrient");
|
---|
499 |
|
---|
500 | cr.signals[0].value = cr;
|
---|
501 |
|
---|
502 | placeCreatureRandomly(cr, 0, 0);
|
---|
503 | }
|
---|
504 |
|
---|
505 | function nutrientGrowth()
|
---|
506 | {
|
---|
507 | nutrientenergywaiting = nutrientenergywaiting + ExpParams.feedrate;
|
---|
508 | if (nutrientenergywaiting > ExpParams.energy_nut)
|
---|
509 | {
|
---|
510 | for (var i = 0; i < ExpParams.nutrientPop; i++)
|
---|
511 | {
|
---|
512 | addNutrient();
|
---|
513 | }
|
---|
514 |
|
---|
515 | nutrientenergywaiting = 0.0;
|
---|
516 | Simulator.checkpoint();
|
---|
517 | }
|
---|
518 | }
|
---|
519 |
|
---|
520 | // -------------------------------- nutrient end --------------------------------
|
---|
521 |
|
---|
522 | // -------------------------------- step begin --------------------------------
|
---|
523 |
|
---|
524 | function onStep()
|
---|
525 | {
|
---|
526 | if (ExpParams.logging == 1)
|
---|
527 | {
|
---|
528 | createStatistics();
|
---|
529 | }
|
---|
530 |
|
---|
531 | nutrientGrowth();
|
---|
532 |
|
---|
533 | //reproduction --------------------------------------------
|
---|
534 | reprocounter += 1;
|
---|
535 | if (reprocounter > ExpParams.repro_time)
|
---|
536 | {
|
---|
537 | reprocounter = 0;
|
---|
538 | reproduce_parents(0);
|
---|
539 | reproduce_parents(1);
|
---|
540 | }
|
---|
541 |
|
---|
542 | //check for extinction -----------------------------------------------
|
---|
543 | if (Populations[0].size == 0)
|
---|
544 | {
|
---|
545 | if (ExpParams.autorestart)
|
---|
546 | {
|
---|
547 | Simulator.print("no more creatures, restarting...");
|
---|
548 | onExpInit();
|
---|
549 | }
|
---|
550 | else
|
---|
551 | {
|
---|
552 | Simulator.print("no more creatures, stopped.");
|
---|
553 | Simulator.stop();
|
---|
554 | }
|
---|
555 | }
|
---|
556 | if (Simulator.stepNumber == 150000)
|
---|
557 | Simulator.stop();
|
---|
558 | }
|
---|
559 |
|
---|
560 | function createStatistics()
|
---|
561 | {
|
---|
562 | var number = [[0, 0],[0,0]]; // [species][gen]
|
---|
563 | var e_inc = [[0, 0],[0,0]];
|
---|
564 | var e_nut = 0.0;
|
---|
565 |
|
---|
566 | for (var i = 0; i < Populations[0].size; i++)
|
---|
567 | {
|
---|
568 | var cr = Populations[0].get(i);
|
---|
569 | var gen = cr.user2["gen"];
|
---|
570 | var species = cr.user2["species"];
|
---|
571 |
|
---|
572 | number[species][gen] = number[species][gen] + 1;
|
---|
573 | e_inc[species][gen] = e_inc[species][gen] + cr.energy;
|
---|
574 | }
|
---|
575 |
|
---|
576 | for (var i = 0; i < Populations[1].size; i++)
|
---|
577 | {
|
---|
578 | var cr = Populations[1].get(i);
|
---|
579 | e_nut += cr.energy;
|
---|
580 | }
|
---|
581 |
|
---|
582 | var log_numbers = [number[0][0], number[0][1], number[1][0], number[1][1], Populations[1].size];
|
---|
583 | var log_energies = [e_inc[0][0], e_inc[0][1], e_inc[1][0], e_inc[1][1], e_nut];
|
---|
584 |
|
---|
585 | log(log_numbers, "forams_log.txt");
|
---|
586 | log(log_energies, "energies_log.txt");
|
---|
587 | }
|
---|
588 |
|
---|
589 | function log(tolog, fname)
|
---|
590 | {
|
---|
591 | var f = File.appendDirect(fname, "forams data");
|
---|
592 | f.writeString("" + Simulator.stepNumber);
|
---|
593 | for (var i = 0; i < tolog.size; i++)
|
---|
594 | {
|
---|
595 | f.writeString(";" + tolog[i]);
|
---|
596 | }
|
---|
597 | f.writeString("\n");
|
---|
598 | f.close();
|
---|
599 | }
|
---|
600 |
|
---|
601 | // -------------------------------- step end --------------------------------
|
---|
602 |
|
---|
603 | @include "standard_events.inc"
|
---|
604 |
|
---|
605 | ~
|
---|
606 |
|
---|
607 | prop:
|
---|
608 | id:showRet
|
---|
609 | name:Show reticulopodia
|
---|
610 | type:d 0 1 0
|
---|
611 | group:Foraminifera
|
---|
612 |
|
---|
613 | prop:
|
---|
614 | id:e_repro_cost_haplo
|
---|
615 | name:Cost of reproduction
|
---|
616 | type:f 0.1 0.9 0.5
|
---|
617 | group:Foraminifera
|
---|
618 |
|
---|
619 | prop:
|
---|
620 | id:e_repro_cost_diplo
|
---|
621 | name:Cost of reproduction
|
---|
622 | type:f 0.1 0.9 0.3
|
---|
623 | group:Foraminifera
|
---|
624 |
|
---|
625 | prop:
|
---|
626 | id:chamber_proculus_haplo
|
---|
627 | name:Size of proculus
|
---|
628 | type:f
|
---|
629 | group:Foraminifera
|
---|
630 |
|
---|
631 | prop:
|
---|
632 | id:chamber_proculus_diplo
|
---|
633 | name:Size of proculus
|
---|
634 | type:f
|
---|
635 | group:Foraminifera
|
---|
636 |
|
---|
637 | prop:
|
---|
638 | id:chamber_difference_haplo
|
---|
639 | name:Difference in size between subsequent chambers
|
---|
640 | type:f
|
---|
641 | group:Foraminifera
|
---|
642 |
|
---|
643 | prop:
|
---|
644 | id:chamber_difference_diplo
|
---|
645 | name:Difference in size between subsequent chambers
|
---|
646 | type:f
|
---|
647 | group:Foraminifera
|
---|
648 |
|
---|
649 | prop:
|
---|
650 | id:hunted_prob
|
---|
651 | name:Probability of being hunted
|
---|
652 | type:f 0 1 0
|
---|
653 | group:Forminifera
|
---|
654 |
|
---|
655 | prop:
|
---|
656 | id:zone1_range
|
---|
657 | name:Zone 1 range
|
---|
658 | type:f 0 200
|
---|
659 | group:Foraminifera
|
---|
660 |
|
---|
661 | prop:
|
---|
662 | id:zone2_range
|
---|
663 | name:Zone 2 range
|
---|
664 | type:f 0 3000
|
---|
665 | group:Foraminifera
|
---|
666 |
|
---|
667 | prop:
|
---|
668 | id:colors
|
---|
669 | name:Haploid and diploid colors
|
---|
670 | type:x
|
---|
671 | group:Foraminifera
|
---|
672 |
|
---|
673 | prop:
|
---|
674 | id:min_repro_energ_haplo
|
---|
675 | name:Min reproduction energy of forams
|
---|
676 | type:f
|
---|
677 | group:Foraminifera
|
---|
678 |
|
---|
679 | prop:
|
---|
680 | id:min_repro_energ_diplo
|
---|
681 | name:Min reproduction energy of forams
|
---|
682 | type:f
|
---|
683 | group:Foraminifera
|
---|
684 |
|
---|
685 | prop:
|
---|
686 | id:repro_prob
|
---|
687 | name:Probability of reproduction
|
---|
688 | type:f 0 1 0.8
|
---|
689 | group:Foraminifera
|
---|
690 |
|
---|
691 | prop:
|
---|
692 | id:energies0_haplo
|
---|
693 | name:Energy of offspring from diploid forams
|
---|
694 | type:f
|
---|
695 | group:Foraminifera
|
---|
696 |
|
---|
697 | prop:
|
---|
698 | id:energies0_diplo
|
---|
699 | name:Energy of offspring from diploid forams
|
---|
700 | type:f
|
---|
701 | group:Foraminifera
|
---|
702 |
|
---|
703 | prop:
|
---|
704 | id:energy_hib
|
---|
705 | name:Energy used for hibernation during one step
|
---|
706 | type:f 0 1 0.001
|
---|
707 | group:Foraminifera
|
---|
708 |
|
---|
709 | prop:
|
---|
710 | id:energy_move
|
---|
711 | name:Energy used for movement during one step
|
---|
712 | type:f 0 20 0.001
|
---|
713 | group:Foraminifera
|
---|
714 |
|
---|
715 | prop:
|
---|
716 | id:min_vol
|
---|
717 | name:Minimal volume for reproduction
|
---|
718 | type:f 100 900 100
|
---|
719 | group:Foraminifera
|
---|
720 |
|
---|
721 | prop:
|
---|
722 | id:max_size
|
---|
723 | name:Maximal size
|
---|
724 | type:d 1 10 5
|
---|
725 | group:Foraminifera
|
---|
726 |
|
---|
727 | prop:
|
---|
728 | id:foramPop
|
---|
729 | name:Initial forams population size
|
---|
730 | type:d 1 1000 100
|
---|
731 | group:Foraminifera
|
---|
732 |
|
---|
733 | prop:
|
---|
734 | id:crossprob
|
---|
735 | name:Crossover probability
|
---|
736 | type:f 0 1 0
|
---|
737 | group:Foraminifera
|
---|
738 |
|
---|
739 | prop:
|
---|
740 | id:mutationprob
|
---|
741 | name:Mutation probability
|
---|
742 | type:f 0 1 0
|
---|
743 | group:Foraminifera
|
---|
744 |
|
---|
745 | prop:
|
---|
746 | id:e_death_level
|
---|
747 | name:Minimal level of energy to sustain life
|
---|
748 | type:f 0 20 0
|
---|
749 | group:Foraminifera
|
---|
750 |
|
---|
751 | prop:
|
---|
752 | id:e_meta
|
---|
753 | name:Idle metabolism
|
---|
754 | type:f 0 1
|
---|
755 | group:Energy
|
---|
756 | help:Each stick consumes this amount of energy in one time step
|
---|
757 |
|
---|
758 | prop:
|
---|
759 | id:feedrate
|
---|
760 | name:Feeding rate
|
---|
761 | type:f 0 100
|
---|
762 | group:Energy
|
---|
763 | help:How fast energy is created in the world
|
---|
764 |
|
---|
765 | prop:
|
---|
766 | id:energy_nut
|
---|
767 | name:Nutrient energy
|
---|
768 | type:f 0 1000
|
---|
769 | group:Energy
|
---|
770 |
|
---|
771 | prop:
|
---|
772 | id:feedtrans
|
---|
773 | name:Ingestion multiplier
|
---|
774 | type:f 0 100
|
---|
775 | group:Energy
|
---|
776 |
|
---|
777 | prop:
|
---|
778 | id:nutrientsize
|
---|
779 | name:Nutrient size
|
---|
780 | type:f 0.1 0.9 0.1
|
---|
781 | group:Energy
|
---|
782 |
|
---|
783 | prop:
|
---|
784 | id:nutrientPop
|
---|
785 | name:Nutrient population size
|
---|
786 | group:Energy
|
---|
787 | type:d 1 1000 10
|
---|
788 |
|
---|
789 | prop:
|
---|
790 | id:world_size
|
---|
791 | name:World size
|
---|
792 | type:d 10 10000 20
|
---|
793 | group:World
|
---|
794 |
|
---|
795 | prop:
|
---|
796 | id:stress
|
---|
797 | name:Environmental stress
|
---|
798 | type:d 0 1 1
|
---|
799 | group:World
|
---|
800 |
|
---|
801 | prop:
|
---|
802 | id:repro_trigger
|
---|
803 | name:Reproduction trigger
|
---|
804 | type:d 0 1 1
|
---|
805 | group:World
|
---|
806 |
|
---|
807 | prop:
|
---|
808 | id:repro_time
|
---|
809 | name:Time before reproduction
|
---|
810 | type:d 0 1000
|
---|
811 |
|
---|
812 | prop:
|
---|
813 | id:creath
|
---|
814 | name:Creation height
|
---|
815 | type:f -1 50
|
---|
816 | help:~
|
---|
817 | Vertical position (above the surface) where new Forams are revived.
|
---|
818 | Negative values are only used in the water area:
|
---|
819 | 0 = at the surface
|
---|
820 | -0.5 = half depth
|
---|
821 | -1 = just above the bottom~
|
---|
822 |
|
---|
823 | state:
|
---|
824 | id:nutrient
|
---|
825 | name:Nutrient locations
|
---|
826 | help:vector of vectors [x,y,energy]
|
---|
827 | type:x
|
---|
828 | flags:32
|
---|
829 |
|
---|
830 | prop:
|
---|
831 | id:autorestart
|
---|
832 | name:Restart after extinction
|
---|
833 | help:Restart automatically this experiment after the last creature has died?
|
---|
834 | type:d 0 1
|
---|
835 |
|
---|
836 | state:
|
---|
837 | id:notes
|
---|
838 | name:Notes
|
---|
839 | type:s 1
|
---|
840 | help:~
|
---|
841 | You can write anything here
|
---|
842 | (it will be saved to the experiment file)~
|
---|
843 |
|
---|
844 | state:
|
---|
845 | id:totaltestedcr
|
---|
846 | name:Evaluated Forams
|
---|
847 | help:Total number of the Forams evaluated in the experiment
|
---|
848 | type:d
|
---|
849 | flags:16
|
---|
850 |
|
---|
851 | prop:
|
---|
852 | id:logging
|
---|
853 | name:Log statistics to file
|
---|
854 | type:d 0 1 0
|
---|