//returns true if the king is in check after the proposed move //takes in the piece being moved, the king in question, the final x/y positions of the piece, and the chessBoard public bool isKingInCheckAfterMove(King king, int finalX, int finalY, ChessPiece[,] chessBoard) { int oldX = _positionX; int oldY = _positionY; ChessPiece[,] chessBoardAfterMove = new ChessPiece[MAX_CHESS_VALUE + 1, MAX_CHESS_VALUE + 1]; //Create duplicate chessboard to examine future move for (int i = 0; i <= MAX_CHESS_VALUE; i++) { for (int j = 0; j <= MAX_CHESS_VALUE; j++) { chessBoardAfterMove[i, j] = chessBoard[i, j].Clone(); } } //Make the move on the chessboard chessBoardAfterMove[finalX, finalY] = chessBoardAfterMove[oldX, oldY]; chessBoardAfterMove[oldX, oldY] = new ChessPiece(oldX, oldY); //is the king is in check after this move? return(king.isInCheck(king.PositionX, king.PositionY, chessBoardAfterMove)); }