public int getDistanceToGoal ( ) { int distance = 0 ; for ( int i = 0 ; i < cells . length ; i ++ ) { distance += getDistance ( i , cells [ i ] ) ; } return distance ; }
Calculate the distance between the goal by summing the distance between each cell and its goal .