再译《A *路径搜索入门》之四

■在A *方法总结

Summary of the A* Method

好了,现在你通过解释已经走了,让我们奠定了一步一步的方法,在同一个地方:

Okay, now that you have gone through the explanation, let‘s lay out the step-by-step method all in one place:

添加开始方块(或节点)到开启列表。

Add the starting square (or node) to the open list.

重复以下操作:

Repeat the following:

a) 寻找开启列表上最小F值的方块。我们将此作为当前方块。

  1. Look for the lowest F cost square on the open list. We refer to this as the current square

b) 切换到关闭列表。

  1. Switch it to the closed list.

c)  对于当前方块的8个方块的每一个...

c) For each of the 8 squares adjacent to this current square …

如果不能走,或者如果它是关闭的名单上,忽略它。否则,请执行以下操作。

If it is not walkable or if it is on the closed list, ignore it. Otherwise do the following.

如果不在开启列表中,将其添加到开启列表。使当前方块成为这个方块的父。记录的方块F值,G值和H值。

If it isn‘t on the open list, add it to the open list. Make the current square the parent of this square. Record the F, G, and H costs of the square.

如果在开启列表了,检查,看看这个路径,该方块是否是更好的,采用G值作为衡量。更低的G值意味着这是一个更好的路径。如果是这样,把方格的父改变当前方块,并重新计算方块的G值和F值。如果你保持开启列表排序F值,由于这个变化你可能需重存列表。

If it is on the open list already, check to see if this path to that square is better, using G cost as the measure. A lower G cost means that this is a better path. If so, change the parent of the square to the current square, and recalculate the G and F scores of the square. If you are keeping your open list sorted by F score, you may need to resort the list to account for the change.

d)当你停止:

d) Stop when you:

目标方块添加到关闭列表,在这种情况下,路径已经被发现(见下面的注),或无法找到目标方块,并且开启列表是空的。在这种情况下,不存在路径。

Add the target square to the closed list, in which case the path has been found (see note below), or Fail to find the target square, and the open list is empty. In this case, there is no path.

保存路径。从目标方块往回走,从每个方块移到其父,直到你到达开始方块。这是你的路径。

Save the path. Working backwards from the target square, go from each square to its parent square until you reach the starting square. That is your path.

注:在早期版本的文章中,有人建议,当目标方块(或节点)已经添加到开启列表,而不是关闭的列表,你可以停下来。这样做会更快,它几乎总是会给你的最短路径,但并非总是如此。有些情况下,这样做可能产生差异当从第二移动到最后一个节点到最后的(目标)节点的运动成本可能有明显变化 -例如,如果在河流交叉在两个节点之间的情况下。

Note: In earlier versions of this article, it was suggested that you can stop when the target square (or node) has been added to the open list, rather than the closed list. Doing this will be faster and it will almost always give you the shortest path, but not always. Situations where doing this could make a difference are when the movement cost to move from the second to the last node to the last (target) node can vary significantly -- as in the case of a river crossing between two nodes, for example.

■小咆哮

Small Rant

请原谅我的题外话,但值得指出的是,当你在网上阅读的A *路径搜索,并在各类论坛上的各种讨论时,你偶尔会看到有人提到某些代码不是A *。对于A *使用方法,你需要包含上面讨论到的元素 -- 特别是开放列表和关闭列表和路径采用F值,G值和H值。有很多其他的路径搜索算法,但是其它的通常被认为是最好的方法不是A *。在这篇文章的末尾有布莱恩斯托特讨论,包括他们的一些利弊引用的文章很多。有时替代品在某些情况下更好,但你应该明白你正在进入。好了,爽了。回到话题。

Forgive me for digressing, but it is worth pointing out that when you read various discussions of A* pathfinding on the web and in assorted forums, you will occasionally see someone refer to certain code as A* when it isn‘t. For the A* method to be used, you need to include the elements just discussed above -- specifically open and closed lists and path scoring using F, G, and H. There are lots of other pathfinding algorithms, but those other methods are not A*, which is generally considered to be the best of the lot. Bryan Stout discusses many of them in the article referenced at the end of this article, including some of their pros and cons. Sometimes alternatives are better under certain circumstances, but you should understand what you are getting into. Okay, enough ranting. Back to the article.

(待续)

时间: 2024-10-17 11:05:51

再译《A *路径搜索入门》之四的相关文章

再译《A *路径搜索入门》之流畅版??

