public static boolean solveBoard(Move current) { if (movesCounter == boardSize * boardSize) return true; int[] x = {-1, 1, -2, -2, 2, 2, -1, 1}; int[] y = {2, 2, 1, -1, 1, -1, -2, -2}; for (int i = 0; i < 8; i++) { Move next = new Move(current.row + x[i], current.col + y[i]); if (makeMove(next)) { if (solveBoard(next) == true) return true; else { undoMove(); movesCounter--; } } else if (movesCounter == boardSize * boardSize) { return true; } } return false; }