/// <summary> /// Demande au plateau de vérifiré la possibilité d'un échec et pat. /// </summary> /// <returns>Vrai si un des rois est en échec et pat.</returns> public bool askBoardCheckPat() { //trying move on temp board Board tempBoard = new Board(m_board.ToString()); for (int x = -1; x <= 1; x++) { for (int y = -1; y <= 1; y++) { if (x != 0 || y != 0) { int[] direction = new int[] { x, y }; int[] start = m_board.getKingCoord(m_turn); int[] end = new int[] { start[0], start[1] }; if ((end[0] + direction[0] > 0 && end[0] + direction[0] < 8) && (end[1] + direction[1] > 0 && end[1] + direction[1] < 8)) { end[0] += direction[0]; end[1] += direction[1]; if (!m_board[end[0], end[1]].isOccupied()) { tempBoard.movePiece(start, end); //Does the move puts us in check position on the temp board if (!tempBoard.detectCheck(m_turn)) { return(false); } tempBoard.movePiece(end, start); } } } } } return(true); }