A *路径搜索入门 帕特里克·莱斯特发表于2003年10月8日下午8点33人工智能 如果您发现文中有错误或问题(丢失的影像或文件,受损代码,不正确的文本格式等),导致无法阅读它时,请联系编辑,以便能更正.感谢您帮助我们改善这个资源. 更新于2005年7月18日 这篇文章已被翻译成阿尔巴尼亚语,中文,法语,德语,葡萄牙语,俄语和西班牙语.欢迎其他的翻译.在这篇文章的末尾有联系的电子邮件地址. 对于初学者, A *(读A-星,译者注:老外读A-star)算法可能有些复杂.虽然在网上有很多解释A *算

再译《A *路径搜索入门》之一

※※※  外语不好凑合着看吧,呵呵  ※※※ A *路径搜索入门 A* Pathfinding for Beginners 帕特里克·莱斯特发表于2003年10月8日下午8点33人工智能 By Patrick Lester Published Oct 08 2003 08:33 PM in Artificial Intelligence 如果您发现本文中包含错误或问题,导致无法读取它(丢失的影像或文件,受损代码,不正确的文本格式等),请联系编辑,以便能更正.感谢您帮助我们改善此资源. If yo

A* Pathfinding for Beginners A*算法路径搜索入门

原始链接地址: http://www.gamedev.net/page/resources/_/technical/artificial-intelligence/a-pathfinding-for-beginners-r2003 Updated July 18, 2005 This article has been translated into Albanian, Chinese, French, German, Portuguese, Russian, and Spanish. Other

VS2010/MFC编程入门之四(MFC应用程序框架分析)

VS2010/MFC编程入门之四(MFC应用程序框架分析)-软件开发-鸡啄米 http://www.jizhuomi.com/software/145.html   上一讲鸡啄米讲的是VS2010应用程序工程中文件的组成结构,可能大家对工程的运行原理还是很模糊,理不出头绪,毕竟跟C++编程入门系列中的例程差别太大.这一节鸡啄米就为大家分析下MFC应用程序框架的运行流程. 一.SDK应用程序与MFC应用程序运行过程的对比        程序运行都要有入口函数,在之前的C++教程中都是main函数,

【Git入门之四】操作项目

[Git入门之四]操作项目 - JackyStudio - 博客频道 - CSDN.NET 1.查看操作日记 <git log>用于查看操作日记详情.因为Git是分布式的,采用SHA1这样的版本号可有效的防止版本冲突. [cpp]?view plaincopy ? #查看操作日记,底下那串长长的数据就是SHA1?ID,表示当前版本号?? $Snbsp;git?log?? commit?aea0365712908805bc28540b4db9fd2f15360a8b?? Author:?Jack

(译)Windsor入门教程---第五部分 添加日志功能

介绍 现在我们已经有了基础的框架了,是时候添加内容了,那么我们首先应该考虑的就是在应用程序中添加日志功能.我们会使用Windsor来配置,在这一部分,你将学习Windsor之外的其他功能. Logging Facility 在上一部分说过,Windsor有很多自带的可选的功能组件,他们扩展了Windsor的即用性.在这一部分,我们将在程序中添加日志功能. Logging Facility提供了一些常用的日志框架比如Log4net.Nlog,以及mvc内置的日志框架Trace.Logging Fa

(译)Windsor入门教程---第三部分 编写第一个Installer

简介 在第二部分我们创建了控制器工厂.现在我们要把我们的控制器交给Windsor来管理. Installer Windsor有一个专门的类installer.cs,用来向容器注册组件.在你的应用程序中至少会有几个这样的installer类,所以要保持他们的代码整洁以及可见性.接下来在我们的应用程序中新建一个专门的文件夹"Installer"来存放这些类.我们首先要注册到容器中的就是控制器,所以我们先来新建一个ControllersInstaller.cs类. Controller in

再译《A *路径搜索入门》之五

■实施上的注意事项 Notes on Implementation 现在您了解了基本的方法,当你编写自己的程序时,有一些额外的事情要考虑.下面给出我用C ++和Blitz Basic编写的程序,用其他语言也同样有效. Now that you understand the basic method, here are some additional things to think about when you are writing your own program. Some of the f

再译《A *路径搜索入门》之三

■继续搜索 Continuing the Search 要继续搜索,我们简单地选择在开启列表中具有最小F值的方块.然后,我们用选择方块作以下事情: To continue the search, we simply choose the lowest F score square from all those that are on the open list. We then do the following with the selected square: 1.把它从开启列表取出,并加入到