【发布时间】:2018-05-20 17:27:50
【问题描述】:
因此,在我正在研究的 A* 搜索实现中,我可以使用向上、向左、向右、向下的寻路方向:
#define the moving direction: up /left /right /down
xs = (0, -1, 1, 0)
ys = (-1, 0, 0, 1)
如何将移动方向更改为:上、左、右、下、左上、左下、右上和右下?
至于成本,上,左,右,下我有1.0,但如果我必须将成本作为2.0的方向:左上,左下,右上和右下,我该如何实现那个?
def get_cost(self, x1, y1, x2, y2):
if x1 == x2 or y1 == y2:
return 1.0
【问题讨论】:
标签: python-3.x artificial-intelligence a-star