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