public int eval(INode state){
  EightPuzzleNode node=(EightPuzzleNode)state;
  int sumDistance=0;
  sumDistance+=node.cell(1,0) - node.cell(1,2);
  sumDistance+=node.cell(2,0) - node.cell(0,2);
  sumDistance+=node.cell(2,1) - node.cell(0,1);
  sumDistance+=node.cell(2,2) - node.cell(0,0);
  return Math.abs(16 - sumDistance);
}

public int eval ( INode state ) { EightPuzzleNode node = ( EightPuzzleNode ) state ; int sumDistance = 0 ; sumDistance += node . cell ( 1 , 0 ) - node . cell ( 1 , 2 ) ; sumDistance += node . cell ( 2 , 0 ) - node . cell ( 0 , 2 ) ; sumDistance += node . cell ( 2 , 1 ) - node . cell ( 0 , 1 ) ; sumDistance += node . cell ( 2 , 2 ) - node . cell ( 0 , 0 ) ; return Math . abs ( 16 - sumDistance ) ; }
eval = g ( n ) + w ( n ) , where g ( n ) is length of the path from initial to node n , and w ( n ) computes difference of opposite cells .
