文档章节

两层A *路径搜索之草译

如比如比
 如比如比
发布于 2015/06/18 04:35
字数 1737
阅读 140
收藏 8

A *路径搜索

Two-Tiered A* Pathfinding

 

作者:帕特里克·莱斯特(更新200319日)

By Patrick Lester ( Updated January 9, 2003)

 

在我的主文章A *路径搜索入门(http://my.oschina.net/u/660460/blog/467603)里,我非常笼统得描述了A*,并描述了如何建一个一的通用路径搜索功能。建只有一个路径搜索功能,但是,可以是不必要的限制。

In my main article, A* Pathfinding for Beginners, I described A* in very general terms, and described how to create a single all-purpose pathfinding function. Creating only one pathfinding function, however, can be needlessly limiting.

 

下面的RPG情况,想找到绕过附近的的路

Consider the following RPG situation, and a swordsman who wants to pathfind around a nearby wall:

 


种地,可以以各种方式使用各种密度放置点。在个例子中,使用了高密度点网,如下所示。

Given this kind of map, you could place nodes in a variety of ways, and use a variety of densities. In this example, let's use a high-density node network, as is shown below.

 

 

在此中,白点的能走的。没有点的地儿走。在个例子中我做一些有点不同事情。在个例子中,你被允抄近路方格。另外,“方格”本身不是方形了。因为这是一个等距例,我已决定了Y(垂直X(水平)两倍多点。适当的等距路径。

In this graphic, the white nodes are walkable. Spots where there are no nodes are unwalkable. We also do some things a little differently in this example. In this example you are allowed to "cut corners" around unwalkable squares. Also the "squares" themselves aren't square anymore. Because this is an isometric example, we have decided to pack twice as many nodes on the Y (vertical axis) as there are on the X (horizontal) axis. This allows proper isometric paths.

 

正如你所看到的,使用点的网,我可以在附近的找到路径,但也上和附近的桶的程之。我的密集点的网络路径搜索也可以的站立的火炬,其中在最基点是不走。之,是精密路径搜索

As you can see, using this tightly packed node network, we can pathfind not only around the nearby wall but also between the wall and the nearby barrel in the process. Our dense node network also allows pathfinding around the standing torch, where the node at the very base is unwalkable. This, in sum, is precision pathfinding.

 

是在短距离的情况下很酷,但我需要在整个地路径搜索?用密密麻麻的网络节点像这样很容易A *搜索通只是一个一的路径超过10,000以上个点。来几乎任何PC嘎然而止。

Well, that is pretty cool in short-distance situations, but what do we do if we need to pathfind across the entire map? Using a densely packed node network like this could easily leave you searching through 10,000+ nodes on just a single pass through the A* loop. That will bring just about any PC to a grinding halt.

 

所以,来看看另一种选择。如果我们选择创建一个更密集的点的网,就像一个你下文?

So let's look at an alternative. What if we chose to create a much less dense node network, like the one you see below?

 

 

个例子中,点是在的大等距菱形的中心。关于菱形能走的数据存在沿边缘相同的数,并表示在形与色的小点。从一个等距瓦移到其相8相邻的砖块之一,相邻砖块本身必能走的,之的路径不能被阻止。

In this example, the nodes are in the center of the large isometric diamonds. Data about walkability between the diamonds is stored in the same array along the edges, and is represented in this graphic with small red dots. To move from one isometric tile to one of its 8 adjacent macro-tiles, the adjacent tile must itself be walkable, and the path between must not be blocked. 

 

点网是比早的一个不密集的72倍。相反,有多达10000理,在任何时间,在里我将只能与1/72的,或小于200。我算机理肯定可以搞定。整个地图路径搜索不再是一个问题

This node network is 72 times less dense than the earlier one. Instead of dealing with as many as 10,000+ nodes at any given time, here we will only be dealing with 1/72 of that, or less than 200. Our computer can definitely handle that. Pathfinding across the map is no longer a problem.

 

把两者合起来

Putting the Two Together

 

所以,我们选择哪种方法?两个

So, which method do we choose? Both!

 

在任何定的搜索,你会先pathfind整个地,用宏观层面探路。这样,你会切到微探路者和搜索从当前位置的路径点两种宏运点走的道路。一旦你入每一个新的宏观层面的菱形方格”,你会用微观层面来探路,以pathfind点两种宏运点提前。这结束了浪每个微通道的下半年,但你需要这样做,以确保它看起来不 - 是没有太大的浪,因你是跨越一个相短的距离微路径搜索。一旦你2-3离目,你会完全切到微探路者,并pathfind到最位置。

On any given search, you would first pathfind across the map, using the macro-level pathfinder. You would then switch to the micro-pathfinder and search for a path from the current location to the node two macro-nodes away on the path. Once you entered each new macro-level diamond "square," you would use the micro-level pathfinder to pathfind to the macro-node two macro nodes ahead. This ends up wasting the second half of each micro-path, but you need to do this to make sure it looks good -- and it isn't much of a waste, since you are micro-pathfinding across a relatively short distance. Once you get 2-3 macro nodes away from the target, you would switch over completely to the micro-pathfinder, and pathfind to the final location.

 

使用种方法,你会得到快速路径搜索整个地,能够进微知著,桶等,以现实的方式,因在早期的微路径搜索的例子。很酷,呵呵!

Using this approach, you will get speed pathfinding across the entire map and be able to negotiate around corners, barrels, etc. in a realistic way, as in the earlier micro-pathfinding example. Pretty cool, huh!

 

如果你是*真的*雄心勃勃,你可以开3探路者,如果你有一个非常大的地,一个在一个真正宏观层面,一是中等水平,以及一个微观层面。像帝国代游戏那样的专业人士做到了一点。只是取决于你的需求是什么。

And if you are *really* ambitious, you could develop three pathfinders if you have a really big map, one at a really macro level, one medium level, and one micro-level. The professionals have done this for games like Age of Empires. It just depends on what your needs are.

 

,就是这样。与往常一联系到我:

Well, that's it. As always, I can be reached at:

 

pwlester@policyalmanac.org

 

在此之前,祝你好运!

Until then, good luck!

 

© 著作权归作者所有

如比如比
粉丝 126
博文 178
码字总数 286951
作品 0
日本
程序员
私信 提问
再译《A *路径搜索入门》之流畅版??

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

放个屁
2015/06/17
210
0
去吧,去抓住一颗流星(GO, and catch a falling star)

约翰·邓恩(John Donne,1572-1631)的《去吧,去抓住一颗流星》(GO, and catch a falling star),是所有选本必选的英语名诗。昨天,我想找这首诗的中译,在网上怎么也找不到。那么,我就...

阮一峰
2006/08/18
0
0
jfinal 上传文件的相对路径问题

@JFinal 你好,想跟你请教个问题: 下面是jfinal中处理上传文件保存路径的代码片段, 在项目中设置保存文件的相对路径为file home后,得到的路径是如下路径: D:\aaa\bbb\file home\file home ...

JerryYux
2015/01/28
5.3K
3
再译《A *路径搜索入门》之五

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

放个屁
2015/06/11
71
0
FOSCommentBundle功能包:与FOSUserBundle集成(投票)

原文出处:12c-integrationwith_fosuserbundle.md 原文作者:FriendsOfSymfony 授权许可:创作共用协议 翻译人员:FireHare 校对人员: 适用版本:FOSCommentBundle 2.0.5 文章状态:草译阶段...

firehare
2013/07/29
0
0

没有更多内容

加载失败,请刷新页面

加载更多

什么样的人要学点python编程?请你对号入座

什么样的人需要学点python编程? 时代越来越不一样了,编程这种专业程序员的工作,已经开始应用于各种其他日常工作中,就以前象征着互联网的电脑,现在早已进入普通人家。 那么什么样的人需要...

这人就爱编程
13分钟前
2
0
哪吒之魔童降世的背景音乐怎么提取 视频中提取音频的方法

随着国漫的不断崛起一大批优质的动漫正向我们袭来,从大鱼海棠到大圣归来再到我们现在的哪吒让我们看到国漫质的飞跃,也让我们对国漫充满信心,前段时间哪吒之魔童降世以国产第二的票房下线到...

cenfeng123
16分钟前
2
0
springcloud 整合 springboot-admin 监控中心

Admin监控应用 Spring Boot提供的监控接口,例如:/health、/info等等,实际上除了之前提到的信息,还有其他信息业需要监控:当前处于活跃状态的会话数量、当前应用的并发数、延迟以及其他度...

java框架开发者
18分钟前
1
0
GMAT阅读提分要看课外读物,名师点评正确使用方法

阅读提分需要从积累阅读量开始,这种积累不能只靠做练习,还需要大量阅读课外读物。而最适合GRE考生的课外读物之一就是原版杂志。但看课外读物提分也要讲究方法。下面小编就为大家详解看课外...

bole6
21分钟前
1
0
第六次读Kingfisher网络图片缓存库的思考与感受(稍微有点起色)

这节我们来优化一下之前的 硬盘存储,看看kingfiisher哪里做得好,我们稍微来学习一下。 从硬盘里检索图片模仿改进: open func retrieveImageInDiskCache(forKey key: String, options:...

T型人才追梦者
21分钟前
1
0

没有更多内容

加载失败,请刷新页面

加载更多

返回顶部
顶部