Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- float runSim(vector<float> cromo)
- {
- nnet.init(16,10,2);
- nnet.setWeights(cromo);
- std::string worldFile = "/home/alex/Stage/worlds/simple.world";
- const int popsize = 1;
- char *ptest[2];
- int ntest = 1;
- ptest[0]="0";
- char **pptest=ptest;
- char ***ppptest = &pptest;
- // initialize libstage
- Stg::Init( &ntest, ppptest );
- float simFitnessTotal = 0;
- //run three trials and get the average fitness
- for (int i=0; i<3; i++)
- {
- Stg::World* world = new Stg::World("Stage Benchmark Program");
- world->Load( worldFile );
- if (world->PastQuitTime())
- {
- cout << "past quit time" << endl;
- }
- // create the logic and connect it to the world
- Logic logic(popsize);
- logic.setnnet(nnet);
- logic.connect(world);
- world->Run();
- simFitnessTotal += logic.trialFitness();
- }
- float finalFitness = simFitnessTotal/3;
- cout << "final fitness: " << finalFitness << endl;
- return finalFitness;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement