Skip to content

Commit

Permalink
merging variable outputs, to screen and to sim_out.txtx
Browse files Browse the repository at this point in the history
  • Loading branch information
dmj12004 committed May 2, 2017
2 parents 82f3a6e + af5822f commit 6fc0724
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
2 changes: 2 additions & 0 deletions include/Heuristic.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ class Heuristic
void set(int index, int value) { coeff[index] = value; };
int evaluate(bup &bitboard);
auto getArray(){ return coeff;};
std::string coefficientsToString();

// Needed public for variable depth search
int jumpeablePieces() const;

Expand Down
12 changes: 12 additions & 0 deletions src/GeneticSimulation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ void GeneticSimulation::simulateRound(int roundNum){
}

}

if(fileOut.is_open()){
fileOut<< "\nRound: " << roundNum << std::endl;
fileOut<< "Size: \t\t" << numSpecimen << std::endl;
Expand All @@ -100,5 +101,16 @@ void GeneticSimulation::simulateRound(int roundNum){
fileOut<< "End popultion size: \t" << population.size() << std::endl;
}

int n = population.size();
for (int i = 0; i < n; ++i) {
Specimen temp = population.front();
population.pop();
s << "+++++++++++++++++++++++++++++++" << std::endl;
s << "START: " << std::endl;
s << temp.getStartHeuristics().coefficientsToString();
s << "END: " << std::endl;
s << temp.getEndHeuristics().coefficientsToString();
}


}
15 changes: 15 additions & 0 deletions src/Heuristic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,21 @@ int Heuristic::moveableKings() const
return (isBlacksTurn ? 1 : -1) * count(accumK);
}

std::string Heuristic::coefficientsToString()
{
return "pawn count: " + std::to_string(coeff[0]) + "\n" +
"king count: " + std::to_string(coeff[1]) + "\n" +
"safe pawns: " + std::to_string(coeff[2]) + "\n" +
"safe kings: " + std::to_string(coeff[3]) + "\n" +
"pawn promotion distance: " + std::to_string(coeff[4]) + "\n" +
"defender count: " + std::to_string(coeff[5]) + "\n" +
"attacker count: " + std::to_string(coeff[6]) + "\n" +
"open promotion count: " + std::to_string(coeff[7]) + "\n" +
"moveable pawns: " + std::to_string(coeff[8]) + "\n" +
"moveable kings: " + std::to_string(coeff[9]) + "\n" +
"jumpeable pieces: " + std::to_string(coeff[10]) + "\n";
}

int Heuristic::jumpeablePieces() const
{
uint32_t accumP = 0;
Expand Down

0 comments on commit 6fc0724

Please sign in to comment.