Commit 52d99e1a authored by AlaskaLinuxUser's avatar AlaskaLinuxUser

Make a semi-educated decision.

parent 00502a12
......@@ -73,7 +73,7 @@ void inputGo()
{
cout << "Going...." << endl;
engineMove = "";
engineMove = movePick.bestMove(board.moveBoard(), board.getTurn(), styleRandom, board.getIsPassent(), board.getEnPassent());
engineMove = movePick.bestMove(board.moveBoard(), board.getTurn(), styleRandom, board.getIsPassent(), board.getEnPassent(), 1);
cout << "bestmove " + engineMove << endl;
}
void inputQuit()
......
......@@ -1633,7 +1633,7 @@ string Moves::available(string boardPositions, bool whoseTurn, bool isPass, char
*/
}
string Moves::bestMove(string boardPositions, bool whoseTurn, bool styleRandom, bool isPass, char enPass){
string Moves::bestMove(string boardPositions, bool whoseTurn, bool styleRandom, bool isPass, char enPass, int plyMoves){
string candidateList = Moves::available(boardPositions, whoseTurn, isPass, enPass);
string chosenMove = "";
int currentEval = 0;
......@@ -1652,14 +1652,32 @@ string Moves::bestMove(string boardPositions, bool whoseTurn, bool styleRandom,
for (int a = 0; a < 4; a++) {
chosenMove += candidateList[(0)+a];
}
cout << "Eval: " << chosenMove << " " << currentEval << endl;
for (int e = 0; unsigned(e) < (candidateList.size()/5); e++){
moveEval++;
//cout << "Eval: " << chosenMove << " " << currentEval << endl;
string proposedMove = "";
for (int a = 0; a < 4; a++) {
proposedMove += candidateList[(5*e)+a];
}
}// End not random.
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];
boardPositions[second] = boardPositions[first];
boardPositions[first] = '-';
moveEval = evaluations.getEval(boardPositions);
cout << "Move eval: " << chosenMove << " " << moveEval << endl;
plyMoves--;
if (whoseTurn){
// White's turn, higher is better.
if ( moveEval > currentEval ) {
chosenMove = proposedMove;}
} else {
// Black's turn, lower is better.
if ( moveEval < currentEval ) {
chosenMove = proposedMove;}
}
boardPositions[first] = boardPositions[second];
boardPositions[first] = pieceHolder;
} // End candidate list moves.
}// End not random.
}// End candidates list.
return chosenMove;
}
......@@ -29,7 +29,7 @@ public:
string available(string boardPositions, bool whoseTurn, bool isPass, char enPass);
// Best move.
string bestMove(string boardPositions, bool whoseTurn, bool styleRandom, bool isPass, char enPass);
string bestMove(string boardPositions, bool whoseTurn, bool styleRandom, bool isPass, char enPass, int plyMoves);
// Is the king safe?
bool isKingSafe(string boardPositions, bool whoseTurn);
......
No preview for this file type
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