/** * Description of calHorizontal(int row). This method returns linear conflicts in certain column. * * @param row row which conflicts are checked * @return amount of conflicts * 2 */ private int calHorizontal(int row) { int lc = 0; int max = -1; for (int col = 0; col < columns; col++) { int num = puzzle.getNumberInCell(row, col); if (num != puzzle.getEmpty() && num / rows == row) { if (num > max) { max = num; } else { lc += 2; } } } return lc; }
/** * Description of calVertical(int col). This method returns linear conflicts in certain row. * * @param col column which conflict are checked * @return amount of conflicts * 2 */ private int calVertical(int col) { int lc = 0; int max = -1; for (int row = 0; row < rows; row++) { int num = puzzle.getNumberInCell(row, col); if (num != puzzle.getEmpty() && num % columns == col) { if (num > max) { max = num; } else { lc += 2; } } } return lc; }