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