X-Y heuristic function for solving N-puzzle

对着背影说爱祢 提交于 2019-12-24 10:40:30

问题


Can somebody please explain this heuristic function, for example for the following arrangement of 4x4 puzzle, whats the X-Y heuristic cost?

1  2  3  4 
5  6  7  8
9 10 11 12
0 13 14 15

(0 indicates blank space)


回答1:


As from here and here the X-Y heuristic is computed by the sum of the minimum number of column-adjacent blank swaps to get all tiles in their destination column and the minimum number of row adjacent blank swaps to get all tiles in their destination row.

So in this situation:

1  2  3  4 
5  6  7  8
9 10 11 12
0 13 14 15

the only misplaced tiles are 13 , 14 and 15, assuming the goal state is

1  2  3  4 
5  6  7  8
9 10 11 12
13 14 15 0

So in this case the we have to compute at first the number of column swaps the blank has to do to get all the tiles in the correct position. This is equivalent to 3, since the blank has to move three times to the the right column to be in the right position (and to have all the tiles in the right position)

Then we have to compute the number of row swaps the blank has to do. This is 0 thanks to the fact that all the tiles are already on the correct row.

Finally h(n) = 3 + 0 = 3 .



来源:https://stackoverflow.com/questions/25850406/x-y-heuristic-function-for-solving-n-puzzle

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!