# 再译《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.

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.

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

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.

（待续）

### 放个屁

A*算法之烂片整理

《鸡啄米C++编程入门系列》系列技术文章整理收藏

《鸡啄米C++编程入门系列》系列技术文章整理收藏 收藏整理鸡啄米C++编程入门系列文章，供个人和网友学习C++时参考 1鸡啄米：C++编程入门系列之前言 2鸡啄米：C++编程入门系列之一（进制数） ...

■实施上的注意事项 Notes on Implementation 现在您了解了基本的方法，当你编写自己的程序时，有一些额外的事情要考虑。下面给出我用C ++和Blitz Basic编写的程序，用其他语言也同样有效。 ...

A 路径搜索入门 帕特里克·莱斯特发表于2003年10月8日下午8点33人工智能 如果您发现文中有错误或问题（丢失的影像或文件，受损代码，不正确的文本格式等），导致无法阅读它时，请联系编辑，以...

※※※ 外语不好凑合着看吧，呵呵 ※※※ A 路径搜索入门 A Pathfinding for Beginners 帕特里克·莱斯特发表于2003年10月8日下午8点33人工智能 By Patrick Lester Published Oct 08 2003 08...

《鸡啄米VS2010/MFC编程入门》系列技术文章整理收藏

《鸡啄米VS2010/MFC编程入门》系列技术文章整理收藏 1VS2010/MFC编程入门之前言 http://www.lai18.com/content/410337.html 2VS2010/MFC编程入门之二（利用MFC向导生成单文档应用程序框架） ...

VS2010/MFC编程入门教程之目录和总结（鸡啄米）

weixin_40647819 ⋅ 05/23 ⋅ 0

■延伸阅读 Further Reading 好了，现在你已具备了基础知识和一些先进的概念感。在这一点上，我建议你到涉水我的源代码。该软件包包含两个版本，一个是C ++的，一个是Blitz Basic的。两个版本...

Spring Security

【每天一个JQuery特效】淡入淡出显示或隐藏窗口

Rhymo-Wu ⋅ 今天 ⋅ 0

Spring JDBC使用方法

Contos 7 安装Jenkins

Jenkins是一款能提高效率的软件，它能帮你把软件开发过程形成工作流，典型的工作流包括以下几个步骤 开发 提交 编译 测试 发布 有了Jenkins的帮助，在这5步中，除了第1步，后续的4步都是自动...

revel

revel install go get github.com/revel/revelgo get github.com/revel/cmd create new app revel new git.oschina.net/zdglf/myapp run app revel run git.oschina.net/zdglf/myapp ot......

zdglf ⋅ 今天 ⋅ 0

49. Group Anagrams - LeetCode

Question 49. Group Anagrams Solution 思路：维护一个map,key是输入数组中的字符串(根据字符排好序) Java实现： public List<List<String>> groupAnagrams(String[] strs) { Map<Strin......

yysue ⋅ 今天 ⋅ 0

spring Email

BobwithB ⋅ 今天 ⋅ 0

spark 整理的一些知识

Spark 知识点 请描述spark RDD原理与特征？ RDD全称是resilient distributed dataset（具有弹性的分布式数据集）。一个RDD仅仅是一个分布式的元素集合。在Spark中，所有工作都表示为创建新的...

tuoleisi77 ⋅ 今天 ⋅ 0

hello_hp ⋅ 今天 ⋅ 0