-
Notifications
You must be signed in to change notification settings - Fork 73
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
你好,我遇到寻路失败的情况了 #1
Comments
因为你终点不可达,new Node(4, 5)在maps中是的值是1 |
你好,您仔细看下我这个map,new Node(4, 5)这个终点貌似是0 |
new Node(4, 5),应该是图里面的第六行,第五列这个吧? |
确实有问题,我看下 |
这是因为H值没乘代价,我分析的是这样。 |
不是这个代价问题,已经修复了,可以运行代码看看,H这个时候没必须要乘代价 |
G都乘了代价,H不乘代价,比较不会出问题吗? |
这里还有斜走的,为什么斜走要*10? |
10是曼哈顿值得代价,即使斜着走也是用移动的曼哈顿值*10 |
理解你的意思了,确实是有问题,如果按照曼哈顿的计算方式,是属于横竖移动的,理应乘上响应代价,多谢提醒,我修改下代码 |
下面这种情况,寻路就会失败
int[][] maps = {
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0 },
{ 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0 },
{ 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0 }
};
MapInfo info=new MapInfo(maps,maps[0].length, maps.length,new Node(1, 1), new Node(4, 5));
The text was updated successfully, but these errors were encountered: