[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:
|
---|
[476] | 8 | Genes and parameter values which control reproduction are stored in data->genes and data->lifeparams fields.
|
---|
[380] | 9 |
|
---|
[476] | 10 | genes:
|
---|
[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 |
|
---|
[476] | 15 | lifeparams:
|
---|
[380] | 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 |
|
---|
[422] | 25 | global colors;
|
---|
[493] | 26 | global retColors;
|
---|
| 27 | global curColor;
|
---|
[479] | 28 | global max_chamber_volume;
|
---|
[474] | 29 | global movePerStep;
|
---|
[479] | 30 | global nutrientenergywaiting;
|
---|
| 31 | global reprocounter;
|
---|
[481] | 32 | global changePeriod;
|
---|
| 33 | global phase;
|
---|
[493] | 34 | global nutrientSqrCm;
|
---|
[567] | 35 | global species_genes;
|
---|
| 36 | global max_chambers_def;
|
---|
| 37 | global foram_uid; //introduced because each replacement of a creature (while growing) would generate a new Creature.uid
|
---|
| 38 | global chamber_vis_denominator;
|
---|
| 39 | global curRadius;
|
---|
[380] | 40 |
|
---|
[406] | 41 | @include "foraminifera.inc"
|
---|
[401] | 42 |
|
---|
[380] | 43 | // -------------------------------- experiment begin --------------------------------
|
---|
| 44 |
|
---|
| 45 | function onExpDefLoad()
|
---|
| 46 | {
|
---|
| 47 | // define genotype and creature groups
|
---|
| 48 | GenePools.clear();
|
---|
| 49 | Populations.clear();
|
---|
| 50 | GenePools[0].name = "Unused";
|
---|
| 51 |
|
---|
| 52 | var pop = Populations[0];
|
---|
[421] | 53 | pop.name = "Forams";
|
---|
[380] | 54 | pop.en_assim = 0;
|
---|
[404] | 55 | pop.nnsim = 0;
|
---|
[380] | 56 | pop.enableperf = 1;
|
---|
| 57 | pop.death = 1;
|
---|
| 58 | pop.energy = 1;
|
---|
[487] | 59 | pop.selfmask = 0;
|
---|
| 60 | pop.othermask = 0;
|
---|
[401] | 61 | //pop.selfmask = 0x20002; pop.othermask = 0x10002;
|
---|
[422] | 62 | pop.perfperiod = 25;
|
---|
[487] | 63 | pop.bodysim = 0;
|
---|
[380] | 64 |
|
---|
[421] | 65 | pop = Populations.addGroup("Nutrients");
|
---|
[380] | 66 | pop.nnsim = 0;
|
---|
| 67 | pop.enableperf = 0;
|
---|
| 68 | pop.death = 1;
|
---|
| 69 | pop.energy = 1;
|
---|
[487] | 70 | pop.selfmask = 0;
|
---|
| 71 | pop.othermask = 0;
|
---|
[422] | 72 | //pop.othermask = 0x10002;
|
---|
[487] | 73 | pop.bodysim = 0;
|
---|
[380] | 74 |
|
---|
[444] | 75 | pop = Populations.addGroup("ReticulopodiaNutrients");
|
---|
[430] | 76 | pop.nnsim = 0;
|
---|
| 77 | pop.enableperf = 0;
|
---|
| 78 | pop.death = 0;
|
---|
| 79 | pop.energy = 0;
|
---|
[487] | 80 | pop.selfmask = 0;
|
---|
| 81 | pop.othermask = 0;
|
---|
| 82 | pop.bodysim = 0;
|
---|
[444] | 83 |
|
---|
[422] | 84 | //world
|
---|
| 85 | SignalView.mode = 1;
|
---|
[496] | 86 | World.wrldwat = 200;
|
---|
[493] | 87 | World.wrldsiz = micronsToFrams(100000);
|
---|
[422] | 88 | World.wrldbnd = 1;
|
---|
| 89 |
|
---|
[474] | 90 | movePerStep = getMovePerStep();
|
---|
| 91 |
|
---|
[486] | 92 | //ExpProperties.visualize = 1; //uncomment to visualize reticulopodia and indicate nutrients positions
|
---|
[444] | 93 |
|
---|
[487] | 94 | //ExpProperties.logging = 1; //uncomment to enable logging simulation parameters to log files
|
---|
[493] | 95 | ExpProperties.logPref = "";
|
---|
[401] | 96 |
|
---|
[487] | 97 | species_genes = [];
|
---|
| 98 |
|
---|
[554] | 99 | //morphology
|
---|
[486] | 100 | ExpProperties.zone1_range = micronsToFrams(1000);
|
---|
| 101 | ExpProperties.zone2_range = micronsToFrams(3000);
|
---|
[567] | 102 | ExpProperties.chamber_proculus_haplo = micronsToFrams(20);
|
---|
| 103 | ExpProperties.chamber_proculus_diplo = micronsToFrams(10);
|
---|
| 104 | colors = ["1.0,1.0,0.0","1.0,0.5,0.0"];
|
---|
| 105 | retColors = ["1.0,1.0,1.0", "1.0,1.0,0.0"];
|
---|
| 106 | curColor = retColors[0];
|
---|
| 107 | curRadius = ExpProperties.zone1_range;
|
---|
[479] | 108 |
|
---|
[422] | 109 | //nutrients
|
---|
[486] | 110 | ExpProperties.nutrientradius = micronsToFrams(10);
|
---|
[552] | 111 | ExpProperties.energy_nut = 200 * energyFromVolume(ExpProperties.nutrientradius,1);
|
---|
[554] | 112 | nutrientSqrCm = 10;
|
---|
[493] | 113 | ExpProperties.nutrient_pop = Math.pow(framsToMicrons(World.wrldsiz)*0.0001,2)/nutrientSqrCm;
|
---|
[554] | 114 |
|
---|
[380] | 115 | ExpState.totaltestedcr = 0;
|
---|
[421] | 116 | ExpState.nutrient = "";
|
---|
[567] | 117 |
|
---|
| 118 | max_chambers_def = 35;
|
---|
| 119 | chamber_vis_denominator = 6;
|
---|
[493] | 120 | //addSpecies({"min_repro_energies" : [4,6]});
|
---|
| 121 | //addSpecies({"min_repro_energies" : [4,8]});
|
---|
[557] | 122 |
|
---|
[561] | 123 | //Simulator.print(create_genotype(0.2, 30, "1.0,1.0,0.0", 0.6)); //sample call
|
---|
| 124 | //Simulator.print(create_genotype(0.1, 40, "1.0,0.5,0.0", 0.1)); //sample call
|
---|
[380] | 125 | }
|
---|
| 126 |
|
---|
| 127 | @include "standard_placement.inc"
|
---|
| 128 |
|
---|
[567] | 129 | function onExpInit()
|
---|
[475] | 130 | {
|
---|
[567] | 131 | foram_uid = 0;
|
---|
[475] | 132 |
|
---|
[567] | 133 | Populations[0].clear();
|
---|
| 134 | Populations[1].clear();
|
---|
| 135 | Populations[2].clear(); //reticulopodia and nutrients
|
---|
| 136 |
|
---|
| 137 | if (ExpProperties.max_chamber_num_haplo == max_chambers_def && ExpProperties.max_chamber_num_diplo == max_chambers_def)
|
---|
[479] | 138 | {
|
---|
[567] | 139 | max_chamber_volume = [[30403.5869594578,52812.2546633948,79578.5148482541,113588.815134453,154620.677376218,205094.322220826,262572.712174265,326078.453295303,402342.518962956,498133.985678766,615066.864740109,759500.497626816,937064.025544282,1155915.25563075,1429139.14079748,1762487.92940157,2176286.62046069,2685795.63187845,3316190.12127043,4096436.04462706,5051343.25226193,6231980.1061213,7687880.79524734,9485307.02904958,11716968.9852569,14459866.4934433,17836388.9853663,22004935.7247348,27138607.2546045,33482425.1582986,41336775.1280297,50997910.7842793,62888631.7871037,77563060.9243464,95659468.591964]
|
---|
| 140 | , [3430.07716920763,6159.93090353532,9322.94192815286,13462.9896597283,18399.8550832969,24558.9218126892,31468.8148639192,39189.4977865513,48404.4292075836,60185.8639086061,74490.6048472854,92117.8178412275,113852.779747083,140714.366929552,174450.937643841,215250.242147183,266323.295274072,328858.042352538,406552.379957238,503526.321155323,621060.781025019,767240.824049468,947210.683224091,1169506.19906112,1447211.61255879,1787155.29073739,2205627.64766244,2723413.2837305,3360233.53738709,4147771.02835393,5126445.06973928,6328060.3331703,7805693.278958,9631924.72156452,11884287.1596814]];
|
---|
[479] | 141 | }
|
---|
| 142 |
|
---|
[567] | 143 | else
|
---|
[479] | 144 | {
|
---|
[567] | 145 | max_chamber_volume = [Vector.new(), Vector.new()];
|
---|
| 146 | var density = 100;
|
---|
| 147 | for (var ploid = 0; ploid < 2; ploid++)
|
---|
| 148 | {
|
---|
| 149 | var rad = getPloidRadius(ploid);
|
---|
| 150 | for (var cham_num = 0; cham_num < getProperty(ploid,"max_chamber_num"); cham_num++)
|
---|
| 151 | {
|
---|
| 152 | max_chamber_volume[ploid].add(volumeFromGeno(ploid, rad, cham_num+1, density));
|
---|
| 153 | }
|
---|
| 154 | }
|
---|
[479] | 155 | }
|
---|
[422] | 156 |
|
---|
[487] | 157 | if (species_genes.size == 0)
|
---|
[380] | 158 | {
|
---|
[487] | 159 | addSpecies({}); //default
|
---|
[380] | 160 | }
|
---|
[487] | 161 |
|
---|
| 162 | for (var spec = 0; spec < species_genes.size; spec++)
|
---|
| 163 | {
|
---|
| 164 | for (var i = 0; i < ExpProperties.foramPop; i++)
|
---|
| 165 | {
|
---|
| 166 | addInitialForam(spec, i);
|
---|
| 167 | }
|
---|
| 168 | }
|
---|
[380] | 169 | ExpState.totaltestedcr = 0;
|
---|
[554] | 170 |
|
---|
| 171 | reprocounter = 0;
|
---|
| 172 | nutrientenergywaiting = 0;
|
---|
| 173 | changePeriod = 0;
|
---|
| 174 | phase = "low";
|
---|
[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);
|
---|
[476] | 201 | if ((typeof(g.data->genes) == "Vector") && (g.data->genes.size >= 3))
|
---|
[401] | 202 | {
|
---|
| 203 | // [x,y,energy]
|
---|
[476] | 204 | cr.move(g.data->genes[0] - cr.center_x, g.data->genes[1] - cr.center_y, 0);
|
---|
| 205 | cr.energy = g.data->genes[2];
|
---|
[380] | 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 |
|
---|
[567] | 240 | function volumeFromGeno(morphotype, rad, chamber_num, density)
|
---|
| 241 | {
|
---|
| 242 | var geno = create_genotype(rad, chamber_num, colors[morphotype], 1);
|
---|
| 243 | var m=Model.newFromString(geno);
|
---|
| 244 | var mg=ModelGeometry.forModel(m);
|
---|
| 245 | mg.geom_density=density;
|
---|
| 246 | var volumeInFrams = mg.volume();
|
---|
| 247 |
|
---|
| 248 | return volumeInFrams/Math.pow(ExpProperties.scalingFactor,3);
|
---|
| 249 | }
|
---|
| 250 |
|
---|
| 251 | function secToSimSteps(value_in_sec){
|
---|
| 252 | return value_in_sec/ExpProperties.secPerStep;
|
---|
| 253 | }
|
---|
| 254 |
|
---|
| 255 | function volumeInMicrons(radiusInFrams)
|
---|
| 256 | {
|
---|
| 257 | return 4.0/3.0*Math.pi*Math.pow(framsToMicrons(radiusInFrams),3);
|
---|
| 258 | }
|
---|
| 259 |
|
---|
| 260 | function energyFromVolume(base, isRadiusInFrams)
|
---|
| 261 | {
|
---|
| 262 | if (isRadiusInFrams == 1) //radius in frams
|
---|
| 263 | {
|
---|
| 264 | return ExpProperties.picoCarbonPerMikro*volumeInMicrons(base);
|
---|
| 265 | }
|
---|
| 266 | else //volume in microns
|
---|
| 267 | {
|
---|
| 268 | return ExpProperties.picoCarbonPerMikro * base;
|
---|
| 269 | }
|
---|
| 270 | }
|
---|
| 271 |
|
---|
| 272 | function getMovePerStep()
|
---|
| 273 | {
|
---|
| 274 | return micronsToFrams((ExpProperties.foramSpeedMmPerMin/60)*1000)*ExpProperties.secPerStep;
|
---|
| 275 | }
|
---|
| 276 |
|
---|
| 277 | function micronsToFrams(micrometers)
|
---|
| 278 | {
|
---|
| 279 | return micrometers*ExpProperties.scalingFactor;
|
---|
| 280 | }
|
---|
| 281 |
|
---|
| 282 | function framsToMicrons(framsworldunits)
|
---|
| 283 | {
|
---|
| 284 | return framsworldunits/ExpProperties.scalingFactor;
|
---|
| 285 | }
|
---|
| 286 |
|
---|
| 287 | function getProperty(gen, prop_id)
|
---|
| 288 | {
|
---|
| 289 | var ploid = "haplo";
|
---|
| 290 | if (gen == 1) ploid = "diplo";
|
---|
| 291 | return ExpProperties.[prop_id + "_" + ploid];
|
---|
| 292 | }
|
---|
| 293 |
|
---|
| 294 | function getGene(cr, gen_id, gen_set)
|
---|
| 295 | {
|
---|
| 296 | if (cr.data->lifeparams->gen == 0)
|
---|
| 297 | return cr.data->genes[gen_id];
|
---|
| 298 | else
|
---|
| 299 | return cr.data->genes[gen_set][gen_id];
|
---|
| 300 | }
|
---|
| 301 |
|
---|
| 302 | function getPloidRadius(ploid)
|
---|
| 303 | {
|
---|
| 304 | var radius = ExpProperties.chamber_proculus_haplo;
|
---|
| 305 | if (ploid == 1)
|
---|
| 306 | {
|
---|
| 307 | radius = ExpProperties.chamber_proculus_diplo;
|
---|
| 308 | }
|
---|
| 309 | return radius;
|
---|
| 310 | }
|
---|
| 311 |
|
---|
| 312 | function chamberNumFromEnergy(energy, ploid)
|
---|
| 313 | {
|
---|
| 314 | var chamber_num = max_chamber_volume[ploid].size;
|
---|
| 315 | for (var i = 0; i < chamber_num; i++)
|
---|
| 316 | {
|
---|
| 317 | if (energy < energyFromVolume(max_chamber_volume[ploid][i],0))
|
---|
| 318 | {
|
---|
| 319 | chamber_num = i+1;
|
---|
| 320 | break;
|
---|
| 321 | }
|
---|
| 322 | }
|
---|
| 323 |
|
---|
| 324 | return chamber_num;
|
---|
| 325 | }
|
---|
| 326 |
|
---|
| 327 | function addForam(species, iter, start_energy, ploid)
|
---|
| 328 | {
|
---|
| 329 | var chambernum = chamberNumFromEnergy(start_energy, ploid);
|
---|
| 330 | var radius = getPloidRadius(ploid);
|
---|
| 331 | var geno = create_genotype(radius, chambernum, colors[ploid], 1);
|
---|
| 332 | curColor = retColors[ploid];
|
---|
| 333 | var cr = Populations[0].add(geno);
|
---|
| 334 | cr.name = "Initial creature" + species + "_" + iter;
|
---|
| 335 | placeCreatureRandomly(cr, 0, 0);
|
---|
| 336 | cr.energy = start_energy;
|
---|
| 337 | setGenotype({"opt" : "birth", "cr" : cr, "gen" : ploid, "species" : species, "energy0" : cr.energy, "genes" : species_genes[species], "parentsuids" : ["c0"]});
|
---|
| 338 | if (ploid == 1)
|
---|
| 339 | {
|
---|
| 340 | cr.data->genes = [cr.data->genes, cr.data->genes]; //TODO two different genes sets
|
---|
| 341 | }
|
---|
| 342 | moveReticulopodia(cr);
|
---|
| 343 | }
|
---|
| 344 |
|
---|
| 345 | function addInitialForam(species, iter)
|
---|
| 346 | {
|
---|
| 347 | var ploid = 0;
|
---|
| 348 | if (Math.rnd01 > 0.5)
|
---|
| 349 | {
|
---|
| 350 | ploid = 1;
|
---|
| 351 | }
|
---|
| 352 | //add new foram with random energy bewtween starting energy and reproduction threshold
|
---|
| 353 | var repro_thr = species_genes[species]->min_repro_energies[ploid];
|
---|
| 354 | var start_energy = Math.rndUni(energyFromVolume(getPloidRadius(ploid),1),repro_thr-0.25*repro_thr);
|
---|
| 355 | addForam(species, iter, start_energy,ploid);
|
---|
| 356 | }
|
---|
| 357 |
|
---|
| 358 | //new species can be added as a dictionary with parameter values that are different than default values
|
---|
| 359 | function addSpecies(new_genes)
|
---|
| 360 | {
|
---|
| 361 | species_genes.add({"min_repro_energies" : [ExpProperties.min_repro_energ_haplo,ExpProperties.min_repro_energ_diplo], "energies0" : [ExpProperties.energies0_haplo, ExpProperties.energies0_diplo], "hibernation" : 0, "morphotype" : 0});
|
---|
| 362 | for (var i = 0; i < new_genes.size; i++)
|
---|
| 363 | {
|
---|
| 364 | var key = new_genes.getKey(i);
|
---|
| 365 | species_genes[species_genes.size-1][key] = new_genes[key];
|
---|
| 366 | }
|
---|
| 367 | }
|
---|
| 368 |
|
---|
[421] | 369 | // -------------------------------- foram begin -----------------------------------
|
---|
[380] | 370 |
|
---|
[479] | 371 | function setForamMeta(cr)
|
---|
[430] | 372 | {
|
---|
[479] | 373 | //percent of current energy
|
---|
[486] | 374 | cr.idleen = (ExpProperties.e_meta * cr.energy)*ExpProperties.secPerStep;
|
---|
[430] | 375 | }
|
---|
| 376 |
|
---|
| 377 | function lastChamberNum(cr)
|
---|
| 378 | {
|
---|
[567] | 379 | return cr.numparts;
|
---|
[430] | 380 | }
|
---|
| 381 |
|
---|
[479] | 382 | function getZoneRange(cr, zone_num)
|
---|
| 383 | {
|
---|
[486] | 384 | return ExpProperties.["zone"+zone_num+"_range"];
|
---|
[479] | 385 | }
|
---|
| 386 |
|
---|
[567] | 387 | function addReticulopodia(cr, radius)
|
---|
| 388 | {
|
---|
| 389 | if (reticulopodiaExists(cr))
|
---|
| 390 | {
|
---|
| 391 | Populations[2].delete(cr.data->reticulopodiacreature);
|
---|
| 392 | }
|
---|
| 393 | var ret = Populations[2].add("//0\nm:Vstyle=reticulopodia\np:sh=1,sx=0.001,sy=0.001,sz=0.001\np:sh=3,sx=0.01,sy="+radius+",sz="+radius+",ry=1.57079633,vr="+curColor+"\nj:0, 1, sh=1");
|
---|
| 394 | cr.data->reticulopodiacreature = ret;
|
---|
| 395 | ret.getMechPart(0).orient.set(cr.getMechPart(0).orient);
|
---|
| 396 | ret.moveAbs(cr.center_x-radius, cr.center_y-radius, cr.center_z-radius);
|
---|
| 397 | }
|
---|
| 398 |
|
---|
[421] | 399 | function onForamsBorn(cr)
|
---|
| 400 | {
|
---|
[479] | 401 | setForamMeta(cr);
|
---|
[486] | 402 | if (ExpProperties.visualize == 1)
|
---|
[430] | 403 | {
|
---|
[567] | 404 | addReticulopodia(cr, curRadius);
|
---|
[430] | 405 | }
|
---|
[567] | 406 | moveReticulopodia(cr);
|
---|
[380] | 407 | }
|
---|
| 408 |
|
---|
[401] | 409 | function placeRandomlyNotColliding(cr)
|
---|
| 410 | {
|
---|
| 411 | var retry = 100; //try 100 times
|
---|
| 412 | while (retry--)
|
---|
| 413 | {
|
---|
| 414 | placeCreatureRandomly(cr, 0, 0);
|
---|
| 415 | if (!cr.boundingBoxCollisions(0))
|
---|
| 416 | return cr;
|
---|
| 417 | }
|
---|
| 418 |
|
---|
| 419 | Populations[0].delete(cr);
|
---|
| 420 | }
|
---|
| 421 |
|
---|
[567] | 422 | function reticulopodiaExists(cr)
|
---|
[444] | 423 | {
|
---|
| 424 | var has_ret = 0;
|
---|
| 425 |
|
---|
[476] | 426 | if (cr.data->reticulopodiacreature != null)
|
---|
[444] | 427 | {
|
---|
[476] | 428 | if (Populations[2].findUID(cr.data->reticulopodiacreature.uid) != null)
|
---|
[444] | 429 | {
|
---|
| 430 | has_ret = 1;
|
---|
| 431 | }
|
---|
| 432 | }
|
---|
| 433 |
|
---|
| 434 | return has_ret;
|
---|
| 435 | }
|
---|
| 436 |
|
---|
[567] | 437 | function visualization(cr)
|
---|
[380] | 438 | {
|
---|
[567] | 439 | return reticulopodiaExists(cr);
|
---|
| 440 | }
|
---|
| 441 |
|
---|
| 442 | function foramGrow(cr, chamber_num, lastchambergrowth)
|
---|
| 443 | {
|
---|
| 444 | if ((chamber_num+1) <= max_chamber_volume[cr.data->lifeparams->gen].size)
|
---|
[474] | 445 | {
|
---|
[493] | 446 | curColor = retColors[cr.data->lifeparams->gen];
|
---|
[567] | 447 | var ploid = cr.data->lifeparams->gen;
|
---|
| 448 | var geno = create_genotype(getPloidRadius(ploid), chamber_num+1, colors[ploid], lastchambergrowth);
|
---|
[474] | 449 | var cr2 = Populations[0].add(geno);
|
---|
[422] | 450 |
|
---|
[474] | 451 | cr2.energy0 = cr.energy;
|
---|
| 452 | cr2.energy = cr2.energy0;
|
---|
[422] | 453 |
|
---|
[554] | 454 | setGenotype({"cr" : cr2, "parent_genes" : cr.data->genes, "parent_lifeparams" : cr.data->lifeparams, "opt" : "growth", "energy0" : cr.energy0});
|
---|
[567] | 455 | cr2.moveAbs(cr.pos_x, cr.pos_y,cr.pos_z);
|
---|
[479] | 456 | setForamMeta(cr2);
|
---|
[422] | 457 |
|
---|
[567] | 458 | if (reticulopodiaExists(cr))
|
---|
[474] | 459 | {
|
---|
[476] | 460 | Populations[2].delete(cr.data->reticulopodiacreature);
|
---|
[474] | 461 | }
|
---|
| 462 | Populations[0].delete(cr);
|
---|
[567] | 463 | return cr2;
|
---|
[430] | 464 | }
|
---|
[567] | 465 | return cr;
|
---|
[380] | 466 | }
|
---|
| 467 |
|
---|
[435] | 468 | function stepToNearest(cr)
|
---|
[380] | 469 | {
|
---|
| 470 | var p = cr.getMechPart(0);
|
---|
[479] | 471 | var n = cr.signals.receiveSet("nutrient", getZoneRange(cr,2));
|
---|
[380] | 472 |
|
---|
[401] | 473 | //if signals are received find the source of the nearest
|
---|
[380] | 474 | if (n.size > 0)
|
---|
| 475 | {
|
---|
| 476 | var i;
|
---|
| 477 | var mp;
|
---|
| 478 | var distvec = XYZ.new(0, 0, 0);
|
---|
| 479 | var dist;
|
---|
[470] | 480 | var mindist = 100000000000.0;
|
---|
[380] | 481 | var mindistvec = null;
|
---|
[430] | 482 | var eating = 0;
|
---|
[380] | 483 |
|
---|
[401] | 484 | for (i = 0; i < n.size; i++)
|
---|
[380] | 485 | {
|
---|
[430] | 486 | mp = n[i].value.getMechPart(0);
|
---|
[401] | 487 | distvec.set(mp.pos);
|
---|
| 488 | distvec.sub(p.pos);
|
---|
| 489 | dist = distvec.length;
|
---|
[479] | 490 | if (dist < getZoneRange(cr,1))
|
---|
[380] | 491 | {
|
---|
[430] | 492 | if (n[i].value != null)
|
---|
| 493 | {
|
---|
| 494 | energyTransfer(cr, n[i].value);
|
---|
| 495 | eating = 1;
|
---|
| 496 | }
|
---|
| 497 | }
|
---|
[476] | 498 | else if (eating == 0 && cr.data->lifeparams->hibernated == 0 && dist < mindist)
|
---|
[430] | 499 | {
|
---|
[401] | 500 | mindist = dist;
|
---|
| 501 | mindistvec = distvec.clone();
|
---|
[380] | 502 | }
|
---|
| 503 | }
|
---|
| 504 |
|
---|
[476] | 505 | if (!eating && cr.data->lifeparams->hibernated == 0)
|
---|
[430] | 506 | {
|
---|
| 507 | mindistvec.normalize();
|
---|
[474] | 508 | mindistvec.scale(-1*movePerStep);
|
---|
[430] | 509 | cr.localDrive = mindistvec;
|
---|
| 510 | moveEnergyDec(cr);
|
---|
| 511 | }
|
---|
| 512 |
|
---|
[422] | 513 | return 1;
|
---|
[380] | 514 | }
|
---|
[422] | 515 |
|
---|
| 516 | else
|
---|
[474] | 517 | {
|
---|
[422] | 518 | return 0;
|
---|
[474] | 519 | }
|
---|
[422] | 520 | }
|
---|
[401] | 521 |
|
---|
[422] | 522 | function moveEnergyDec(cr)
|
---|
| 523 | {
|
---|
[476] | 524 | if (cr.data->lifeparams->hibernated == 0)
|
---|
[422] | 525 | {
|
---|
[479] | 526 | //percent of maximal energy
|
---|
[504] | 527 | cr.energy -= (ExpProperties.energy_move * cr.data->lifeparams->max_energy_level)*ExpProperties.secPerStep;
|
---|
[422] | 528 | }
|
---|
[421] | 529 | }
|
---|
[380] | 530 |
|
---|
[493] | 531 | function fence(pos, zone)
|
---|
[487] | 532 | {
|
---|
[496] | 533 | return Math.min(Math.max(0,pos),World.wrldsiz);
|
---|
[487] | 534 | }
|
---|
| 535 |
|
---|
[422] | 536 | function foramMove(cr)
|
---|
[421] | 537 | {
|
---|
[422] | 538 | //TODO moving inside sediment?
|
---|
[421] | 539 |
|
---|
[422] | 540 | //adjustment in z axis
|
---|
[554] | 541 | var change_direction = 0;
|
---|
| 542 | var new_x = fence(cr.pos_x, getZoneRange(cr, 1));
|
---|
| 543 | var new_y = fence(cr.pos_y,getZoneRange(cr, 1));
|
---|
[421] | 544 |
|
---|
[554] | 545 | if ((new_x != cr.pos_x) || (new_y != cr.pos_y) || (cr.data->lifeparams->dir_counter >= int(secToSimSteps(ExpProperties.dir_change_sec))))
|
---|
| 546 | {
|
---|
| 547 | change_direction = 1;
|
---|
| 548 | }
|
---|
| 549 |
|
---|
| 550 | cr.moveAbs(new_x, new_y, 0);
|
---|
| 551 |
|
---|
[430] | 552 | //are there any nutrients in zone 1 or 2?
|
---|
[401] | 553 | {
|
---|
[435] | 554 | var moved = stepToNearest(cr); //TODO weighted sum of distance and energy
|
---|
[422] | 555 | if (moved==1)
|
---|
[430] | 556 | {
|
---|
[502] | 557 | moveReticulopodia(cr);
|
---|
[422] | 558 | return;
|
---|
| 559 | }
|
---|
[401] | 560 | }
|
---|
| 561 |
|
---|
[422] | 562 | //no nutrients in zone 2
|
---|
[487] | 563 | if (getGene(cr, "hibernation",0) == 1)
|
---|
[401] | 564 | {
|
---|
[430] | 565 | reverseHib(cr);
|
---|
[422] | 566 | cr.localDrive = XYZ.new(0,0,0);
|
---|
[380] | 567 | }
|
---|
[422] | 568 | //random move
|
---|
[554] | 569 | else if (change_direction == 1)
|
---|
[380] | 570 | {
|
---|
[476] | 571 | cr.data->lifeparams->dir = randomDir();
|
---|
[552] | 572 | cr.data->lifeparams->dir_counter = 0;
|
---|
[476] | 573 | cr.localDrive = cr.data->lifeparams->dir;
|
---|
[422] | 574 | moveEnergyDec(cr);
|
---|
| 575 | }
|
---|
[474] | 576 | else
|
---|
| 577 | {
|
---|
[476] | 578 | cr.localDrive = cr.data->lifeparams->dir;
|
---|
[474] | 579 | }
|
---|
[502] | 580 | moveReticulopodia(cr);
|
---|
[422] | 581 | }
|
---|
[401] | 582 |
|
---|
[502] | 583 | function moveReticulopodia(cr)
|
---|
| 584 | {
|
---|
| 585 | if (visualization(cr))
|
---|
| 586 | {
|
---|
| 587 | cr.data->reticulopodiacreature.moveAbs(cr.center_x-getZoneRange(cr,1), cr.center_y-getZoneRange(cr,1), cr.center_z-getZoneRange(cr,1));
|
---|
| 588 | cr.data->reticulopodiacreature.localDrive = cr.localDrive;
|
---|
| 589 | }
|
---|
| 590 | }
|
---|
| 591 |
|
---|
[474] | 592 | function randomDir()
|
---|
| 593 | {
|
---|
[486] | 594 | var dir = (Math.rndUni(-ExpProperties.zone2_range, ExpProperties.zone2_range), Math.rndUni(-ExpProperties.zone2_range, ExpProperties.zone2_range), 0);
|
---|
[474] | 595 | dir.normalize();
|
---|
| 596 | dir.scale(-1*movePerStep);
|
---|
| 597 | return dir;
|
---|
| 598 | }
|
---|
| 599 |
|
---|
[430] | 600 | function energyTransfer(cr1, cr2)
|
---|
[422] | 601 | {
|
---|
[430] | 602 | cr1.localDrive = XYZ.new(0,0,0);
|
---|
[510] | 603 | var e = ExpProperties.feedtrans*cr1.energy*ExpProperties.secPerStep; //TODO efficiency dependent on age
|
---|
[502] | 604 | //Simulator.print("transferring "+e +"("+e*ExpProperties.ingestion+")"+" to "+cr1.name +" ("+ cr1.energy+") " +" from "+cr2.uid+" ("+cr2.energy+") "+ e/ExpProperties.secPerStep+ " per sec");
|
---|
[510] | 605 | var transferred = cr2.transferEnergyTo(cr1, e);
|
---|
| 606 | cr1.energy -= transferred*(1-ExpProperties.ingestion);
|
---|
[476] | 607 | if (cr1.data->lifeparams->hibernated == 1)
|
---|
[422] | 608 | {
|
---|
[430] | 609 | reverseHib(cr1);
|
---|
[422] | 610 | }
|
---|
| 611 | }
|
---|
[401] | 612 |
|
---|
[430] | 613 | function reverseHib(cr)
|
---|
| 614 | {
|
---|
[476] | 615 | if (cr.data->lifeparams->hibernated == 1)
|
---|
[430] | 616 | {
|
---|
[479] | 617 | setForamMeta(cr); //unhibernate
|
---|
[430] | 618 | }
|
---|
| 619 | else
|
---|
| 620 | {
|
---|
[486] | 621 | cr.idleen = (ExpProperties.energy_hib * cr.energy)*ExpProperties.secPerStep; //hibernate
|
---|
[430] | 622 | }
|
---|
[476] | 623 | cr.data->lifeparams->hibernated = 1 - cr.data->lifeparams->hibernated;
|
---|
[430] | 624 | }
|
---|
| 625 |
|
---|
[422] | 626 | function onForamsStep(cr)
|
---|
| 627 | {
|
---|
[479] | 628 | //checking for gametogenesis process
|
---|
| 629 | if (cr.data->lifeparams->division_time > 0)
|
---|
[444] | 630 | {
|
---|
[479] | 631 | cr.data->lifeparams->division_time = Math.max(cr.data->lifeparams->division_time-1,0);
|
---|
[444] | 632 | }
|
---|
[479] | 633 | //checking for end of gametogenesis
|
---|
| 634 | else if (cr.data->lifeparams->division_time == 0)
|
---|
[422] | 635 | {
|
---|
[479] | 636 | //waiting for gamets fusion
|
---|
[422] | 637 | }
|
---|
[479] | 638 | //checking for chamber growth process
|
---|
| 639 | else if (cr.data->lifeparams->chamber_growth > 0)
|
---|
| 640 | {
|
---|
[567] | 641 | var chamber_time = Math.max(cr.data->lifeparams->chamber_growth-1,0);
|
---|
| 642 | cr.data->lifeparams->chamber_growth = chamber_time;
|
---|
[504] | 643 | cr.energy -= ExpProperties.chamberCostPerSec * cr.energy * ExpProperties.secPerStep;
|
---|
[422] | 644 |
|
---|
[567] | 645 | if (visualization(cr))
|
---|
| 646 | {
|
---|
| 647 | var total_time = secToSimSteps(ExpProperties.chamberGrowthSec);
|
---|
| 648 | var ret_unit = total_time/chamber_vis_denominator;
|
---|
| 649 | var chamber_unit = total_time-ret_unit;
|
---|
| 650 |
|
---|
| 651 | if (chamber_time < ret_unit || chamber_time >= chamber_unit)
|
---|
| 652 | {
|
---|
| 653 | var new_rad = Math.min(Math.max((chamber_time%ret_unit)/ret_unit*getZoneRange(cr,1),0.01),getZoneRange(cr,1));
|
---|
| 654 |
|
---|
| 655 | if(chamber_time < ret_unit)
|
---|
| 656 | new_rad = getZoneRange(cr,1)-new_rad;
|
---|
| 657 |
|
---|
| 658 | addReticulopodia(cr,new_rad);
|
---|
| 659 | }
|
---|
| 660 | else
|
---|
| 661 | {
|
---|
| 662 | var new_rad = 1 - Math.min(Math.max((chamber_time-ret_unit)/chamber_unit,0.01),1);
|
---|
| 663 | curRadius = cr.data->reticulopodiacreature.getPart(1).sy;
|
---|
| 664 |
|
---|
| 665 | if (chamber_time == ret_unit){
|
---|
| 666 | new_rad == 1;
|
---|
| 667 | }
|
---|
| 668 |
|
---|
| 669 | var new_cr = foramGrow(cr, chamberNumFromEnergy(cr.data->lifeparams->max_energy_level, cr.data->lifeparams->gen)-1, new_rad);
|
---|
| 670 | curRadius = getZoneRange(new_cr,1);
|
---|
| 671 |
|
---|
| 672 | if (chamber_time == 0)//checking for end of chamber growth process
|
---|
| 673 | {
|
---|
| 674 | new_cr.data->lifeparams->chamber_growth = -1;
|
---|
| 675 | }
|
---|
| 676 | }
|
---|
| 677 | }
|
---|
[479] | 678 | }
|
---|
| 679 | //checking for end of chamber growth process
|
---|
[567] | 680 | else if (cr.data->lifeparams->chamber_growth == 0 && visualization(cr)==0)
|
---|
| 681 | {
|
---|
| 682 | foramGrow(cr, lastChamberNum(cr), 1);
|
---|
[479] | 683 | cr.data->lifeparams->chamber_growth = -1;
|
---|
| 684 | //Simulator.print("chamber "+ (lastChamberNum(cr) + 1) +" complete");
|
---|
[430] | 685 | }
|
---|
[479] | 686 | else
|
---|
[422] | 687 | {
|
---|
[479] | 688 | //update of metabolism rate
|
---|
| 689 | if (cr.data->lifeparams->hibernated == 0)
|
---|
[401] | 690 | {
|
---|
[479] | 691 | setForamMeta(cr);
|
---|
| 692 | }
|
---|
| 693 |
|
---|
| 694 | if (deathConditions(cr) == 1)
|
---|
| 695 | {
|
---|
[493] | 696 | if (ExpProperties.logging == 1)
|
---|
| 697 | {
|
---|
| 698 | log(createLogVector(cr, cr.data->lifeparams->max_energy_level),ExpProperties.logPref+"fossil_log.txt");
|
---|
[552] | 699 | log(createLogVector(cr, cr.lifespan),ExpProperties.logPref+"lifespan_log.txt");
|
---|
[493] | 700 | }
|
---|
[479] | 701 | Populations[0].kill(cr);
|
---|
| 702 | return;
|
---|
| 703 | }
|
---|
| 704 |
|
---|
[552] | 705 | //update direction change counter
|
---|
| 706 | cr.data->lifeparams->dir_counter += 1;
|
---|
| 707 |
|
---|
[479] | 708 | foramMove(cr);
|
---|
| 709 |
|
---|
| 710 | var repro = foramReproduce(cr);
|
---|
| 711 | if (repro == 1)
|
---|
| 712 | {
|
---|
| 713 | return;
|
---|
| 714 | }
|
---|
| 715 |
|
---|
| 716 | cr.data->lifeparams->max_energy_level = Math.max(cr.energy, cr.data->lifeparams->max_energy_level);
|
---|
| 717 |
|
---|
| 718 | //cheking conditions of chamber growth process start
|
---|
[567] | 719 | if (lastChamberNum(cr) < max_chamber_volume[cr.data->lifeparams->gen].size)
|
---|
[479] | 720 | {
|
---|
[567] | 721 | if ((cr.data->lifeparams->max_energy_level >= energyFromVolume(max_chamber_volume[cr.data->lifeparams->gen][lastChamberNum(cr)-1],0)))
|
---|
[479] | 722 | {
|
---|
[554] | 723 | cr.data->lifeparams->chamber_growth = int(secToSimSteps(ExpProperties.chamberGrowthSec));
|
---|
[479] | 724 | }
|
---|
| 725 | }
|
---|
[430] | 726 | }
|
---|
[380] | 727 | }
|
---|
| 728 |
|
---|
[422] | 729 | function deathConditions(cr)
|
---|
| 730 | {
|
---|
[486] | 731 | if ((cr.energy <= getProperty(cr.data->lifeparams->gen,"e_death_level")*cr.data->lifeparams->max_energy_level) || (Math.rnd01 < ExpProperties.hunted_prob))
|
---|
[479] | 732 | {
|
---|
[422] | 733 | return 1;
|
---|
[479] | 734 | }
|
---|
[422] | 735 | else
|
---|
| 736 | return 0;
|
---|
| 737 | }
|
---|
| 738 |
|
---|
[421] | 739 | function onForamsDied(cr)
|
---|
[380] | 740 | {
|
---|
[444] | 741 | if (visualization(cr))
|
---|
[430] | 742 | {
|
---|
[476] | 743 | Populations[2].delete(cr.data->reticulopodiacreature);
|
---|
[430] | 744 | }
|
---|
[380] | 745 | //fossilization
|
---|
| 746 | var geno = GenePools[0].add(cr.genotype);
|
---|
[476] | 747 | geno.data->genes = cr.data->genes;
|
---|
| 748 | geno.data->lifeparams = cr.data->lifeparams;
|
---|
[486] | 749 | if (ExpProperties.logging == 1) Simulator.print("\"" + cr.name + "\" died...");
|
---|
[380] | 750 | ExpState.totaltestedcr++;
|
---|
| 751 | }
|
---|
| 752 |
|
---|
[421] | 753 | // --------------------------------foram end -------------------------------------
|
---|
[380] | 754 |
|
---|
[421] | 755 | // -------------------------------- nutrient begin --------------------------------
|
---|
[380] | 756 |
|
---|
[479] | 757 | function createNutrientGenotype(nutrientradius)
|
---|
[422] | 758 | {
|
---|
[524] | 759 | return "//0\nm:Vstyle=nutrient\np:sh=3,sx="+nutrientradius+",sy="+nutrientradius+",sz="+nutrientradius+",ry=1.57,vr=0.0,1.0,0.0";
|
---|
[422] | 760 | }
|
---|
| 761 |
|
---|
[421] | 762 | function onNutrientsStep(cr)
|
---|
[380] | 763 | {
|
---|
[444] | 764 | cr.moveAbs(cr.pos_x % World.wrldsiz, cr.pos_y % World.wrldsiz, 0.5);
|
---|
[380] | 765 | }
|
---|
| 766 |
|
---|
[421] | 767 | function addNutrient()
|
---|
[380] | 768 | {
|
---|
[486] | 769 | var cr = Populations[1].add(createNutrientGenotype(ExpProperties.nutrientradius));
|
---|
[380] | 770 |
|
---|
[421] | 771 | cr.name = "Nutrients";
|
---|
[380] | 772 | cr.idleen = 0;
|
---|
[486] | 773 | cr.energy0 = ExpProperties.energy_nut;
|
---|
[416] | 774 | cr.energy = cr.energy0;
|
---|
[421] | 775 | cr.signals.add("nutrient");
|
---|
[380] | 776 |
|
---|
[430] | 777 | cr.signals[0].value = cr;
|
---|
[380] | 778 |
|
---|
[422] | 779 | placeCreatureRandomly(cr, 0, 0);
|
---|
[486] | 780 | if (ExpProperties.visualize == 1)
|
---|
[444] | 781 | {
|
---|
[486] | 782 | var nutsize = ExpProperties.nutrientradius*10;
|
---|
[555] | 783 | var nut = Populations[2].add("//0\nm:Vstyle=nutrient_visual\np:sh=2,sx="+nutsize+",sy="+nutsize+",sz="+nutsize+",ry=1.5,vr=0.0,1.0,0.0");
|
---|
[476] | 784 | cr.data->reticulopodiacreature = nut;
|
---|
[444] | 785 | nut.moveAbs(cr.pos_x-1.5*nutsize, cr.pos_y-1.5*nutsize, 0.5);
|
---|
| 786 | }
|
---|
[380] | 787 | }
|
---|
| 788 |
|
---|
[444] | 789 | function onNutrientsDied(cr)
|
---|
| 790 | {
|
---|
| 791 | if (visualization(cr))
|
---|
| 792 | {
|
---|
[476] | 793 | Populations[2].delete(cr.data->reticulopodiacreature);
|
---|
[444] | 794 | }
|
---|
| 795 | }
|
---|
| 796 |
|
---|
[422] | 797 | function nutrientGrowth()
|
---|
[380] | 798 | {
|
---|
[486] | 799 | if (ExpProperties.foodPeriodChange > 0)
|
---|
[481] | 800 | {
|
---|
| 801 | changePeriod += 1;
|
---|
[554] | 802 | if (phase=="low" && changePeriod >= secToSimSteps(23328000)) //9 months
|
---|
[481] | 803 | {
|
---|
[486] | 804 | ExpProperties.foodperiod = ExpProperties.foodperiod/ExpProperties.foodPeriodChange;
|
---|
[481] | 805 | phase = "high";
|
---|
| 806 | changePeriod = 0;
|
---|
| 807 | }
|
---|
| 808 |
|
---|
[554] | 809 | else if (phase == "high" && changePeriod >= secToSimSteps(7776000)) //3 months
|
---|
[481] | 810 | {
|
---|
[486] | 811 | ExpProperties.foodperiod = ExpProperties.foodperiod*ExpProperties.foodPeriodChange;
|
---|
[481] | 812 | phase = "low";
|
---|
| 813 | changePeriod = 0;
|
---|
| 814 | }
|
---|
| 815 | }
|
---|
[474] | 816 | nutrientenergywaiting = nutrientenergywaiting + 1;
|
---|
[554] | 817 | if (nutrientenergywaiting >= secToSimSteps(ExpProperties.foodperiod))
|
---|
[380] | 818 | {
|
---|
[493] | 819 | for (var i = 0; i < ExpProperties.nutrient_pop; i++)
|
---|
[432] | 820 | {
|
---|
[422] | 821 | addNutrient();
|
---|
| 822 | }
|
---|
| 823 |
|
---|
| 824 | nutrientenergywaiting = 0.0;
|
---|
| 825 | Simulator.checkpoint();
|
---|
[493] | 826 |
|
---|
| 827 | if (ExpProperties.logging == 1)
|
---|
| 828 | {
|
---|
| 829 | log([ExpProperties.nutrient_pop],ExpProperties.logPref+"nutrients_log.txt");
|
---|
| 830 | }
|
---|
[380] | 831 | }
|
---|
[493] | 832 |
|
---|
[380] | 833 | }
|
---|
| 834 |
|
---|
[421] | 835 | // -------------------------------- nutrient end --------------------------------
|
---|
[380] | 836 |
|
---|
[422] | 837 | // -------------------------------- step begin --------------------------------
|
---|
[380] | 838 |
|
---|
[422] | 839 | function onStep()
|
---|
| 840 | {
|
---|
[432] | 841 |
|
---|
| 842 | nutrientGrowth();
|
---|
[486] | 843 | if (ExpProperties.logging == 1)
|
---|
[422] | 844 | {
|
---|
| 845 | createStatistics();
|
---|
| 846 | }
|
---|
| 847 |
|
---|
| 848 | //reproduction --------------------------------------------
|
---|
| 849 | reprocounter += 1;
|
---|
[554] | 850 | if (reprocounter > secToSimSteps(ExpProperties.reproTimeSec))
|
---|
[422] | 851 | {
|
---|
| 852 | reprocounter = 0;
|
---|
[567] | 853 | for (var s = 0; s < species_genes.size; s++)
|
---|
| 854 | {
|
---|
| 855 | reproduce_parents(s);
|
---|
| 856 | }
|
---|
| 857 |
|
---|
[422] | 858 | }
|
---|
| 859 |
|
---|
| 860 | //check for extinction -----------------------------------------------
|
---|
| 861 | if (Populations[0].size == 0)
|
---|
| 862 | {
|
---|
[486] | 863 | if (ExpProperties.autorestart)
|
---|
[422] | 864 | {
|
---|
| 865 | Simulator.print("no more creatures, restarting...");
|
---|
| 866 | onExpInit();
|
---|
| 867 | }
|
---|
| 868 | else
|
---|
| 869 | {
|
---|
| 870 | Simulator.print("no more creatures, stopped.");
|
---|
| 871 | Simulator.stop();
|
---|
| 872 | }
|
---|
| 873 | }
|
---|
[486] | 874 | if (ExpProperties.maxSteps > 0)
|
---|
[432] | 875 | {
|
---|
[486] | 876 | if (Simulator.stepNumber >= ExpProperties.maxSteps)
|
---|
[432] | 877 | Simulator.stop();
|
---|
| 878 | }
|
---|
[422] | 879 | }
|
---|
| 880 |
|
---|
| 881 | function createStatistics()
|
---|
| 882 | {
|
---|
[487] | 883 | var number = [];
|
---|
| 884 | var e_inc = [];
|
---|
[422] | 885 | var e_nut = 0.0;
|
---|
| 886 |
|
---|
[487] | 887 | for (var s = 0; s < species_genes.size; s++)
|
---|
| 888 | {
|
---|
| 889 | number.add([0,0]);// [haplo][diplo]
|
---|
| 890 | e_inc.add([0,0]);
|
---|
| 891 | }
|
---|
| 892 |
|
---|
[422] | 893 | for (var i = 0; i < Populations[0].size; i++)
|
---|
| 894 | {
|
---|
| 895 | var cr = Populations[0].get(i);
|
---|
[476] | 896 | var gen = cr.data->lifeparams->gen;
|
---|
| 897 | var species = cr.data->lifeparams->species;
|
---|
[430] | 898 |
|
---|
| 899 | number[species][gen] = number[species][gen] + 1;
|
---|
| 900 | e_inc[species][gen] = e_inc[species][gen] + cr.energy;
|
---|
[422] | 901 | }
|
---|
| 902 |
|
---|
| 903 | for (var i = 0; i < Populations[1].size; i++)
|
---|
| 904 | {
|
---|
| 905 | var cr = Populations[1].get(i);
|
---|
| 906 | e_nut += cr.energy;
|
---|
| 907 | }
|
---|
| 908 |
|
---|
[487] | 909 | var log_numbers = [];
|
---|
| 910 | var log_energies = [];
|
---|
[422] | 911 |
|
---|
[487] | 912 | for (var s = 0; s < species_genes.size; s++)
|
---|
| 913 | {
|
---|
| 914 | for (var p = 0; p < 2; p++)
|
---|
| 915 | {
|
---|
| 916 | log_numbers.add(number[s][p]);
|
---|
| 917 | log_energies.add(e_inc[s][p]);
|
---|
| 918 | }
|
---|
| 919 | }
|
---|
| 920 |
|
---|
| 921 | log_numbers.add(Populations[1].size);
|
---|
| 922 | log_energies.add(e_nut);
|
---|
| 923 |
|
---|
[493] | 924 | log(log_numbers, ExpProperties.logPref+"forams_log.txt");
|
---|
| 925 | log(log_energies, ExpProperties.logPref+"energies_log.txt");
|
---|
[422] | 926 | }
|
---|
| 927 |
|
---|
[380] | 928 | function log(tolog, fname)
|
---|
| 929 | {
|
---|
[430] | 930 | var f = File.appendDirect(fname, "forams data");
|
---|
[380] | 931 | f.writeString("" + Simulator.stepNumber);
|
---|
[401] | 932 | for (var i = 0; i < tolog.size; i++)
|
---|
[380] | 933 | {
|
---|
| 934 | f.writeString(";" + tolog[i]);
|
---|
| 935 | }
|
---|
| 936 | f.writeString("\n");
|
---|
| 937 | f.close();
|
---|
| 938 | }
|
---|
| 939 |
|
---|
[567] | 940 | function createLogVector(cr, value)
|
---|
| 941 | {
|
---|
| 942 | var vec = Vector.new();
|
---|
| 943 | for (var i = 0; i < species_genes.size; i++)
|
---|
| 944 | {
|
---|
| 945 | for (var j = 0; j < 2; j++)
|
---|
| 946 | {
|
---|
| 947 | vec.add(0);
|
---|
| 948 | }
|
---|
| 949 | if (cr.data->lifeparams->species == i)
|
---|
| 950 | {
|
---|
| 951 | vec[i*2+cr.data->lifeparams->gen] = value;
|
---|
| 952 | }
|
---|
| 953 | }
|
---|
| 954 | return vec;
|
---|
| 955 | }
|
---|
| 956 |
|
---|
| 957 |
|
---|
[422] | 958 | // -------------------------------- step end --------------------------------
|
---|
[479] | 959 | //TODO default params values in frams instead of microns/seconds
|
---|
[380] | 960 |
|
---|
[401] | 961 | @include "standard_events.inc"
|
---|
[380] | 962 |
|
---|
[401] | 963 | ~
|
---|
[380] | 964 |
|
---|
[486] | 965 | property:
|
---|
[444] | 966 | id:visualize
|
---|
| 967 | name:Show reticulopodia and nutrients
|
---|
[430] | 968 | type:d 0 1 0
|
---|
[554] | 969 | group:
|
---|
[430] | 970 |
|
---|
[486] | 971 | property:
|
---|
[434] | 972 | id:maxSteps
|
---|
[554] | 973 | name:Maximum number of steps
|
---|
[552] | 974 | type:d 0 10000000 0
|
---|
[554] | 975 | group:
|
---|
[432] | 976 |
|
---|
[486] | 977 | property:
|
---|
[567] | 978 | id:scalingFactor
|
---|
| 979 | name:Scaling factor for micrometers
|
---|
| 980 | type:f 0 -1 0.01
|
---|
| 981 | group:
|
---|
| 982 |
|
---|
| 983 | property:
|
---|
[554] | 984 | id:logging
|
---|
| 985 | name:Log statistics to file
|
---|
| 986 | type:d 0 1 0
|
---|
| 987 | group:
|
---|
| 988 |
|
---|
| 989 | property:
|
---|
[493] | 990 | id:logPref
|
---|
| 991 | name:Log prefix
|
---|
| 992 | type:s
|
---|
| 993 |
|
---|
| 994 | property:
|
---|
[554] | 995 | id:secPerStep
|
---|
| 996 | name:Seconds per simulation step
|
---|
| 997 | help:Number of seconds of foraminifera time per simulation step
|
---|
| 998 | type:f 1 480 300
|
---|
| 999 | flags: 16
|
---|
| 1000 | group:
|
---|
| 1001 |
|
---|
| 1002 | property:
|
---|
[474] | 1003 | id:foramSpeedMmPerMin
|
---|
| 1004 | name:Speed of foraminfera in mm/min
|
---|
[554] | 1005 | type:f 0.01 0.1 0.05
|
---|
[474] | 1006 | flags: 16
|
---|
| 1007 | group:Foraminifera
|
---|
| 1008 |
|
---|
[486] | 1009 | property:
|
---|
[554] | 1010 | id:dir_change_sec
|
---|
| 1011 | name:Number of seconds before direction change
|
---|
| 1012 | type:d 300 300000 6000
|
---|
[479] | 1013 | group:Foraminifera
|
---|
| 1014 |
|
---|
[486] | 1015 | property:
|
---|
[554] | 1016 | id:foramPop
|
---|
| 1017 | name:Initial forams population size
|
---|
| 1018 | type:d 1 1000 20
|
---|
[552] | 1019 | group:Foraminifera
|
---|
| 1020 |
|
---|
| 1021 | property:
|
---|
[554] | 1022 | id:gametoPeriodSec
|
---|
[479] | 1023 | name:Time of gametogenesis
|
---|
[554] | 1024 | type:f 300 300000 21600
|
---|
| 1025 | group:Reproduction
|
---|
[479] | 1026 |
|
---|
[486] | 1027 | property:
|
---|
[554] | 1028 | id:gametSuccessRate
|
---|
| 1029 | name:Ratio of successful gamets
|
---|
| 1030 | type:f 0.0001 0.01 0.001
|
---|
| 1031 | group:Reproduction
|
---|
[479] | 1032 |
|
---|
[486] | 1033 | property:
|
---|
[554] | 1034 | id:divisionCost
|
---|
| 1035 | name:Cost of division in pG
|
---|
| 1036 | type:f 15 25 20
|
---|
| 1037 | group:Reproduction
|
---|
[474] | 1038 |
|
---|
[486] | 1039 | property:
|
---|
[554] | 1040 | id:min_repro_energ_haplo
|
---|
[567] | 1041 | name:Min reproduction energy of haploid in pg
|
---|
| 1042 | type:f 0 -1 350000
|
---|
[554] | 1043 | group:Energy
|
---|
[380] | 1044 |
|
---|
[486] | 1045 | property:
|
---|
[554] | 1046 | id:min_repro_energ_diplo
|
---|
[567] | 1047 | name:Min reproduction energy of diploid in pg
|
---|
| 1048 | type:f 0 -1 600000
|
---|
[554] | 1049 | group:Energy
|
---|
[479] | 1050 |
|
---|
[486] | 1051 | property:
|
---|
[554] | 1052 | id:repro_prob
|
---|
| 1053 | name:Probability of reproduction
|
---|
| 1054 | type:f 0 1 0.8
|
---|
| 1055 | group:Reproduction
|
---|
[380] | 1056 |
|
---|
[486] | 1057 | property:
|
---|
[554] | 1058 | id:energies0_haplo
|
---|
| 1059 | name:Energy of offspring from diploid forams
|
---|
| 1060 | type:f 0 -1 20
|
---|
| 1061 | group:Energy
|
---|
[479] | 1062 |
|
---|
[486] | 1063 | property:
|
---|
[554] | 1064 | id:energies0_diplo
|
---|
| 1065 | name:Energy of offspring from diploid forams
|
---|
| 1066 | type:f 0 -1 1.25
|
---|
| 1067 | group:Energy
|
---|
| 1068 |
|
---|
| 1069 | property:
|
---|
[567] | 1070 | id:max_chamber_num_haplo
|
---|
| 1071 | name:Maximum number of haploid chambers
|
---|
| 1072 | type:f 1 50 35
|
---|
| 1073 | group:Energy
|
---|
| 1074 |
|
---|
| 1075 | property:
|
---|
| 1076 | id:max_chamber_num_diplo
|
---|
| 1077 | name:Maximum number of diploid chambers
|
---|
| 1078 | type:f 1 50 35
|
---|
| 1079 | group:Energy
|
---|
| 1080 |
|
---|
| 1081 |
|
---|
| 1082 | property:
|
---|
[554] | 1083 | id:crossprob
|
---|
| 1084 | name:Crossover probability
|
---|
| 1085 | type:f 0 1 0
|
---|
| 1086 | group:Reproduction
|
---|
| 1087 |
|
---|
| 1088 | property:
|
---|
| 1089 | id:mutationprob
|
---|
| 1090 | name:Mutation probability
|
---|
| 1091 | type:f 0 1 0
|
---|
| 1092 | group:Reproduction
|
---|
| 1093 |
|
---|
| 1094 | property:
|
---|
| 1095 | id:reproTimeSec
|
---|
| 1096 | name:Time before reproduction
|
---|
| 1097 | type:d 0 10000 720
|
---|
| 1098 | group:Reproduction
|
---|
| 1099 |
|
---|
| 1100 | property:
|
---|
| 1101 | id:chamberGrowthSec
|
---|
| 1102 | name:Time of the chamber growth in seconds
|
---|
[567] | 1103 | type:f 720 43200 43200
|
---|
[479] | 1104 | group:Foraminifera
|
---|
| 1105 |
|
---|
[486] | 1106 | property:
|
---|
[422] | 1107 | id:chamber_proculus_haplo
|
---|
[423] | 1108 | name:Size of proculus
|
---|
[422] | 1109 | type:f
|
---|
[421] | 1110 | group:Foraminifera
|
---|
[380] | 1111 |
|
---|
[486] | 1112 | property:
|
---|
[422] | 1113 | id:chamber_proculus_diplo
|
---|
[423] | 1114 | name:Size of proculus
|
---|
[422] | 1115 | type:f
|
---|
[380] | 1116 | group:Foraminifera
|
---|
| 1117 |
|
---|
[486] | 1118 | property:
|
---|
[422] | 1119 | id:hunted_prob
|
---|
| 1120 | name:Probability of being hunted
|
---|
| 1121 | type:f 0 1 0
|
---|
[554] | 1122 | group:Foraminifera
|
---|
[380] | 1123 |
|
---|
[486] | 1124 | property:
|
---|
[557] | 1125 | id:zone1_range
|
---|
[556] | 1126 | name:Zone 1 range in frams units
|
---|
[554] | 1127 | type:f 0 200 10
|
---|
[422] | 1128 | group:Foraminifera
|
---|
[380] | 1129 |
|
---|
[486] | 1130 | property:
|
---|
[422] | 1131 | id:zone2_range
|
---|
[556] | 1132 | name:Zone 2 range in frams units
|
---|
[554] | 1133 | type:f 0 3000 30
|
---|
[421] | 1134 | group:Foraminifera
|
---|
[380] | 1135 |
|
---|
[486] | 1136 | property:
|
---|
[554] | 1137 | id:chamberCostPerSec
|
---|
| 1138 | name:Cost of growning chamber per second
|
---|
| 1139 | type:f 0 1 0.000001
|
---|
| 1140 | group:Energy
|
---|
[380] | 1141 |
|
---|
[486] | 1142 | property:
|
---|
[475] | 1143 | id:e_death_level_haplo
|
---|
| 1144 | name:Minimal level of energy to sustain life of haploid
|
---|
[554] | 1145 | type:f 0 1 0.5
|
---|
| 1146 | group:Energy
|
---|
[475] | 1147 |
|
---|
[486] | 1148 | property:
|
---|
[475] | 1149 | id:e_death_level_diplo
|
---|
| 1150 | name:Minimal level of energy to sustain life of diploid
|
---|
[554] | 1151 | type:f 0 1 0.5
|
---|
| 1152 | group:Energy
|
---|
[475] | 1153 |
|
---|
[486] | 1154 | property:
|
---|
[422] | 1155 | id:energy_hib
|
---|
| 1156 | name:Energy used for hibernation during one step
|
---|
[554] | 1157 | type:f 0 1 0.0000001
|
---|
| 1158 | group:Energy
|
---|
[422] | 1159 |
|
---|
[486] | 1160 | property:
|
---|
[422] | 1161 | id:energy_move
|
---|
| 1162 | name:Energy used for movement during one step
|
---|
[554] | 1163 | type:f 0 1 0.0000005
|
---|
| 1164 | group:Energy
|
---|
[422] | 1165 |
|
---|
[486] | 1166 | property:
|
---|
[380] | 1167 | id:e_meta
|
---|
| 1168 | name:Idle metabolism
|
---|
[554] | 1169 | type:f 0 1 0.0000005
|
---|
[380] | 1170 | group:Energy
|
---|
[556] | 1171 | help:Foraminifera consumes this proportion of its energy in one time step
|
---|
[380] | 1172 |
|
---|
[486] | 1173 | property:
|
---|
[554] | 1174 | id:ingestion
|
---|
| 1175 | name:Ingestion rate
|
---|
| 1176 | type:f 0 -1 0.25
|
---|
| 1177 | group:Energy
|
---|
| 1178 |
|
---|
| 1179 | property:
|
---|
[493] | 1180 | id:nutrient_pop
|
---|
[554] | 1181 | name:Nutrient population
|
---|
[474] | 1182 | type:f 0 1000000
|
---|
[380] | 1183 | group:Energy
|
---|
| 1184 | help:How fast energy is created in the world
|
---|
| 1185 |
|
---|
[486] | 1186 | property:
|
---|
[554] | 1187 | id:energy_nut
|
---|
| 1188 | name:Nutrient energy
|
---|
| 1189 | type:f 0 10000000
|
---|
[481] | 1190 | group:Energy
|
---|
| 1191 |
|
---|
[486] | 1192 | property:
|
---|
[554] | 1193 | id:nutrientradius
|
---|
| 1194 | name:Nutrient size
|
---|
| 1195 | type:f 0.001 0.9 0.1
|
---|
[479] | 1196 | group:Energy
|
---|
| 1197 |
|
---|
[486] | 1198 | property:
|
---|
[554] | 1199 | id:picoCarbonPerMikro
|
---|
[556] | 1200 | name:Picograms of carbon in cubic micrometer
|
---|
[554] | 1201 | type:f 0 -1 0.13
|
---|
[380] | 1202 | group:Energy
|
---|
| 1203 |
|
---|
[486] | 1204 | property:
|
---|
[380] | 1205 | id:feedtrans
|
---|
[479] | 1206 | name:Energy transfer per second
|
---|
[554] | 1207 | type:f 0 1 0.001
|
---|
[380] | 1208 | group:Energy
|
---|
[422] | 1209 |
|
---|
[486] | 1210 | property:
|
---|
[479] | 1211 | id:foodperiod
|
---|
| 1212 | name:Time between food occurrences
|
---|
[554] | 1213 | type:f 0 1000000 14400
|
---|
[422] | 1214 | group:Energy
|
---|
| 1215 |
|
---|
[486] | 1216 | property:
|
---|
[554] | 1217 | id:foodPeriodChange
|
---|
| 1218 | name:Set variable feed rate
|
---|
| 1219 | type:f 0 -1 0
|
---|
[421] | 1220 | group:Energy
|
---|
| 1221 |
|
---|
[486] | 1222 | property:
|
---|
[422] | 1223 | id:stress
|
---|
| 1224 | name:Environmental stress
|
---|
| 1225 | type:d 0 1 1
|
---|
[554] | 1226 | group:
|
---|
[422] | 1227 |
|
---|
[486] | 1228 | property:
|
---|
[422] | 1229 | id:repro_trigger
|
---|
| 1230 | name:Reproduction trigger
|
---|
| 1231 | type:d 0 1 1
|
---|
[554] | 1232 | group:Reproduction
|
---|
[422] | 1233 |
|
---|
[486] | 1234 | property:
|
---|
[422] | 1235 | id:creath
|
---|
| 1236 | name:Creation height
|
---|
[554] | 1237 | type:f -1 50 -0.99
|
---|
[422] | 1238 | help:~
|
---|
| 1239 | Vertical position (above the surface) where new Forams are revived.
|
---|
| 1240 | Negative values are only used in the water area:
|
---|
| 1241 | 0 = at the surface
|
---|
| 1242 | -0.5 = half depth
|
---|
| 1243 | -1 = just above the bottom~
|
---|
| 1244 |
|
---|
[554] | 1245 | property:
|
---|
| 1246 | id:autorestart
|
---|
| 1247 | name:Restart after extinction
|
---|
| 1248 | help:Restart automatically this experiment after the last creature has died?
|
---|
| 1249 | type:d 0 1 0
|
---|
| 1250 |
|
---|
[421] | 1251 | state:
|
---|
| 1252 | id:nutrient
|
---|
[428] | 1253 | name:Nutrient locations
|
---|
[421] | 1254 | help:vector of vectors [x,y,energy]
|
---|
| 1255 | type:x
|
---|
| 1256 | flags:32
|
---|
| 1257 |
|
---|
[380] | 1258 | state:
|
---|
| 1259 | id:notes
|
---|
| 1260 | name:Notes
|
---|
| 1261 | type:s 1
|
---|
| 1262 | help:~
|
---|
| 1263 | You can write anything here
|
---|
| 1264 | (it will be saved to the experiment file)~
|
---|
| 1265 |
|
---|
| 1266 | state:
|
---|
| 1267 | id:totaltestedcr
|
---|
[421] | 1268 | name:Evaluated Forams
|
---|
| 1269 | help:Total number of the Forams evaluated in the experiment
|
---|
[380] | 1270 | type:d
|
---|
| 1271 | flags:16
|
---|