/** * Description of calculate(Puzzle puzzle). This method finds conflicting numbers which are they * own row or column but reversed order. Every conflict adds +2 to counter. Why? Every conflict * needs two extra movements to solution. Manhattan Distance value is added to Linear Conflict * value at before it is returned. * * @return amount of conflicts * 2 + Manhattan Distance */ @Override public int calculate(Puzzle puzzle) { this.puzzle = puzzle; rows = puzzle.getNumberOfRows(); columns = puzzle.getNumberOfColumns(); int lc = 0; for (int row = 0; row < rows; row++) { lc += calHorizontal(row); } for (int col = 0; col < columns; col++) { lc += calVertical(col); } return lc + md.calculate(puzzle); }