启发式搜索和A*算法(Heuristics and A* Pathfinding)

本文介绍了A*路径寻找算法中的两种常见启发式方法:曼哈顿距离法和对角线捷径法。曼哈顿方法计算简单且速度快,但可能不会找到最短路径;对角线捷径法则能更好地平衡启发式与实际成本,适用于需要精确路径的情况。

作者:Patrick Lester 

原文地址:http://www.policyalmanac.org/games/heuristics.htm


 

Heuristics and A* Pathfinding

By Patrick Lester ( Updated April 21, 2004)


This article is a sidebar for the main article, “A* Pathfinding for Beginners.

As was noted in the main article, there are several ways that you can calculate the heuristic in A*. I describe a few here. You should also check out the links at the bottom of this page.

Manhattan Method

This is the method used in the main article. Its primary advantage is that it will generally get you to the target faster than most alternatives. Its primary drawback is that in a 8-way pathfinder like the one in the main example, this method is inadmissible, so it is not guaranteed to give us the shortest possible path. It will almost always give the shortest path, though, and when it doesn't it won't be far off. Also, because it is overweighted compared to G, it will overpower any small modifiers that you try to add to the calculation of G like, say, a turning penalty or an influence map modifier. If you don't have those, this method is probably your best bet. The equation, where abs = absolute value, is:

H = 10*(abs(currentX-targetX) + abs(currentY-targetY))

Diagonal Shortcut

This method balances H with G. Its primary advantage is that, because it is balanced, it is able to fully consider small modifiers like a turning penalty or influence map modifier. It is also admissible. It is a bit slower than the Manhattan method, though. The equation, where abs = absolute value, is:

xDistance = abs(currentX-targetX)
yDistance = abs(currentY-targetY)
if xDistance > yDistance
     H = 14*yDistance + 10*(xDistance-yDistance)
else
     H = 14*xDistance + 10*(yDistance-xDistance)
end if

There are many other methods for calculating H, although these are probably two of the most commonly used. In general, the closer your estimate is to the actual remaining distance along the path to the goal, the faster A* will find that goal. If you overestimate H compared to the actual remaining distance, however, A* is not guaranteed to give you the best path. The trick, then, is to come as close to the actual distance as possible, without overestimating.

For more information, see:


随着信息技术在管理上越来越深入而广泛的应用,作为学校以及一些培训机构,都在用信息化战术来部署线上学习以及线上考试,可以与线下的考试有机的结合在一起,实现基于SSM的小码创客教育教学资源库的设计与实现在技术上已成熟。本文介绍了基于SSM的小码创客教育教学资源库的设计与实现的开发全过程。通过分析企业对于基于SSM的小码创客教育教学资源库的设计与实现的需求,创建了一个计算机管理基于SSM的小码创客教育教学资源库的设计与实现的方案。文章介绍了基于SSM的小码创客教育教学资源库的设计与实现的系统分析部分,包括可行性分析等,系统设计部分主要介绍了系统功能设计数据库设计。 本基于SSM的小码创客教育教学资源库的设计与实现有管理员,校长,教师,学员四个角色。管理员可以管理校长,教师,学员等基本信息,校长角色除了校长管理之外,其他管理员可以操作的校长角色都可以操作。教师可以发布论坛,课件,视频,作业,学员可以查看下载所有发布的信息,还可以上传作业。因而具有一定的实用性。 本站是一个B/S模式系统,采用Java的SSM框架作为开发技术,MYSQL数据库设计开发,充分保证系统的稳定性。系统具有界面清晰、操作简单,功能齐全的特点,使得基于SSM的小码创客教育教学资源库的设计与实现管理工作系统化、规范化。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值