I am done with promotion of pieces.
bool promotion(char CB[9][9], int EC[2], char &turn) //EC-endcoordinate
{
if((CB[EC[0]][EC[1]]=='p','s','n','l') && turn=='b')
return (CB[EC[0]][EC[1]]=='g');
else if((CB[EC[0]][EC[1]]=='P','S','N','L') && turn=='a')
return (CB[EC[0]][EC[1]]=='G');
else if((CB[EC[0]][EC[1]]=='r') && turn=='b')
return (CB[EC[0]][EC[1]]=='k' || 'r');
else if ((CB[EC[0]][EC[1]]=='R') && turn=='a')
return (CB[EC[0]][EC[1]]=='K' || 'R');
else if ((CB[EC[0]][EC[1]]=='b') && turn=='b')
return (CB[EC[0]][EC[1]]=='k' || 'b');
else if ((CB[EC[0]][EC[1]]=='B') && turn=='a')
return (CB[EC[0]][EC[1]]=='K' || 'B');
}
But i didnot understand what is drop,stalemate and checkmate in shogi. Need some help in writing code of these?
C++ does not support implied left hand side in conditionals. You must fully specify the conditions.
Example: if (ans == 'Y' || 'y') evaluates as if ((ans == 'Y') || ('y'))
('y') always evaluates to 1 (true), therefore the if statement is always true.
When a player's move threatens to capture the opposing king on the next turn, the move is said to give check to the king means the king is said to be in check. If a player's king is in check that player's responding move must remove the check if possible if no such move exists, the checking move is also checkmate and immediately wins the game.
I have made check function and through this check function I have to made checkmate function.But don't understand how to write it
void check(char CB[9][9], int SC[2], int EC[2], char turn)
{
if(Isvalidmove(CB, SC, EC, turn)==true) \\I have Isvalidmove
return true;
else
return false;
}
> I have made check function ... I have to made checkmate function ... I have Isvalidmove
1 2 3 4 5 6 7 8
bool checkmate:
if the king is not in check returnfalsefor each square adjacent to the king
if there is a valid move (or capture) to that square && king is not in check in that square returnfalsereturntrue (king is in check and there is no adjacent square to which it can move to escape the check)