Skip to content

Commit

Permalink
Prints out heuristics values for winner
Browse files Browse the repository at this point in the history
  • Loading branch information
mbluemer committed May 2, 2017
1 parent 69f5bc8 commit abcb2cb
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions include/Heuristic.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class Heuristic
public:
void set(int index, int value) { coeff[index] = value; };
int evaluate(bup &bitboard);
std::string coefficientsToString();

// Needed public for variable depth search
int jumpeablePieces() const;
Expand Down
9 changes: 9 additions & 0 deletions src/GeneticSimulation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,15 @@ void GeneticSimulation::simulate(){
s << "White Wins(after Tie): " << cntTieBlack << std::endl;
s << "Black Wins(after Tie): " << cntTieWhite << std::endl;
s << "Ties: \t\t" << cntTies << std::endl;
int n = population.size();
for (int i = 0; i < n; ++i) {
Specimen temp = population.front();
s << "+++++++++++++++++++++++++++++++" << std::endl;
s << "START: " << std::endl;
s << temp.getStartHeuristics().coefficientsToString();
s << "END: " << std::endl;
s << temp.getEndHeuristics().coefficientsToString();
}
}
s.close();

Expand Down
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 abcb2cb

Please sign in to comment.