Changeset 567 for experiments
- Timestamp:
- 08/07/16 15:05:16 (8 years ago)
- Location:
- experiments/frams/foraminifera/data/scripts
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
experiments/frams/foraminifera/data/scripts/foraminifera.expdef
r561 r567 23 23 code:~ 24 24 25 global chambers;26 25 global colors; 27 26 global retColors; … … 30 29 global movePerStep; 31 30 global nutrientenergywaiting; 32 global o;33 31 global reprocounter; 34 32 global changePeriod; 35 33 global phase; 36 34 global nutrientSqrCm; 37 global species_genes; 35 global species_genes; 36 global max_chambers_def; 37 global foram_uid; //introduced because each replacement of a creature (while growing) would generate a new Creature.uid 38 global chamber_vis_denominator; 39 global curRadius; 38 40 39 41 @include "foraminifera.inc" … … 96 98 97 99 //morphology 98 init_chambers();99 curColor = retColors[0];100 100 ExpProperties.zone1_range = micronsToFrams(1000); 101 101 ExpProperties.zone2_range = micronsToFrams(3000); 102 ExpProperties.chamber_proculus_haplo = micronsToFrams(50); 103 ExpProperties.chamber_difference_haplo = 0.0; 104 ExpProperties.chamber_proculus_diplo = micronsToFrams(20); 105 ExpProperties.chamber_difference_diplo = micronsToFrams(8); 106 107 max_chamber_volume = [Vector.new(), Vector.new()]; 108 for (var j = 0; j < 2; j++) 109 { 110 for (var i = 0; i < chambers[0].size; i++) 111 { 112 max_chamber_volume[j].add(((volumeInMicrons(getProperty(j, "chamber_proculus")) + volumeInMicrons(getProperty(j, "chamber_proculus") + (i) * getProperty(j, "chamber_difference")))*(i+1))/2); 113 } 114 } 102 ExpProperties.chamber_proculus_haplo = micronsToFrams(20); 103 ExpProperties.chamber_proculus_diplo = micronsToFrams(10); 104 colors = ["1.0,1.0,0.0","1.0,0.5,0.0"]; 105 retColors = ["1.0,1.0,1.0", "1.0,1.0,0.0"]; 106 curColor = retColors[0]; 107 curRadius = ExpProperties.zone1_range; 115 108 116 109 //nutrients … … 122 115 ExpState.totaltestedcr = 0; 123 116 ExpState.nutrient = ""; 124 117 118 max_chambers_def = 35; 119 chamber_vis_denominator = 6; 125 120 //addSpecies({"min_repro_energies" : [4,6]}); 126 121 //addSpecies({"min_repro_energies" : [4,8]}); … … 132 127 @include "standard_placement.inc" 133 128 134 function secToSimSteps(value_in_sec){135 return value_in_sec/ExpProperties.secPerStep;136 }137 138 function volumeInMicrons(radiusInFrams)139 {140 return 4.0/3.0*Math.pi*Math.pow(framsToMicrons(radiusInFrams),3);141 }142 143 function energyFromVolume(base, isRadiusInFrams)144 {145 if (isRadiusInFrams == 1) //radius in frams146 {147 return ExpProperties.picoCarbonPerMikro*volumeInMicrons(base);148 }149 else //volume in microns150 {151 return ExpProperties.picoCarbonPerMikro * base;152 }153 }154 155 function getMovePerStep()156 {157 return micronsToFrams((ExpProperties.foramSpeedMmPerMin/60)*1000)*ExpProperties.secPerStep;158 }159 160 function micronsToFrams(micrometers)161 {162 return micrometers*0.01;163 }164 165 function framsToMicrons(framsworldunits)166 {167 return framsworldunits/0.01;168 }169 170 function getProperty(gen, prop_id)171 {172 var ploid = "haplo";173 if (gen == 1) ploid = "diplo";174 return ExpProperties.[prop_id + "_" + ploid];175 }176 177 function getGene(cr, gen_id, gen_set)178 {179 if (cr.data->lifeparams->gen == 0)180 return cr.data->genes[gen_id];181 else182 return cr.data->genes[gen_set][gen_id];183 }184 185 function addForam(species, iter, chambernum, ploid)186 {187 var geno = createForamMorphology(ploid, ploid, chambernum);188 curColor = retColors[ploid];189 var cr = Populations[0].add(geno);190 cr.name = "Initial creature" + species + "_" + iter;191 placeCreatureRandomly(cr, 0, 0);192 cr.energy0 = energyFromVolume(max_chamber_volume[ploid][chambernum],0);193 cr.energy = cr.energy0;194 setGenotype({"opt" : "birth", "cr" : cr, "gen" : ploid, "species" : species, "energy0" : cr.energy0, "genes" : species_genes[species]});195 if (ploid == 1)196 {197 cr.data->genes = [cr.data->genes, cr.data->genes]; //TODO two different genes sets198 }199 moveReticulopodia(cr);200 }201 202 function addInitialForam(species, iter)203 {204 var ploid = 0;205 if (Math.rnd01 > 0.5)206 {207 ploid = 1;208 }209 //add new foram with random energy bewtween starting energy and reproduction threshold210 addForam(species, iter, int(Math.rndUni(0,species_genes[species]->min_repro_energies[ploid])),ploid);211 }212 213 //new species can be added as a dictionary with parameter values that are different than default values214 function addSpecies(new_genes)215 {216 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});217 for (var i = 0; i < new_genes.size; i++)218 {219 var key = new_genes.getKey(i);220 species_genes[species_genes.size-1][key] = new_genes[key];221 }222 }223 224 129 function onExpInit() 225 130 { 131 foram_uid = 0; 132 226 133 Populations[0].clear(); 227 134 Populations[1].clear(); 228 135 Populations[2].clear(); //reticulopodia and nutrients 229 136 137 if (ExpProperties.max_chamber_num_haplo == max_chambers_def && ExpProperties.max_chamber_num_diplo == max_chambers_def) 138 { 139 max_chamber_volume = [[30403.5869594578,52812.2546633948,79578.5148482541,113588.815134453,154620.677376218,205094.322220826,262572.712174265,326078.453295303,402342.518962956,498133.985678766,615066.864740109,759500.497626816,937064.025544282,1155915.25563075,1429139.14079748,1762487.92940157,2176286.62046069,2685795.63187845,3316190.12127043,4096436.04462706,5051343.25226193,6231980.1061213,7687880.79524734,9485307.02904958,11716968.9852569,14459866.4934433,17836388.9853663,22004935.7247348,27138607.2546045,33482425.1582986,41336775.1280297,50997910.7842793,62888631.7871037,77563060.9243464,95659468.591964] 140 , [3430.07716920763,6159.93090353532,9322.94192815286,13462.9896597283,18399.8550832969,24558.9218126892,31468.8148639192,39189.4977865513,48404.4292075836,60185.8639086061,74490.6048472854,92117.8178412275,113852.779747083,140714.366929552,174450.937643841,215250.242147183,266323.295274072,328858.042352538,406552.379957238,503526.321155323,621060.781025019,767240.824049468,947210.683224091,1169506.19906112,1447211.61255879,1787155.29073739,2205627.64766244,2723413.2837305,3360233.53738709,4147771.02835393,5126445.06973928,6328060.3331703,7805693.278958,9631924.72156452,11884287.1596814]]; 141 } 142 143 else 144 { 145 max_chamber_volume = [Vector.new(), Vector.new()]; 146 var density = 100; 147 for (var ploid = 0; ploid < 2; ploid++) 148 { 149 var rad = getPloidRadius(ploid); 150 for (var cham_num = 0; cham_num < getProperty(ploid,"max_chamber_num"); cham_num++) 151 { 152 max_chamber_volume[ploid].add(volumeFromGeno(ploid, rad, cham_num+1, density)); 153 } 154 } 155 } 156 230 157 if (species_genes.size == 0) 231 158 { … … 240 167 } 241 168 } 242 o = Populations[0][0].getMechPart(0).orient.clone();243 169 ExpState.totaltestedcr = 0; 244 170 … … 312 238 // -------------------------------- experiment end -------------------------------- 313 239 240 function volumeFromGeno(morphotype, rad, chamber_num, density) 241 { 242 var geno = create_genotype(rad, chamber_num, colors[morphotype], 1); 243 var m=Model.newFromString(geno); 244 var mg=ModelGeometry.forModel(m); 245 mg.geom_density=density; 246 var volumeInFrams = mg.volume(); 247 248 return volumeInFrams/Math.pow(ExpProperties.scalingFactor,3); 249 } 250 251 function secToSimSteps(value_in_sec){ 252 return value_in_sec/ExpProperties.secPerStep; 253 } 254 255 function volumeInMicrons(radiusInFrams) 256 { 257 return 4.0/3.0*Math.pi*Math.pow(framsToMicrons(radiusInFrams),3); 258 } 259 260 function energyFromVolume(base, isRadiusInFrams) 261 { 262 if (isRadiusInFrams == 1) //radius in frams 263 { 264 return ExpProperties.picoCarbonPerMikro*volumeInMicrons(base); 265 } 266 else //volume in microns 267 { 268 return ExpProperties.picoCarbonPerMikro * base; 269 } 270 } 271 272 function getMovePerStep() 273 { 274 return micronsToFrams((ExpProperties.foramSpeedMmPerMin/60)*1000)*ExpProperties.secPerStep; 275 } 276 277 function micronsToFrams(micrometers) 278 { 279 return micrometers*ExpProperties.scalingFactor; 280 } 281 282 function framsToMicrons(framsworldunits) 283 { 284 return framsworldunits/ExpProperties.scalingFactor; 285 } 286 287 function getProperty(gen, prop_id) 288 { 289 var ploid = "haplo"; 290 if (gen == 1) ploid = "diplo"; 291 return ExpProperties.[prop_id + "_" + ploid]; 292 } 293 294 function getGene(cr, gen_id, gen_set) 295 { 296 if (cr.data->lifeparams->gen == 0) 297 return cr.data->genes[gen_id]; 298 else 299 return cr.data->genes[gen_set][gen_id]; 300 } 301 302 function getPloidRadius(ploid) 303 { 304 var radius = ExpProperties.chamber_proculus_haplo; 305 if (ploid == 1) 306 { 307 radius = ExpProperties.chamber_proculus_diplo; 308 } 309 return radius; 310 } 311 312 function chamberNumFromEnergy(energy, ploid) 313 { 314 var chamber_num = max_chamber_volume[ploid].size; 315 for (var i = 0; i < chamber_num; i++) 316 { 317 if (energy < energyFromVolume(max_chamber_volume[ploid][i],0)) 318 { 319 chamber_num = i+1; 320 break; 321 } 322 } 323 324 return chamber_num; 325 } 326 327 function addForam(species, iter, start_energy, ploid) 328 { 329 var chambernum = chamberNumFromEnergy(start_energy, ploid); 330 var radius = getPloidRadius(ploid); 331 var geno = create_genotype(radius, chambernum, colors[ploid], 1); 332 curColor = retColors[ploid]; 333 var cr = Populations[0].add(geno); 334 cr.name = "Initial creature" + species + "_" + iter; 335 placeCreatureRandomly(cr, 0, 0); 336 cr.energy = start_energy; 337 setGenotype({"opt" : "birth", "cr" : cr, "gen" : ploid, "species" : species, "energy0" : cr.energy, "genes" : species_genes[species], "parentsuids" : ["c0"]}); 338 if (ploid == 1) 339 { 340 cr.data->genes = [cr.data->genes, cr.data->genes]; //TODO two different genes sets 341 } 342 moveReticulopodia(cr); 343 } 344 345 function addInitialForam(species, iter) 346 { 347 var ploid = 0; 348 if (Math.rnd01 > 0.5) 349 { 350 ploid = 1; 351 } 352 //add new foram with random energy bewtween starting energy and reproduction threshold 353 var repro_thr = species_genes[species]->min_repro_energies[ploid]; 354 var start_energy = Math.rndUni(energyFromVolume(getPloidRadius(ploid),1),repro_thr-0.25*repro_thr); 355 addForam(species, iter, start_energy,ploid); 356 } 357 358 //new species can be added as a dictionary with parameter values that are different than default values 359 function addSpecies(new_genes) 360 { 361 species_genes.add({"min_repro_energies" : [ExpProperties.min_repro_energ_haplo,ExpProperties.min_repro_energ_diplo], "energies0" : [ExpProperties.energies0_haplo, ExpProperties.energies0_diplo], "hibernation" : 0, "morphotype" : 0}); 362 for (var i = 0; i < new_genes.size; i++) 363 { 364 var key = new_genes.getKey(i); 365 species_genes[species_genes.size-1][key] = new_genes[key]; 366 } 367 } 368 314 369 // -------------------------------- foram begin ----------------------------------- 315 370 … … 322 377 function lastChamberNum(cr) 323 378 { 324 return cr.numparts -1;379 return cr.numparts; 325 380 } 326 381 … … 328 383 { 329 384 return ExpProperties.["zone"+zone_num+"_range"]; 385 } 386 387 function addReticulopodia(cr, radius) 388 { 389 if (reticulopodiaExists(cr)) 390 { 391 Populations[2].delete(cr.data->reticulopodiacreature); 392 } 393 var ret = Populations[2].add("//0\nm:Vstyle=reticulopodia\np:sh=1,sx=0.001,sy=0.001,sz=0.001\np:sh=3,sx=0.01,sy="+radius+",sz="+radius+",ry=1.57079633,vr="+curColor+"\nj:0, 1, sh=1"); 394 cr.data->reticulopodiacreature = ret; 395 ret.getMechPart(0).orient.set(cr.getMechPart(0).orient); 396 ret.moveAbs(cr.center_x-radius, cr.center_y-radius, cr.center_z-radius); 330 397 } 331 398 … … 335 402 if (ExpProperties.visualize == 1) 336 403 { 337 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"); 338 cr.data->reticulopodiacreature = ret; 339 ret.getMechPart(0).orient.set(cr.getMechPart(0).orient); 340 ret.moveAbs(cr.center_x-getZoneRange(cr,1), cr.center_y-getZoneRange(cr,1), cr.center_z-getZoneRange(cr,1)); 341 } 404 addReticulopodia(cr, curRadius); 405 } 406 moveReticulopodia(cr); 342 407 } 343 408 … … 355 420 } 356 421 422 function reticulopodiaExists(cr) 423 { 424 var has_ret = 0; 425 426 if (cr.data->reticulopodiacreature != null) 427 { 428 if (Populations[2].findUID(cr.data->reticulopodiacreature.uid) != null) 429 { 430 has_ret = 1; 431 } 432 } 433 434 return has_ret; 435 } 436 357 437 function visualization(cr) 358 438 { 359 var has_ret = 0; 360 361 if (cr.data->reticulopodiacreature != null) 362 { 363 if (Populations[2].findUID(cr.data->reticulopodiacreature.uid) != null) 364 { 365 has_ret = 1; 366 } 367 } 368 369 return has_ret; 370 } 371 372 function foramGrow(cr, chamber_num) 373 { 374 if ((chamber_num+1) < chambers[cr.data->lifeparams->species].size) 439 return reticulopodiaExists(cr); 440 } 441 442 function foramGrow(cr, chamber_num, lastchambergrowth) 443 { 444 if ((chamber_num+1) <= max_chamber_volume[cr.data->lifeparams->gen].size) 375 445 { 376 446 curColor = retColors[cr.data->lifeparams->gen]; 377 var geno = createForamMorphology(cr.data->lifeparams->gen, cr.data->lifeparams->gen, chamber_num+1); 447 var ploid = cr.data->lifeparams->gen; 448 var geno = create_genotype(getPloidRadius(ploid), chamber_num+1, colors[ploid], lastchambergrowth); 378 449 var cr2 = Populations[0].add(geno); 379 450 … … 382 453 383 454 setGenotype({"cr" : cr2, "parent_genes" : cr.data->genes, "parent_lifeparams" : cr.data->lifeparams, "opt" : "growth", "energy0" : cr.energy0}); 384 cr2.moveAbs(cr. center_x - cr2.size_x / 2, cr.center_y - cr2.size_y / 2,cr.pos_z);455 cr2.moveAbs(cr.pos_x, cr.pos_y,cr.pos_z); 385 456 setForamMeta(cr2); 386 457 387 if ( visualization(cr))458 if (reticulopodiaExists(cr)) 388 459 { 389 460 Populations[2].delete(cr.data->reticulopodiacreature); 390 461 } 391 462 Populations[0].delete(cr); 392 } 463 return cr2; 464 } 465 return cr; 393 466 } 394 467 … … 551 624 } 552 625 553 function createLogVector(cr, value)554 {555 var vec = Vector.new();556 for (var i = 0; i < species_genes.size; i++)557 {558 for (var j = 0; j < 2; j++)559 {560 vec.add(0);561 }562 if (cr.data->lifeparams->species == i)563 {564 vec[i*2+cr.data->lifeparams->gen] = value;565 }566 }567 return vec;568 }569 570 626 function onForamsStep(cr) 571 627 { … … 583 639 else if (cr.data->lifeparams->chamber_growth > 0) 584 640 { 585 cr.data->lifeparams->chamber_growth= Math.max(cr.data->lifeparams->chamber_growth-1,0);586 //Simulator.print("chamber growing, time left = " + cr.data->lifeparams->chamber_growth*ExpProperties.secPerStep);641 var chamber_time = Math.max(cr.data->lifeparams->chamber_growth-1,0); 642 cr.data->lifeparams->chamber_growth = chamber_time; 587 643 cr.energy -= ExpProperties.chamberCostPerSec * cr.energy * ExpProperties.secPerStep; 588 644 589 //Simulator.print("energy " + cr2.energy + " subtracting " + growth_cost); 645 if (visualization(cr)) 646 { 647 var total_time = secToSimSteps(ExpProperties.chamberGrowthSec); 648 var ret_unit = total_time/chamber_vis_denominator; 649 var chamber_unit = total_time-ret_unit; 650 651 if (chamber_time < ret_unit || chamber_time >= chamber_unit) 652 { 653 var new_rad = Math.min(Math.max((chamber_time%ret_unit)/ret_unit*getZoneRange(cr,1),0.01),getZoneRange(cr,1)); 654 655 if(chamber_time < ret_unit) 656 new_rad = getZoneRange(cr,1)-new_rad; 657 658 addReticulopodia(cr,new_rad); 659 } 660 else 661 { 662 var new_rad = 1 - Math.min(Math.max((chamber_time-ret_unit)/chamber_unit,0.01),1); 663 curRadius = cr.data->reticulopodiacreature.getPart(1).sy; 664 665 if (chamber_time == ret_unit){ 666 new_rad == 1; 667 } 668 669 var new_cr = foramGrow(cr, chamberNumFromEnergy(cr.data->lifeparams->max_energy_level, cr.data->lifeparams->gen)-1, new_rad); 670 curRadius = getZoneRange(new_cr,1); 671 672 if (chamber_time == 0)//checking for end of chamber growth process 673 { 674 new_cr.data->lifeparams->chamber_growth = -1; 675 } 676 } 677 } 590 678 } 591 679 //checking for end of chamber growth process 592 else if (cr.data->lifeparams->chamber_growth == 0 )593 { 594 foramGrow(cr, lastChamberNum(cr) );680 else if (cr.data->lifeparams->chamber_growth == 0 && visualization(cr)==0) 681 { 682 foramGrow(cr, lastChamberNum(cr), 1); 595 683 cr.data->lifeparams->chamber_growth = -1; 596 684 //Simulator.print("chamber "+ (lastChamberNum(cr) + 1) +" complete"); … … 603 691 setForamMeta(cr); 604 692 } 605 606 cr.getMechPart(0).orient.set(o);607 693 608 694 if (deathConditions(cr) == 1) … … 631 717 632 718 //cheking conditions of chamber growth process start 633 if (lastChamberNum(cr) != chambers[0].size-1)634 { 635 if ((cr.data->lifeparams->max_energy_level >= energyFromVolume(max_chamber_volume[cr.data->lifeparams->gen][lastChamberNum(cr) ],0)))719 if (lastChamberNum(cr) < max_chamber_volume[cr.data->lifeparams->gen].size) 720 { 721 if ((cr.data->lifeparams->max_energy_level >= energyFromVolume(max_chamber_volume[cr.data->lifeparams->gen][lastChamberNum(cr)-1],0))) 636 722 { 637 723 cr.data->lifeparams->chamber_growth = int(secToSimSteps(ExpProperties.chamberGrowthSec)); … … 765 851 { 766 852 reprocounter = 0; 767 reproduce_parents(0); 768 reproduce_parents(1); 853 for (var s = 0; s < species_genes.size; s++) 854 { 855 reproduce_parents(s); 856 } 857 769 858 } 770 859 … … 849 938 } 850 939 940 function createLogVector(cr, value) 941 { 942 var vec = Vector.new(); 943 for (var i = 0; i < species_genes.size; i++) 944 { 945 for (var j = 0; j < 2; j++) 946 { 947 vec.add(0); 948 } 949 if (cr.data->lifeparams->species == i) 950 { 951 vec[i*2+cr.data->lifeparams->gen] = value; 952 } 953 } 954 return vec; 955 } 956 957 851 958 // -------------------------------- step end -------------------------------- 852 959 //TODO default params values in frams instead of microns/seconds … … 866 973 name:Maximum number of steps 867 974 type:d 0 10000000 0 975 group: 976 977 property: 978 id:scalingFactor 979 name:Scaling factor for micrometers 980 type:f 0 -1 0.01 868 981 group: 869 982 … … 926 1039 property: 927 1040 id:min_repro_energ_haplo 928 name:Min reproduction energy of haploid 929 type:f 0 -1 41041 name:Min reproduction energy of haploid in pg 1042 type:f 0 -1 350000 930 1043 group:Energy 931 1044 932 1045 property: 933 1046 id:min_repro_energ_diplo 934 name:Min reproduction energy of diploid 935 type:f 0 -1 6 1047 name:Min reproduction energy of diploid in pg 1048 type:f 0 -1 600000 936 1049 group:Energy 937 1050 … … 955 1068 956 1069 property: 1070 id:max_chamber_num_haplo 1071 name:Maximum number of haploid chambers 1072 type:f 1 50 35 1073 group:Energy 1074 1075 property: 1076 id:max_chamber_num_diplo 1077 name:Maximum number of diploid chambers 1078 type:f 1 50 35 1079 group:Energy 1080 1081 1082 property: 957 1083 id:crossprob 958 1084 name:Crossover probability … … 975 1101 id:chamberGrowthSec 976 1102 name:Time of the chamber growth in seconds 977 type:f 360 1440 7201103 type:f 720 43200 43200 978 1104 group:Foraminifera 979 1105 … … 988 1114 name:Size of proculus 989 1115 type:f 990 group:Foraminifera991 992 property:993 id:chamber_difference_haplo994 name:Difference in size between subsequent chambers995 type:f 0 -1 0996 group:Foraminifera997 998 property:999 id:chamber_difference_diplo1000 name:Difference in size between subsequent chambers1001 type:f 0 -1 0.081002 1116 group:Foraminifera 1003 1117 -
experiments/frams/foraminifera/data/scripts/foraminifera.inc
r561 r567 17 17 size=size*(1.35-0.35*lastchambergrowth); //last iteration: 'size' is only used for shifting (dx). The last chamber emerges at the surface of the previous one 18 18 } 19 str +="p:sh=1,sx=%g,sy=%g,sz=%g,vr=%s\n" % effectivesize % effectivesize % effectivesize % rgbstring;19 str += "p:sh=1,sx=%g,sy=%g,sz=%g,rz=3.14159265358979,vr=%s\n" % effectivesize % effectivesize % effectivesize % rgbstring; 20 20 if (i>0) 21 str+="j:%d,%d,sh=1,dx=%g,r y=%g\n" % (i-1) % i % (size*shift) % (angle_delta+i*angle_delta_delta);21 str+="j:%d,%d,sh=1,dx=%g,rz=%g\n" % (i-1) % i % (size*shift) % (angle_delta+i*angle_delta_delta); 22 22 size*=growing; 23 23 } 24 24 return str; 25 }26 27 function init_chambers()28 {29 colors = ["1.0,1.0,0.0","1.0,0.5,0.0"];30 retColors = ["1.0,1.0,1.0", "1.0,1.0,0.0"];31 chambers = [ ["p:sh=1, sx=0.2, sy=0.2, sz=0.2, rz=3.14159265358979,",32 "p:0.18421219587326, 0.13, sh=1, sx=0.21, sy=0.21, sz=0.21,",33 "p:0.323935478925705, 0.195192575454712, -0.0246672090142965, sh=1, sx=0.2205, sy=0.2205, sz=0.2205,",34 "p:0.467822402715683, 0.258204102516174, -0.0246672090142965, sh=1, sx=0.231525, sy=0.231525, sz=0.231525,",35 "p:0.664101362228394, 0.309014827013016, -0.0246672090142965, sh=1, sx=0.24310125, sy=0.24310125, sz=0.24310125,",36 "p:0.860512733459473, 0.274790525436401, -0.0246672090142965, sh=1, sx=0.2552563125, sy=0.2552563125, sz=0.2552563125,",37 "p:1.0273220539093, 0.1655353307724, -0.0246672090142965, sh=1, sx=0.268019128125, sy=0.268019128125, sz=0.268019128125,",38 "p:1.13825333118439, -0.000509921927005053, -0.0246672090142965, sh=1, sx=0.28142008453125, sy=0.28142008453125, sz=0.28142008453125,",39 "p:1.17569863796234, -0.196833491325378, -0.0246672090142965, sh=1, sx=0.295491088757813, sy=0.295491088757813, sz=0.295491088757813,",40 "p:1.13369226455688, -0.392314255237579, -0.0246672090142965, sh=1, sx=0.310265643195703, sy=0.310265643195703, sz=0.310265643195703,"],41 ["p:sh=1, sx=0.1, sy=0.1, sz=0.1, rz=3.14159265358979,",42 "p:0.110527315735817, -0.0167302016913891, sh=1, sx=0.105, sy=0.105, sz=0.105, rx=3.63519277003091e-33,",43 "p:0.207026958465576, -0.080698736011982, 1.17627548103266e-17, sh=1, sx=0.11025, sy=0.11025, sz=0.11025,",44 "p:0.271191358566284, -0.169948443770409, 1.17627548103266e-17, sh=1, sx=0.1157625, sy=0.1157625, sz=0.1157625,",45 "p:0.291628688573837, -0.286643952131271, 1.17627548103266e-17, sh=1, sx=0.121550625, sy=0.121550625, sz=0.121550625,",46 "p:0.264833927154541, -0.403534322977066, 1.17627548103266e-17, sh=1, sx=0.12762815625, sy=0.12762815625, sz=0.12762815625,",47 "p:0.194418027997017, -0.500668346881866, 1.17627548103266e-17, sh=1, sx=0.1340095640625, sy=0.1340095640625, sz=0.1340095640625,",48 "p:0.091719962656498, -0.562735974788666, 1.17627548103266e-17, sh=1, sx=0.140710042265625, sy=0.140710042265625, sz=0.140710042265625,",49 "p:-0.0270438715815544, -0.57991486787796, 1.17627548103266e-17, sh=1, sx=0.147745544378906, sy=0.147745544378906, sz=0.147745544378906,",50 "p:-0.143122747540474, -0.549489378929138, 1.17627548103266e-17, sh=1, sx=0.155132821597852, sy=0.155132821597852, sz=0.155132821597852,"]];51 }52 53 function createForamMorphology(morphotype, gen, chamber_num)54 {55 var geno = "//0\nm:Vstyle=foram\n" + chambers[morphotype][0] + "vr=" + colors[gen];56 57 chamber_num = Math.min(chamber_num, chambers[morphotype].size - 1);58 59 for (var i = 0; i < chamber_num; i++)60 {61 geno += "\n" + chambers[morphotype][i+1] + "vr=" + colors[gen];62 }63 64 for (var i = 0; i < chamber_num; i++)65 {66 geno += "\n" + "j:"+ i +", "+ (i+1) +", sh=1";67 }68 69 return geno;70 25 } 71 26 … … 80 35 else if (mode->opt == "birth") 81 36 { 37 foram_uid += 1; 38 var new_id = "c"+string(foram_uid); 82 39 mode->cr.data->genes = String.deserialize(String.serialize(mode->genes)); 83 mode->cr.data->lifeparams = {"max_energy_level" : mode->energy0, "gen" : mode->gen, "hibernated" : 0, "species" : mode->species, "reproduce" : 0, "dir" : randomDir(), "dir_counter" : Math.random(int(secToSimSteps(ExpProperties.dir_change_sec))), "chamber_growth" : -1, "division_time" : -1}; 84 85 } 40 mode->cr.data->lifeparams = {"max_energy_level" : mode->energy0, "gen" : mode->gen, "hibernated" : 0, "species" : mode->species, "reproduce" : 0, "dir" : randomDir(), "dir_counter" : Math.random(int(secToSimSteps(ExpProperties.dir_change_sec))), "chamber_growth" : -1, "division_time" : -1, "uid" : new_id}; 41 42 var oper = "cloning"; 43 if (mode->parentsuids.size > 1) 44 { 45 oper = "cross-over"; 46 } 47 48 var dict={"Time":Simulator.stepNumber,"FromIDs":mode->parentsuids,"ID":new_id, "Inherited":[1.0], "Operation": oper, "Kind" : mode->gen}; 49 Simulator.print("[OFFSPRING] " + String.serialize(dict)); 50 } 51 } 52 53 function getEnergy0(radius) 54 { 55 return energyFromVolume(micronsToFrams(radius),1); 86 56 } 87 57 … … 93 63 { 94 64 result = (result-ExpProperties.divisionCost)/2; 95 number *= 2; 65 number *= 2; 96 66 } 97 67 //Simulator.print("parent: " + parent_energy + " result: " + result + " number " + number); 98 68 return {"energy" : result, "number" : number}; 99 }100 101 function getEnergy0(radius)102 {103 return energyFromVolume(micronsToFrams(radius),1);104 69 } 105 70 … … 135 100 } 136 101 137 Simulator.print("haploid number of offspring: " + number + " energ0: " + energy0);102 //Simulator.print("haploid number of offspring: " + number + " energ0: " + energy0); 138 103 139 104 for (var j = 0; j < number; j++) 140 105 { 141 createOffspring(create ForamMorphology(gen, gen, 0), energy0, new_genes, parent.data->lifeparams);106 createOffspring(create_genotype(ExpProperties.chamber_proculus_diplo, 1, colors[1], 1), energy0, new_genes, parent.data->lifeparams, [parent.data->lifeparams->uid, parent2.data->lifeparams->uid]); 142 107 } 143 108 } … … 156 121 } 157 122 158 Simulator.print("diploid number of offspring: " + number+ " energ0: " + energy0);123 //Simulator.print("diploid number of offspring: " + number+ " energ0: " + energy0); 159 124 160 125 for (var j = 0; j < number / 2; j++) … … 170 135 for (var k = 0; k < 2; k++) 171 136 { 172 createOffspring(create ForamMorphology(1 - parent.data->lifeparams->gen, 1 - parent.data->lifeparams->gen, 0), energy0, parent.data->genes[0], parent.data->lifeparams);137 createOffspring(create_genotype(ExpProperties.chamber_proculus_haplo, 1, colors[0], 1), energy0, parent.data->genes[0], parent.data->lifeparams, [parent.data->lifeparams->uid]); 173 138 } 174 139 … … 220 185 { 221 186 reproduce_haploid(parent1, parent2, 0); 222 print_repro_info(parent1);223 print_repro_info(parent2);187 //print_repro_info(parent1); 188 //print_repro_info(parent2); 224 189 pop.kill(parent1); 225 190 pop.kill(parent2); … … 235 200 { 236 201 var reproduced = 1; 237 238 202 239 203 if (cr.data->lifeparams->gen == 1) 240 204 { … … 260 224 if (reproduced == 1) 261 225 { 262 print_repro_info(cr);226 //print_repro_info(cr); 263 227 Populations[0].kill(cr); 264 228 } … … 267 231 } 268 232 269 function print_repro_info(cr)270 {271 Simulator.print("Reproduced " + cr.data->lifeparams->gen + " of species " + cr.data->lifeparams->species + " energy: " + cr.energy);272 }273 274 233 function foramReproduce(cr) 275 234 { 276 var properEnergy = cr.energy >= energyFromVolume(max_chamber_volume[cr.data->lifeparams->gen][getGene(cr, "min_repro_energies",0)[cr.data->lifeparams->gen]],0);235 var properEnergy = cr.energy >= getGene(cr, "min_repro_energies",0)[cr.data->lifeparams->gen]; 277 236 var reproduced = 0; 278 237 … … 309 268 } 310 269 311 function createOffspring(geno, energy, parent_genes, parent_lifeparams )270 function createOffspring(geno, energy, parent_genes, parent_lifeparams, parentsuids) 312 271 { 313 272 curColor = retColors[1-parent_lifeparams->gen]; … … 315 274 cr.energy0 = energy; 316 275 cr.energy = cr.energy0; 317 setGenotype({"opt" : "birth", "cr" : cr, "gen" : 1 - parent_lifeparams->gen, "species" : parent_lifeparams->species, "energy0" : cr.energy0, "genes" : parent_genes });276 setGenotype({"opt" : "birth", "cr" : cr, "gen" : 1 - parent_lifeparams->gen, "species" : parent_lifeparams->species, "energy0" : cr.energy0, "genes" : parent_genes, "parentsuids" : parentsuids}); 318 277 placeRandomlyNotColliding(cr); 319 278 } 279 280 function print_repro_info(cr) 281 { 282 Simulator.print("Reproduced " + cr.data->lifeparams->gen + " of species " + cr.data->lifeparams->species + " energy: " + cr.energy); 283 } -
experiments/frams/foraminifera/data/scripts/foraminifera.show
r503 r567 18 18 function onLoad() 19 19 { 20 Params = { "foodperiod" : [43200,25920,10800], "feedtrans" : [0.0005,0.001,0.002],"energy_nut" :[144.54,544.54,944.54], "stress" : [0,1], "visualize" : [0,1]}; 21 ShowProperties.visualize=1; 20 22 Simulator.init(); 21 23 last_simspeed=0; … … 23 25 GLDisplay.minfps = 10; 24 26 TrackingCam.cam_h = 15; //more side view 25 Params = { "foodperiod" : [43200,25920,10800], "feedtrans" : [0.0005,0.001,0.002],"energy_nut" :[144.54,544.54,944.54], "stress" : [0,1], "visualize" : [0,1]};26 ShowProperties.visualize=1;27 27 28 28 //useful for screenshots:
Note: See TracChangeset
for help on using the changeset viewer.