MisplacedTiles.java in eightpuzzle.zip
Sponsored links
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author samiQ
*/
public class MisplacedTiles implements Heuristic {
public int calculateHeuristiccost(int[] puzzleTable) {
int totalHeuristic = 0;
for(int i=0; i<8; i++){
if(i == 0 && puzzleTable[i] != 1){
totalHeuristic += 1;
}
else if(i == 1 && puzzleTable[i] != 2)
totalHeuristic +=1;
else if(i == 2 && puzzleTable[i] !
...
...
... to be continued.
This is a preview. To get the complete source file,
please click here to download the whole source code package.