Commit ce79782b authored by alaskalinuxuser's avatar alaskalinuxuser
Browse files

Evaluation in action, 1 ply.

parent 52d99e1a
......@@ -1648,7 +1648,9 @@ string Moves::bestMove(string boardPositions, bool whoseTurn, bool styleRandom,
} else {
// Not random, so make educated moves.
currentEval = evaluations.getEval(boardPositions);
cout << "Current eval: " << " time " << (int)time(0) << " eval "<< currentEval << endl;
int moveEval = 0;
int bestEval = currentEval;
for (int a = 0; a < 4; a++) {
chosenMove += candidateList[(0)+a];
}
......@@ -1659,23 +1661,34 @@ string Moves::bestMove(string boardPositions, bool whoseTurn, bool styleRandom,
}
int first =((proposedMove.at(0) - 'a' + 1) + (((proposedMove.at(1) - '1') * 8) - 1));
int second =((proposedMove.at(2) - 'a' + 1) + (((proposedMove.at(3) - '1') * 8) - 1));
char pieceHolder = boardPositions[first];
char firstPieceHolder = boardPositions[first];
char secondPieceHolder = boardPositions[second];
boardPositions[second] = boardPositions[first];
boardPositions[first] = '-';
moveEval = evaluations.getEval(boardPositions);
cout << "Move eval: " << chosenMove << " " << moveEval << endl;
cout << "Move eval: " << chosenMove << " eval " << moveEval << " places " << boardPositions << endl;
plyMoves--;
if (whoseTurn){
// White's turn, higher is better.
if ( moveEval > currentEval ) {
chosenMove = proposedMove;}
if ( moveEval > bestEval ) {
chosenMove = proposedMove;
bestEval = moveEval;
} else if ( moveEval == bestEval && (int)time(0)%2 == 0) {
chosenMove = proposedMove;
bestEval = moveEval;
}
} else {
// Black's turn, lower is better.
if ( moveEval < currentEval ) {
chosenMove = proposedMove;}
if ( moveEval < bestEval ) {
chosenMove = proposedMove;
bestEval = moveEval;
} else if ( moveEval == bestEval && (int)time(0)%2 == 0) {
chosenMove = proposedMove;
bestEval = moveEval;
}
}
boardPositions[first] = boardPositions[second];
boardPositions[first] = pieceHolder;
boardPositions[first] = firstPieceHolder;
boardPositions[second] = secondPieceHolder;
} // End candidate list moves.
}// End not random.
}// End candidates list.
......
No preview for this file type
No preview for this file type
No preview for this file type
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment