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