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