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