Version1/Puzzle.java
/*------------------------------------------------------------------------------
Heuristic Functions: Hamming distance and Manhattan distance
------------------------------------------------------------------------------*/
Heuristic Functions: Hamming distance and Manhattan distance
Heuristic Functions : Hamming distance and Manhattan distance
public static int distHamming(Table tb){
        int diffs=0;
        int[][] table=tb.getTable();
        for(int i=0;i<4;i++){
            for(int j=0;j<4;j++){
                if(table[i][j] != final_state[i][j])
                    diffs++;
            }
        }
        return diffs;
    }
public static int distHamming ( Table tb ) { int diffs = 0 ; int [ ] [ ] table = tb . getTable ( ) ; for ( int i = 0 ; i < 4 ; i ++ ) { for ( int j = 0 ; j < 4 ; j ++ ) { if ( table [ i ] [ j ] != final_state [ i ] [ j ] ) diffs ++ ; } } return diffs ; }
Heuristic Functions: Hamming distance and Manhattan distance
Heuristic Functions : Hamming distance and Manhattan distance
//Calculates the total number of missplaced cells