}//end of IsMoveLegal method public void EnterMove(int[] move) { Move newMove = new Move(move); Console.Write($" moves {GameInterface.map_board_location(move[0],move[1])}{GameInterface.map_board_location(move[2], move[3])} ({GameInterface.map_translate_location(move[0], move[1])}{GameInterface.map_translate_location(move[2], move[3])})"); if(OnBoard(newMove.GetFromRow(), newMove.GetFromCol()) && OnBoard(newMove.GetFromRow(), newMove.GetFromCol())) { PIECES piece = board[newMove.GetFromRow(), newMove.GetFromCol()]; currentHash = currentHash ^ zBoard[(5 * newMove.GetFromRow()) + newMove.GetFromCol(), (int)piece - 1]; Removal removal = new Removal(newMove.GetToRow(), newMove.GetToCol(), board[newMove.GetToRow(), newMove.GetToCol()]); removals.Push(removal); if(board[newMove.GetToRow(), newMove.GetToCol()] != PIECES.NONE) { currentHash = currentHash ^ zBoard[(5 * newMove.GetToRow()) + newMove.GetToCol(), (int)board[newMove.GetToRow(), newMove.GetToCol()] - 1]; } if(piece == PIECES.P1_BISHOP) { board[newMove.GetToRow(), newMove.GetToCol()] = PIECES.P1_KNIGHT; currentHash = currentHash ^ zBoard[(5 * newMove.GetToRow()) + newMove.GetToCol(), (int)PIECES.P1_KNIGHT - 1]; } else if(piece == PIECES.P2_BISHOP) { board[newMove.GetToRow(), newMove.GetToCol()] = PIECES.P2_KNIGHT; currentHash = currentHash ^ zBoard[(5 * newMove.GetToRow()) + newMove.GetToCol(), (int)PIECES.P2_KNIGHT - 1]; } else if(piece == PIECES.P1_ROOK) { board[newMove.GetToRow(), newMove.GetToCol()] = PIECES.P1_BISHOP; currentHash = currentHash ^ zBoard[(5 * newMove.GetToRow()) + newMove.GetToCol(), (int)PIECES.P1_BISHOP - 1]; } else if(piece == PIECES.P2_ROOK) { board[newMove.GetToRow(), newMove.GetToCol()] = PIECES.P2_BISHOP; currentHash = currentHash ^ zBoard[(5 * newMove.GetToRow()) + newMove.GetToCol(), (int)PIECES.P2_BISHOP - 1]; } else if(piece == PIECES.P1_KNIGHT) { board[newMove.GetToRow(), newMove.GetToCol()] = PIECES.P1_ROOK; currentHash = currentHash ^ zBoard[(5 * newMove.GetToRow()) + newMove.GetToCol(), (int)PIECES.P1_ROOK - 1]; } else if(piece == PIECES.P2_KNIGHT) { board[newMove.GetToRow(), newMove.GetToCol()] = PIECES.P2_ROOK; currentHash = currentHash ^ zBoard[(5 * newMove.GetToRow()) + newMove.GetToCol(), (int)PIECES.P2_ROOK - 1]; } else { board[newMove.GetToRow(), newMove.GetToCol()] = piece; currentHash = currentHash ^ zBoard[(5 * newMove.GetToRow()) + newMove.GetToCol(), (int)piece - 1]; } board[newMove.GetFromRow(), newMove.GetFromCol()] = PIECES.NONE; } }//end of EnterMove method
}//end of EnterMove method public void TryMove(Move move) { if(OnBoard(move.GetFromRow(), move.GetFromCol()) && OnBoard(move.GetFromRow(), move.GetFromCol())) { PIECES piece = board[move.GetFromRow(), move.GetFromCol()]; currentHash = currentHash ^ zBoard[(5 * move.GetFromRow()) + move.GetFromCol(), (int)piece - 1]; Removal removal = new Removal(move.GetToRow(), move.GetToCol(), board[move.GetToRow(), move.GetToCol()]); removals.Push(removal); if(board[move.GetToRow(), move.GetToCol()] != PIECES.NONE) { currentHash = currentHash ^ zBoard[(5 * move.GetToRow()) + move.GetToCol(), (int)board[move.GetToRow(), move.GetToCol()] - 1]; } if(piece == PIECES.P1_BISHOP) { board[move.GetToRow(), move.GetToCol()] = PIECES.P1_KNIGHT; currentHash = currentHash ^ zBoard[(5 * move.GetToRow()) + move.GetToCol(), (int)PIECES.P1_KNIGHT - 1]; } else if(piece == PIECES.P2_BISHOP) { board[move.GetToRow(), move.GetToCol()] = PIECES.P2_KNIGHT; currentHash = currentHash ^ zBoard[(5 * move.GetToRow()) + move.GetToCol(), (int)PIECES.P2_KNIGHT - 1]; } else if(piece == PIECES.P1_ROOK) { board[move.GetToRow(), move.GetToCol()] = PIECES.P1_BISHOP; currentHash = currentHash ^ zBoard[(5 * move.GetToRow()) + move.GetToCol(), (int)PIECES.P1_BISHOP - 1]; } else if(piece == PIECES.P2_ROOK) { board[move.GetToRow(), move.GetToCol()] = PIECES.P2_BISHOP; currentHash = currentHash ^ zBoard[(5 * move.GetToRow()) + move.GetToCol(), (int)PIECES.P2_BISHOP - 1]; } else if(piece == PIECES.P1_KNIGHT) { board[move.GetToRow(), move.GetToCol()] = PIECES.P1_ROOK; currentHash = currentHash ^ zBoard[(5 * move.GetToRow()) + move.GetToCol(), (int)PIECES.P1_ROOK - 1]; } else if(piece == PIECES.P2_KNIGHT) { board[move.GetToRow(), move.GetToCol()] = PIECES.P2_ROOK; currentHash = currentHash ^ zBoard[(5 * move.GetToRow()) + move.GetToCol(), (int)PIECES.P2_ROOK - 1]; } else { board[move.GetToRow(), move.GetToCol()] = piece; currentHash = currentHash ^ zBoard[(5 * move.GetToRow()) + move.GetToCol(), (int)piece - 1]; } board[move.GetFromRow(), move.GetFromCol()] = PIECES.NONE; } }//end of TryMove method
}//end of TryMove method public void UndoMove(Move move) { Removal removal = removals.Peek(); if(move.GetToRow() == removal.GetRow() && move.GetToCol() == removal.GetCol()) { removal = removals.Pop(); currentHash = currentHash ^ zBoard[(5 * move.GetToRow()) + move.GetToCol(), (int)board[move.GetToRow(), move.GetToCol()] - 1]; if(board[move.GetToRow(), move.GetToCol()] == PIECES.P1_BISHOP) { board[move.GetFromRow(), move.GetFromCol()] = PIECES.P1_ROOK; currentHash = currentHash ^ zBoard[(5 * move.GetFromRow()) + move.GetFromCol(), (int)PIECES.P1_ROOK - 1]; } else if(board[move.GetToRow(), move.GetToCol()] == PIECES.P2_BISHOP) { board[move.GetFromRow(), move.GetFromCol()] = PIECES.P2_ROOK; currentHash = currentHash ^ zBoard[(5 * move.GetFromRow()) + move.GetFromCol(), (int)PIECES.P2_ROOK - 1]; } else if(board[move.GetToRow(), move.GetToCol()] == PIECES.P1_ROOK) { board[move.GetFromRow(), move.GetFromCol()] = PIECES.P1_KNIGHT; currentHash = currentHash ^ zBoard[(5 * move.GetFromRow()) + move.GetFromCol(), (int)PIECES.P1_KNIGHT - 1]; } else if(board[move.GetToRow(), move.GetToCol()] == PIECES.P2_ROOK) { board[move.GetFromRow(), move.GetFromCol()] = PIECES.P2_KNIGHT; currentHash = currentHash ^ zBoard[(5 * move.GetFromRow()) + move.GetFromCol(), (int)PIECES.P2_KNIGHT - 1]; } else if(board[move.GetToRow(), move.GetToCol()] == PIECES.P1_KNIGHT) { board[move.GetFromRow(), move.GetFromCol()] = PIECES.P1_BISHOP; currentHash = currentHash ^ zBoard[(5 * move.GetFromRow()) + move.GetFromCol(), (int)PIECES.P1_BISHOP - 1]; } else if(board[move.GetToRow(), move.GetToCol()] == PIECES.P2_KNIGHT) { board[move.GetFromRow(), move.GetFromCol()] = PIECES.P2_BISHOP; currentHash = currentHash ^ zBoard[(5 * move.GetFromRow()) + move.GetFromCol(), (int)PIECES.P2_BISHOP - 1]; } else { board[move.GetFromRow(), move.GetFromCol()] = board[move.GetToRow(), move.GetToCol()]; currentHash = currentHash ^ zBoard[(5 * move.GetFromRow()) + move.GetFromCol(), (int)board[move.GetToRow(), move.GetToCol()] - 1]; } board[removal.GetRow(), removal.GetCol()] = removal.GetPiece(); if(removal.GetPiece() != PIECES.NONE) { currentHash = currentHash ^ zBoard[(5 * removal.GetRow()) + removal.GetCol(), (int)removal.GetPiece() - 1]; } } }//end of UndoMove method