Skip to content

Commit

Permalink
Changed output
Browse files Browse the repository at this point in the history
  • Loading branch information
dmj12004 committed May 1, 2017
1 parent 4f8fc70 commit ea450c3
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions src/GeneticSimulation.cpp
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
#include <fstream>
#include <iostream>

#include <thread>
#include "GeneticSimulation.hpp"
#include "Game.hpp"
#include "Specimen.hpp"

void GeneticSimulation::simulate(){

std::cout << dist(gen) << std::endl;


for(int i = 0; i < numSpecimen; i++){

Heuristic h1, h2;
for(int j = 0; j < Heuristic::numFeatures; j++){
h1.set(j, dist(gen));
Expand All @@ -26,17 +22,19 @@ void GeneticSimulation::simulate(){
int cntBlack=0, cntWhite=0, cntTies=0;
int cntTieBlack=0, cntTieWhite=0;

while(population.size() > 1){
while(population.size() > numSpecimen/5){
Specimen a = population.front();
population.pop();
Specimen b = population.front();
population.pop();


Game game1(a, b);
Game game2(b, a);

int winner = 0;
game1.play(&winner);

std::thread t1(game1.play,&winner);

if(winner == 0){
game2.play(&winner);
Expand All @@ -56,7 +54,7 @@ void GeneticSimulation::simulate(){
cntBlack++;
}
else if(winner == 2){
population.push(a);
population.push(b);
cntWhite++;
}
else cntTies++;
Expand Down

0 comments on commit ea450c3

Please sign in to comment.