Calculating Manhattan Distance
我正在Java 2D数组int [] []状态下实现NxN个拼图。需要通过以下方式使用曼哈顿启发式:
1 2 3 4 5 6 | the sum of the vertical and horizontal distances from the current node to the goal node/tile +(plus) the number of moves to reach the goal node from the initial position |
此刻,我还不知道该怎么走。我是2D阵列益智游戏编程的初学者,因此难以理解某些概念。如何用Java编写此代码?
这更多是一个数学问题,但无论如何,曼哈顿距离是水平距离和垂直距离的绝对值之和
更多信息:http://en.wikipedia.org/wiki/Taxicab_geometry