【发布时间】:2012-11-17 20:42:00
【问题描述】:
我目前正在使用 2D 数组来实现 Greedy Best First Search 来表示网格。我现在的实现返回打开的节点。我正在使用优先队列。当我返回遍历的路径/打开的节点并查看节点时,算法似乎会从网格的一侧跳到另一侧。它应该这样做吗?玩家在穿越网格时跳到网格另一侧的单元格是没有意义的,因为那里的启发式更好然后跳回去。 我正在使用这个网格:
这些是所有已经打开的节点的(y,x)坐标(注意是y,x代表一个二维数组):
0,0 Goes across the top of the board
0,1
0,2
0,3
0,4
0,5
1,5 Goes down one cell
1,4 goes left
1,6 goes right 2 spaces
0,6 goes up
1,7 goes down the side of the board
2,7 \/
3,7 \/
4,7 \/
5,7 \/
0,7 jumps up across the board
6,7
1,2 jumps up across the board
2,2
3,2
4,2
3,1
4,1
3,0
2,1
5,2
5,1
4,0
2,0
7,7 jumps up across the board
7,6
7,5
6,5
5,5
5,4
4,4
3,4
3,5
【问题讨论】:
标签: java algorithm search greedy