2019独角兽企业重金招聘Python工程师标准>>>

■在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.

(待续)

转载于:https://my.oschina.net/dubenju/blog/464443

再译《A *路径搜索入门》之四相关推荐

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

    2019独角兽企业重金招聘Python工程师标准>>> ※※※  外语不好凑合着看吧,呵呵  ※※※ A *路径搜索入门 A* Pathfinding for Beginners 帕 ...

  2. OllyDBG 入门之四--破解常用断点设

    OllyDBG 入门之四--破解常用断点(转) 软件汉化2010-07-08 16:25:23 阅读76评论0   字号:大中小 订阅 bpx hmemcpy    破解万能断点,拦截内存拷贝动作 b ...

  3. Unity快速入门之四 - Unity模型动画相关

    最近要给公司的小伙伴做Unity入门,针对几个常用的知识进行快速入门介绍. Unity快速入门之一 3D基础概念.Camera.Canvas RenderMode的几种方式对比_翕翕堂 Unity快速 ...

  4. Godot3游戏引擎入门之四:给主角添加动画(上)

    一.前言 说明:我目前使用的 Godot 3.1 预览版,所以会与 Godot 3 的版本有一些区别,界面影响不大,如果要使用我上传的 Github Demo 代码,记得去官网下载 3.1 预览版(或 ...

  5. 数码摄影入门之四 对称平衡呼应

    数码摄影入门之四 对称平衡呼应 在中国传统绘画中把构图结构称为"章法"或"布局","展纸作画章法第一".位置经营如同围棋,下子格格皆可落,切 ...

  6. 微软同步框架入门之四--冲突(Conflict)检测和处理

    检测和处理微软同步框架(MSF)入门之四--冲突(Conflict)检测和处理     在几篇文章当中,我介绍了 SnapShot(快照方式)和"只同步新更改和增量更改"这两种同步 ...

  7. 再谈进程—从入门到出家

    再谈进程-从入门到出家 这段时间由于工作上用到几个比较基础的进程编程,却发现自己好久没有接触进程了,都狂忘了!不得不感慨几句:老了老了~~~ 趁着对进程的回忆,也总一个简单的总结,下次可以回头看看,也 ...

  8. 再译《A *路径搜索入门》之二

    2019独角兽企业重金招聘Python工程师标准>>> ■路径评分 Path Scoring 计算出的路径时,确定要使用的方格的关键是下面的公式: The key to determ ...

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

    上一讲鸡啄米讲的是VS2010应用程序工程中文件的组成结构,可能大家对工程的运行原理还是很模糊,理不出头绪,毕竟跟C++编程入门系列中的例程差别太大.这一节鸡啄米就为大家分析下MFC应用程序框架的运行 ...

最新文章

  1. MySQL 学习笔记(7)—— 游标
  2. [技术文档] 一劳永逸,用USB设备制作多系统引导
  3. BOM--location对象、history对象
  4. odata连接现有数据库
  5. phpcms9.6 ueditor_PHPCMS V9.6.6 修改版
  6. Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock'的解决
  7. 概率编程编程_概率编程语言的温和介绍
  8. python怎么播放mp3_python上播放mp3歌曲
  9. 优酷 米兔机器人_ONEBOT积木机器人上手评测,寓教于乐的反履机甲让孩子爱不释手...
  10. 前魅族李楠创办“怒喵科技”,网友:看半天不知道公司干嘛的
  11. 大数据工程师职场面试攻略技巧有哪些?
  12. HaaS EDU场景式应用学习 - 光照信息屏
  13. 麻省理工成立金融科技实验室,蚂蚁金服成唯一中国创始企业
  14. laravel pdf 加水印
  15. 通过windows启动流程分析rootkit的潜在位置
  16. Queues.drain 一边读数据一边写数据
  17. 网站出现403错误怎么办,为什么会出现403错误,要怎么解决
  18. app中跳转到手机浏览器,部分手机白屏解决(Vue)
  19. Towards Enhancing Fine-grained Details for Image Matting
  20. Agronomy|3.9分JCR1区征稿/37天见刊-宏基因组解析农业微生物组专刊(刘永鑫/于鹏)...

热门文章

  1. Javascript在页面加载时的执行顺序(转载)
  2. 九妹带你走向 架构师
  3. IT人的自我导向型学习:学习的4个层次
  4. backgroundworder 简单使用
  5. python可迭代对象 迭代器生成器_Python可迭代对象、迭代器和生成器
  6. CentOS系统更换yum源(repomd.xml not found解决方案)
  7. iView 实战系列教程(21课时)_2.iView 实战教程之导航、路由、鉴权篇
  8. Python基础学习总结__Day3
  9. [Unity优化]批处理03:静态批处理
  10. uoj#119. 【UR #8】决战圆锥曲线(线段树+复杂度分析)