source: experiments/frams/evolve-speed-vs-gravity/data/scripts/evolve-speed-vs-gravity.script @ 117

Last change on this file since 117 was 117, checked in by Maciej Komosinski, 8 years ago

sample script that demonstrates how to use Framsticks CLI to run multiple experiments with variable parameters

File size: 1.2 KB
Line 
1script:
2name:Evolve for speed vs gravity
3help:Evolve for speed in different gravity settings
4code:~
5function main(gravity,min_evaluations)
6{
7        Math.randomize();
8        World.wrldg=gravity;
9        Populations[0].perfperiod=100000; //fitness: velocity serves as distance (because sampling period is longer than lifespan)
10        ExpParams.initialgen="XX[|,1:1][N,1:1,2:1][T][G]";
11       
12        Simulator.init();
13        //Simulator.print(GenePools[0][0].genotype); //ensure the initialgen is in the gene pool
14               
15        Simulator.start();
16        while (Simulator.running) Simulator.step(); //runs until the experiment stops by itself
17        var best=GenePools[0].best();
18        Simulator.print("%g (x%g) %s" % best.fit % best.popsiz % best.genotype);
19       
20        ExpParams.stagnation=0; //turn off stagnation detection mechanism
21        ExpParams.p_mut=0; //we don't want evolution and new genotypes anymore. We only want to evaluate existing genotypes multiple times
22        ExpParams.p_xov=0;
23        Simulator.start();
24        while (Simulator.running && best.popsiz<min_evaluations) //repeat until the best genotype will be evaluated at least min_evaluations times
25        {
26                Simulator.step();
27                best=GenePools[0].best();
28        }
29        Simulator.stop();
30        Simulator.print("%g (x%g) %s" % best.fit % best.popsiz % best.genotype);
31}
32~
33
Note: See TracBrowser for help on using the repository browser.