Changeset 554


Ignore:
Timestamp:
07/31/16 23:26:43 (8 years ago)
Author:
oriona
Message:

Refactoring, change of foraminifera direction at world boundary added.

Location:
experiments/frams/foraminifera/data/scripts
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • experiments/frams/foraminifera/data/scripts/foraminifera.expdef

    r553 r554  
    8585        World.wrldsiz = micronsToFrams(100000);
    8686        World.wrldbnd = 1;
    87         ExpProperties.stress = 1;
    88         ExpProperties.creath = -0.99; //just above the bottom
    89         ExpProperties.autorestart = 0;
    90 
    91         //time
    92         ExpProperties.secPerStep = 300;
    93         ExpProperties.foramSpeedMmPerMin = 0.05;
     87
    9488        movePerStep = getMovePerStep();
    9589
     
    9993        ExpProperties.logPref = "";
    10094
    101         //reproduction
    102         ExpProperties.foramPop = 20;   
    103         ExpProperties.crossprob = 0;
    104         ExpProperties.mutationprob = 0;
    105         ExpProperties.repro_time = 720;
    106         ExpProperties.gametoPeriod = 21600;
    107         ExpProperties.divisionCost = 20;
    108         reprocounter = 0;
    109 
    11095        species_genes = [];
    11196
     97        //morphology
    11298        init_chambers();
    113 
    11499        curColor = retColors[0];
    115         //morphology
    116         ExpProperties.dir_change_sec = 30000;
    117100        ExpProperties.zone1_range = micronsToFrams(1000);
    118101        ExpProperties.zone2_range = micronsToFrams(3000);
    119         ExpProperties.chamber_growth_time = 720;
    120         ExpProperties.chamberCostPerSec = 0.000001;
    121102        ExpProperties.chamber_proculus_haplo = micronsToFrams(50);
    122103        ExpProperties.chamber_difference_haplo = 0.0;
     
    133114        }
    134115
    135         //energetics
    136         ExpProperties.min_repro_energ_haplo = 4;
    137         ExpProperties.min_repro_energ_diplo = 6;
    138 
    139         ExpProperties.e_meta = 0.0000005;
    140         ExpProperties.energy_hib = 0.0000001;
    141         ExpProperties.energy_move = 0.0000005;
    142 
    143         ExpProperties.energies0_haplo = 20;
    144         ExpProperties.energies0_diplo = 1.25;
    145         ExpProperties.feedtrans = 0.001;
    146         ExpProperties.e_repro_cost_haplo = 0.3;
    147         ExpProperties.e_repro_cost_diplo = 0.2;
    148 
    149         ExpProperties.e_death_level_haplo = 0.5;
    150         ExpProperties.e_death_level_diplo = 0.5;
    151 
    152116        //nutrients
    153         changePeriod = 0;
    154         phase = "low";
    155         nutrientSqrCm = 10;
    156         ExpProperties.foodperiod = 14400;
    157         ExpProperties.foodPeriodChange = 0;
    158117        ExpProperties.nutrientradius = micronsToFrams(10);
    159118        ExpProperties.energy_nut = 200 * energyFromVolume(ExpProperties.nutrientradius,1);
     119        nutrientSqrCm = 10;
    160120        ExpProperties.nutrient_pop = Math.pow(framsToMicrons(World.wrldsiz)*0.0001,2)/nutrientSqrCm;
    161         ExpProperties.ingestion = 0.25;
    162         nutrientenergywaiting = 0;
     121
    163122        ExpState.totaltestedcr = 0;
    164123        ExpState.nutrient = "";
     
    169128
    170129@include "standard_placement.inc"
     130
     131function secToSimSteps(value_in_sec){
     132        return value_in_sec/ExpProperties.secPerStep;
     133}
    171134
    172135function volumeInMicrons(radiusInFrams)
     
    226189        cr.energy0 = energyFromVolume(max_chamber_volume[ploid][chambernum],0);
    227190        cr.energy = cr.energy0;
    228         setGenotype({"opt" : 0, "cr" : cr, "species" : species, "energy0" : cr.energy0, "genes" : species_genes[species]});
     191        setGenotype({"opt" : "birth", "cr" : cr, "gen" : ploid, "species" : species, "energy0" : cr.energy0, "genes" : species_genes[species]});
    229192        if (ploid == 1)
    230193        {
    231                 cr.data->lifeparams->gen = 1;
    232194                cr.data->genes = [cr.data->genes, cr.data->genes]; //TODO two different genes sets
    233195        }
     
    277239        o = Populations[0][0].getMechPart(0).orient.clone();
    278240        ExpState.totaltestedcr = 0;
     241
     242        reprocounter = 0;
     243        nutrientenergywaiting = 0;
     244        changePeriod = 0;
     245        phase = "low";
    279246}
    280247
     
    411378                cr2.energy = cr2.energy0;
    412379
    413                 setGenotype({"cr" : cr2, "parent_genes" : cr.data->genes, "parent_lifeparams" : cr.data->lifeparams, "opt" : 2, "energy0" : cr.energy0});
     380                setGenotype({"cr" : cr2, "parent_genes" : cr.data->genes, "parent_lifeparams" : cr.data->lifeparams, "opt" : "growth", "energy0" : cr.energy0});
    414381                cr2.moveAbs(cr.center_x - cr2.size_x / 2, cr.center_y - cr2.size_y / 2, cr.pos_z);
    415382                setForamMeta(cr2);
     
    496463
    497464        //adjustment in z axis
    498         cr.moveAbs(fence(cr.pos_x, getZoneRange(cr, 1)), fence(cr.pos_y,getZoneRange(cr, 1)), 0);
     465        var change_direction = 0;
     466        var new_x = fence(cr.pos_x, getZoneRange(cr, 1));
     467        var new_y = fence(cr.pos_y,getZoneRange(cr, 1));
     468
     469        if ((new_x != cr.pos_x) || (new_y != cr.pos_y) || (cr.data->lifeparams->dir_counter >= int(secToSimSteps(ExpProperties.dir_change_sec))))
     470        {
     471                change_direction = 1;
     472        }
     473
     474        cr.moveAbs(new_x, new_y, 0);
    499475
    500476        //are there any nutrients in zone 1 or 2?
     
    515491        }
    516492        //random move
    517         else if (cr.data->lifeparams->dir_counter >= int(ExpProperties.dir_change_sec/ExpProperties.secPerStep))
     493        else if (change_direction == 1)
    518494        {
    519495                cr.data->lifeparams->dir = randomDir();
     
    656632                        if ((cr.data->lifeparams->max_energy_level >= energyFromVolume(max_chamber_volume[cr.data->lifeparams->gen][lastChamberNum(cr)],0)))   
    657633                        {
    658                                 cr.data->lifeparams->chamber_growth = int(ExpProperties.chamber_growth_time/ExpProperties.secPerStep);
     634                                cr.data->lifeparams->chamber_growth = int(secToSimSteps(ExpProperties.chamberGrowthSec));
    659635                        }       
    660636                }
     
    716692        {
    717693                var nutsize = ExpProperties.nutrientradius*10;
    718                 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");
     694                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");
    719695                cr.data->reticulopodiacreature = nut;
    720696                nut.moveAbs(cr.pos_x-1.5*nutsize, cr.pos_y-1.5*nutsize, 0.5);
     
    735711        {
    736712                        changePeriod += 1;
    737                         if (phase=="low" && (changePeriod*ExpProperties.secPerStep) >= 23328000) //9 months
     713                        if (phase=="low" && changePeriod >= secToSimSteps(23328000)) //9 months
    738714                        {
    739715                                ExpProperties.foodperiod = ExpProperties.foodperiod/ExpProperties.foodPeriodChange;
     
    742718                        }
    743719               
    744                         else if (phase == "high" && (changePeriod*ExpProperties.secPerStep) >= 7776000) //3 months
     720                        else if (phase == "high" && changePeriod >= secToSimSteps(7776000)) //3 months
    745721                        {
    746722                                ExpProperties.foodperiod = ExpProperties.foodperiod*ExpProperties.foodPeriodChange;
     
    750726        }
    751727        nutrientenergywaiting = nutrientenergywaiting + 1;
    752         if (nutrientenergywaiting*ExpProperties.secPerStep >= ExpProperties.foodperiod)
     728        if (nutrientenergywaiting >= secToSimSteps(ExpProperties.foodperiod))
    753729        {
    754730                for (var i = 0; i < ExpProperties.nutrient_pop; i++)
     
    783759        //reproduction --------------------------------------------
    784760        reprocounter += 1;
    785         if (reprocounter*ExpProperties.secPerStep > ExpProperties.repro_time)
     761        if (reprocounter > secToSimSteps(ExpProperties.reproTimeSec))
    786762        {
    787763                reprocounter = 0;
     
    881857name:Show reticulopodia and nutrients
    882858type:d 0 1 0
    883 group:Foraminifera
     859group:
    884860
    885861property:
    886862id:maxSteps
    887 name:Stop after the given number of simulation steps
     863name:Maximum number of steps
    888864type:d 0 10000000 0
     865group:
     866
     867property:
     868id:logging
     869name:Log statistics to file
     870type:d 0 1 0
     871group:
    889872
    890873property:
     
    894877
    895878property:
    896 id:foramSpeedMmPerMin
    897 name:Speed of foraminfera in mm/min
    898 type:f 0.1
    899 flags: 16
    900 group:Foraminifera
    901 
    902 property:
    903 id:gametSuccessRate
    904 name:Ratio of successful gamets
    905 type:f 0.001
    906 group:Foraminifera
    907 
    908 property:
    909 id:dir_change_sec
    910 name:Number of seconds before direction change
    911 type:d 30000
    912 group:Foraminifera
    913 
    914 property:
    915 id:gametoPeriod
    916 name:Time of gametogenesis
    917 type:f 720
    918 group:Foraminifera
    919 
    920 property:
    921 id:picoCarbonPerMikro
    922 name:Picograms of carbon in cubed micrometer
    923 type:f 0.13
    924 group:Foraminifera
    925 
    926 property:
    927879id:secPerStep
    928880name:Seconds per simulation step
    929881help:Number of seconds of foraminifera time per simulation step
    930 type:f 60.0
     882type:f 1 480 300
     883flags: 16
     884group:
     885
     886property:
     887id:foramSpeedMmPerMin
     888name:Speed of foraminfera in mm/min
     889type:f 0.01 0.1 0.05
    931890flags: 16
    932891group:Foraminifera
    933892
    934893property:
    935 id:e_repro_cost_haplo
    936 name:Cost of reproduction
    937 type:f 0.1 0.9 0.5
     894id:dir_change_sec
     895name:Number of seconds before direction change
     896type:d 300 300000 6000
    938897group:Foraminifera
     898
     899property:
     900id:foramPop
     901name:Initial forams population size
     902type:d 1 1000 20
     903group:Foraminifera
     904
     905property:
     906id:gametoPeriodSec
     907name:Time of gametogenesis
     908type:f 300 300000 21600
     909group:Reproduction
     910
     911property:
     912id:gametSuccessRate
     913name:Ratio of successful gamets
     914type:f 0.0001 0.01 0.001
     915group:Reproduction
    939916
    940917property:
    941918id:divisionCost
    942919name:Cost of division in pG
    943 type:f
    944 group:Foraminifera
    945 
    946 property:
    947 id:e_repro_cost_diplo
    948 name:Cost of reproduction
    949 type:f 0.1 0.9 0.3
    950 group:Foraminifera
    951 
    952 property:
    953 id:chamber_growth_time
     920type:f 15 25 20
     921group:Reproduction
     922
     923property:
     924id:min_repro_energ_haplo
     925name:Min reproduction energy of haploid
     926type:f 0 -1 4
     927group:Energy
     928
     929property:
     930id:min_repro_energ_diplo
     931name:Min reproduction energy of diploid
     932type:f 0 -1 6
     933group:Energy
     934
     935property:
     936id:repro_prob
     937name:Probability of reproduction
     938type:f 0 1 0.8
     939group:Reproduction
     940
     941property:
     942id:energies0_haplo
     943name:Energy of offspring from diploid forams
     944type:f 0 -1 20
     945group:Energy
     946
     947property:
     948id:energies0_diplo
     949name:Energy of offspring from diploid forams
     950type:f 0 -1 1.25
     951group:Energy
     952
     953property:
     954id:crossprob
     955name:Crossover probability
     956type:f 0 1 0
     957group:Reproduction
     958
     959property:
     960id:mutationprob
     961name:Mutation probability
     962type:f 0 1 0
     963group:Reproduction
     964
     965property:
     966id:reproTimeSec
     967name:Time before reproduction
     968type:d 0 10000 720
     969group:Reproduction
     970
     971property:
     972id:chamberGrowthSec
    954973name:Time of the chamber growth in seconds
    955 type:f
    956 group:Foraminifera
    957 
    958 property:
    959 id:chamberCostPerSec
    960 name:Cost of growning chamber per second
    961 type:f
     974type:f 360 1440 720
    962975group:Foraminifera
    963976
     
    977990id:chamber_difference_haplo
    978991name:Difference in size between subsequent chambers
    979 type:f
     992type:f 0 -1 0
    980993group:Foraminifera
    981994
     
    983996id:chamber_difference_diplo
    984997name:Difference in size between subsequent chambers
    985 type:f
     998type:f 0 -1 0.08
    986999group:Foraminifera
    9871000
     
    9901003name:Probability of being hunted
    9911004type:f 0 1 0
    992 group:Forminifera
     1005group:Foraminifera
    9931006
    9941007property:
    9951008id:zone1_range
    9961009name:Zone 1 range
    997 type:f 0 200
     1010type:f 0 200 10
    9981011group:Foraminifera
    9991012
     
    10011014id:zone2_range
    10021015name:Zone 2 range
    1003 type:f 0 3000
     1016type:f 0 3000 30
    10041017group:Foraminifera
    10051018
    10061019property:
    1007 id:colors
    1008 name:Haploid and diploid colors
    1009 type:x
    1010 group:Foraminifera
    1011 
    1012 property:
    1013 id:min_repro_energ_haplo
    1014 name:Min reproduction energy of forams
    1015 type:f
    1016 group:Foraminifera
    1017 
    1018 property:
    1019 id:min_repro_energ_diplo
    1020 name:Min reproduction energy of forams
    1021 type:f
    1022 group:Foraminifera
    1023 
    1024 property:
    1025 id:repro_prob
    1026 name:Probability of reproduction
    1027 type:f 0 1 0.8
    1028 group:Foraminifera
    1029 
    1030 property:
    1031 id:energies0_haplo
    1032 name:Energy of offspring from diploid forams
    1033 type:f
    1034 group:Foraminifera
    1035 
    1036 property:
    1037 id:energies0_diplo
    1038 name:Energy of offspring from diploid forams
    1039 type:f
    1040 group:Foraminifera
     1020id:chamberCostPerSec
     1021name:Cost of growning chamber per second
     1022type:f 0 1 0.000001
     1023group:Energy
    10411024
    10421025property:
    10431026id:e_death_level_haplo
    10441027name:Minimal level of energy to sustain life of haploid
    1045 type:f 0 20 0.2
    1046 group:Foraminifera
     1028type:f 0 1 0.5
     1029group:Energy
    10471030
    10481031property:
    10491032id:e_death_level_diplo
    10501033name:Minimal level of energy to sustain life of diploid
    1051 type:f 0 20 0.2
    1052 group:Foraminifera
     1034type:f 0 1 0.5
     1035group:Energy
    10531036
    10541037property:
    10551038id:energy_hib
    10561039name:Energy used for hibernation during one step
    1057 type:f 0 1 0.001
    1058 group:Foraminifera
     1040type:f 0 1 0.0000001
     1041group:Energy
    10591042
    10601043property:
    10611044id:energy_move
    10621045name:Energy used for movement during one step
    1063 type:f 0 20 0.001
    1064 group:Foraminifera
    1065 
    1066 property:
    1067 id:min_vol
    1068 name:Minimal volume for reproduction
    1069 type:f 100 900 100
    1070 group:Foraminifera
    1071 
    1072 property:
    1073 id:max_size
    1074 name:Maximal size
    1075 type:d 1 10 5
    1076 group:Foraminifera
    1077 
    1078 property:
    1079 id:foramPop
    1080 name:Initial forams population size
    1081 type:d 1 1000 100
    1082 group:Foraminifera
    1083 
    1084 property:
    1085 id:crossprob
    1086 name:Crossover probability
    1087 type:f 0 1 0
    1088 group:Foraminifera
    1089 
    1090 property:
    1091 id:mutationprob
    1092 name:Mutation probability
    1093 type:f 0 1 0
    1094 group:Foraminifera
     1046type:f 0 1 0.0000005
     1047group:Energy
    10951048
    10961049property:
    10971050id:e_meta
    10981051name:Idle metabolism
    1099 type:f 0 1
     1052type:f 0 1 0.0000005
    11001053group:Energy
    11011054help:Each stick consumes this amount of energy in one time step
    1102 
    1103 property:
    1104 id:nutrient_pop
    1105 name:Feeding rate
    1106 type:f 0 1000000
    1107 group:Energy
    1108 help:How fast energy is created in the world
    1109 
    1110 property:
    1111 id:foodPeriodChange
    1112 name:Set variable feed rate
    1113 type:f 0
    1114 group:Energy
    11151055
    11161056property:
    11171057id:ingestion
    11181058name:Ingestion rate
    1119 type:f
    1120 group:Energy
     1059type:f 0 -1 0.25
     1060group:Energy
     1061
     1062property:
     1063id:nutrient_pop
     1064name:Nutrient population
     1065type:f 0 1000000
     1066group:Energy
     1067help:How fast energy is created in the world
    11211068
    11221069property:
     
    11271074
    11281075property:
    1129 id:feedtrans
    1130 name:Energy transfer per second
    1131 type:f 0 100000
    1132 group:Energy
    1133 
    1134 property:
    1135 id:foodperiod
    1136 name:Time between food occurrences
    1137 type:f 0 1000000
    1138 group:Energy
    1139 
    1140 property:
    11411076id:nutrientradius
    11421077name:Nutrient size
     
    11451080
    11461081property:
     1082id:picoCarbonPerMikro
     1083name:Picograms of carbon in cubed micrometer
     1084type:f 0 -1 0.13
     1085group:Energy
     1086
     1087property:
     1088id:feedtrans
     1089name:Energy transfer per second
     1090type:f 0 1 0.001
     1091group:Energy
     1092
     1093property:
     1094id:foodperiod
     1095name:Time between food occurrences
     1096type:f 0 1000000 14400
     1097group:Energy
     1098
     1099property:
     1100id:foodPeriodChange
     1101name:Set variable feed rate
     1102type:f 0 -1 0
     1103group:Energy
     1104
     1105property:
    11471106id:stress
    11481107name:Environmental stress
    11491108type:d 0 1 1
    1150 group:World
     1109group:
    11511110
    11521111property:
     
    11541113name:Reproduction trigger
    11551114type:d 0 1 1
    1156 group:World
    1157 
    1158 property:
    1159 id:repro_time
    1160 name:Time before reproduction
    1161 type:d 0 10000
     1115group:Reproduction
    11621116
    11631117property:
    11641118id:creath
    11651119name:Creation height
    1166 type:f -1 50
     1120type:f -1 50 -0.99
    11671121help:~
    11681122Vertical position (above the surface) where new Forams are revived.
     
    11721126-1   = just above the bottom~
    11731127
     1128property:
     1129id:autorestart
     1130name:Restart after extinction
     1131help:Restart automatically this experiment after the last creature has died?
     1132type:d 0 1 0
     1133
    11741134state:
    11751135id:nutrient
     
    11781138type:x
    11791139flags:32
    1180 
    1181 property:
    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
    11861140
    11871141state:
     
    11991153type:d
    12001154flags:16
    1201 
    1202 property:
    1203 id:logging
    1204 name:Log statistics to file
    1205 type:d 0 1 0
  • experiments/frams/foraminifera/data/scripts/foraminifera.inc

    r552 r554  
    3030function createForamMorphology(morphotype, gen, chamber_num)
    3131{
    32         var rad = getProperty(gen, "chamber_proculus");
    3332        var geno = "//0\nm:Vstyle=foram\n" + chambers[morphotype][0] + "vr=" + colors[gen];
    3433
     
    3736        for (var i = 0; i < chamber_num; i++)
    3837        {
    39                 //rad = getProperty(gen, "chamber_proculus") + getProperty(gen, "chamber_difference") * (i + 1);
    4038                geno += "\n" + chambers[morphotype][i+1]  + "vr=" +  colors[gen];
    4139        }
     
    4644        }
    4745
    48         //if (morphotype == 0) geno += "\nn:p=0,d=\"S\"";
    4946        return geno;
    5047}
     
    5249function setGenotype(mode)
    5350{
    54         if (mode->opt == 0) //initial
    55         {
    56                 mode->cr.data->genes = String.deserialize(String.serialize(mode->genes));
    57                 mode->cr.data->lifeparams = {"max_energy_level" : mode->energy0, "gen" : 0,  "hibernated" : 0, "species" : mode->species, "reproduce" : 0, "dir" : randomDir(), "dir_counter" : Math.random(ExpProperties.dir_change_sec), "chamber_growth" : -1, "division_time" : -1};
    58         }
    59         else if (mode->opt  == 1) //child
    60         {
    61                 mode->cr.data->lifeparams = {"max_energy_level" : mode->energy0, "gen" : 1 - mode->parent_lifeparams->gen,  "hibernated" : 0, "species" : mode->parent_lifeparams->species, "reproduce" : 0, "dir" : randomDir(), "dir_counter" : Math.random(ExpProperties.dir_change_sec), "chamber_growth" : -1, "division_time" : -1};
    62                 mode->cr.data->genes = String.deserialize(String.serialize(mode->parent_genes));
    63         }
    64         else //grow
     51        if (mode->opt == "growth")
    6552        {
    6653                mode->cr.data->genes = mode->parent_genes;
    6754                mode->cr.data->lifeparams = mode->parent_lifeparams;
     55        }
     56
     57        else if (mode->opt == "birth")
     58        {
     59                mode->cr.data->genes = String.deserialize(String.serialize(mode->genes));
     60                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};                   
     61
    6862        }
    6963}
     
    192186                                        if (parent1.data->lifeparams->division_time == -1 && parent2.data->lifeparams->division_time == -1)
    193187                                        {
    194                                                 var time = int(ExpProperties.gametoPeriod/ExpProperties.secPerStep);
     188                                                var time = int(secToSimSteps(ExpProperties.gametoPeriodSec));
    195189                                                parent1.data->lifeparams->division_time = time;
    196190                                                parent2.data->lifeparams->division_time = time;
     
    298292        cr.energy0 = energy;
    299293        cr.energy = cr.energy0;
    300         setGenotype({"cr" : cr, "parent_genes" : parent_genes, "parent_lifeparams" : parent_lifeparams, "opt" : 1, "energy0" : cr.energy0});
     294        setGenotype({"opt" : "birth", "cr" : cr, "gen" : 1 - parent_lifeparams->gen, "species" : parent_lifeparams->species, "energy0" : cr.energy0, "genes" : parent_genes});
    301295        placeRandomlyNotColliding(cr);
    302296}
Note: See TracChangeset for help on using the changeset viewer.