Commit 38698ec4 authored by AlaskaLinuxUser's avatar AlaskaLinuxUser

picoEngine can choose to castle.

parent 7d267ac1
......@@ -840,6 +840,39 @@ string Moves::bishopMovesB(string boardPositions, int i) {
theseMoves.push_back(i-1);}}
// Need castle moves //
if (theBoard[60] == 'k') {
cout << "The king is on square 60" << endl;
if (theBoard[59] == '-' && theBoard[58] == '-' &&
theBoard[57] == '-' && theBoard[56] == 'r' && m_qcastle == true) {
cout << "Path is clear to castle queenside." << endl;
if (isKingSafe(theBoard, turn)) {
//The king is not in check, so...
theBoard[59] = 'k';
theBoard[60] = '-';
if (isKingSafe(theBoard, turn)) {
//The king is safe in between, so...
theseMoves.push_back(58);
//Then the move will get checked if king is safe at destination.
}
theBoard[60] = 'k';
theBoard[59] = '-';}
} //queenside
if (theBoard[61] == '-' && theBoard[62] == '-' &&
theBoard[63] == 'r' && m_Kcastle == true) {
cout << "Path is clear to castle kingside." << endl;
if (isKingSafe(theBoard, turn)) {
//The king is not in check, so...
theBoard[61] = 'k';
theBoard[60] = '-';
if (isKingSafe(theBoard, turn)) {
//The king is safe in between, so...
theseMoves.push_back(62);
//Then the move will get checked if king is safe at destination.
}
theBoard[60] = 'k';
theBoard[61] = '-';}
} //kingside
} // end castle
for(int l=0; (unsigned)l<theseMoves.size();l++) {
int k = theseMoves[l];
......@@ -1415,6 +1448,39 @@ string Moves::bishopMoves(string boardPositions, int i) {
theseMoves.push_back(i-1);}}
// Need castle moves //
if (theBoard[4] == 'K') {
cout << "The king is on square 4" << endl;
if (theBoard[3] == '-' && theBoard[2] == '-' &&
theBoard[1] == '-' && theBoard[0] == 'R' && m_Qcastle == true) {
cout << "Path is clear to castle queenside." << endl;
if (isKingSafe(theBoard, turn)) {
//The king is not in check, so...
theBoard[3] = 'K';
theBoard[4] = '-';
if (isKingSafe(theBoard, turn)) {
//The king is safe in between, so...
theseMoves.push_back(2);
//Then the move will get checked if king is safe at destination.
}
theBoard[4] = 'K';
theBoard[3] = '-';}
} //queenside
if (theBoard[5] == '-' && theBoard[6] == '-' &&
theBoard[7] == 'R' && m_Kcastle == true) {
cout << "Path is clear to castle kingside." << endl;
if (isKingSafe(theBoard, turn)) {
//The king is not in check, so...
theBoard[5] = 'K';
theBoard[4] = '-';
if (isKingSafe(theBoard, turn)) {
//The king is safe in between, so...
theseMoves.push_back(6);
//Then the move will get checked if king is safe at destination.
}
theBoard[4] = 'K';
theBoard[5] = '-';}
} //kingside
} // end castle
for(int l=0; (unsigned)l<theseMoves.size();l++) {
int k = theseMoves[l];
......
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