(Ancient heritage) AStar heuristic function design

As the first post I'm coming out, how they have to write an article worthy of my identity and status of the article, right?
First let me Tucao about careless hair texture, but I do not care that the collection of curriculum class brothers next door so you do not I feel very passionate BB pressure, volume, ado, immediately get to the bar.
briefly about the AStar algorithm, which is a prototype of traversal algorithm based on heuristic function diagram, For chestnuts, but you if you're in a maze know the direction of the outlet, then you should try to export the way forward, then, the first heuristic function was determined, remove the points around to determine how far from the exit of each point according to a Euclidean distance calculation, thereby select a point short distance move, this is a guiding algorithm inspired by the model function, if do not know what the venue is the heuristic search to Baidu Encyclopedia http://baike.baidu.com/link?url = tHf4ILIGdRGAgQwAnRPGdy8aSQ66aa5cx5iiWxyveoukKN9Fq2FJ6osqqK0x_IOCMHsgXPAePQLYbsN278sLWq
good drops, in fact, the above only as an understanding of their own to make Hello everyone understand what I next want to clarify is off What, if not a computer professional students see here, please skip to the bottom by consciously see legend to feel the charm of heuristic search of it (laughs).

Usually the A * algorithm

    通常的A*算法主要有两种估值函数,曼哈顿距离以及距离消耗步数进行结合,最终得到权值F可以做为下一步将要移动的位置,举个图例就是: 
                   
    注:右图左上角为图形边界30*30,右下角为搜索次数,起始点为(12,5),终止点为(12,24).最终搜索到的点为423*4(最大值).

According to the chart we can see, usually A wayfinding can get the shortest path, but my idea here is to find its way in the game application in order to achieve this I had to make some sacrifices.
In doing this optimization when the first original ! bar is adjusted on the basis of
base a
heuristic function F = G + H used;
G = number of steps to move needed to go where,
H = ABS (this-> X - Goal.x) + ABS (the this -> Y - Goal.y);
. // the this point is a current position, which contains X, Y coordinate information, as it points to. goal target point
so according to this F (x, y) we obtain the FIG. searches, followed by the first optimization simple, first we construct a priority queue to enter all the search teams in turn arranged according to F value, then this can increase the proportion of H values, so that searches toward the target direction to reduce point into the team, need to know is that every time the search to a point when it means that there is likely to be the point of not more than 4 (movement direction based on 4) expand search of the point, which is the direction of optimization, reducing point enter the priority queue, in order to improve search efficiency. so what I'm doing first priority . Of
F = sideMAX * H + G; // sideMAX two boundary large value
then the result of this time is as follows:
Again a chestnut FIG it ~

At this point, the search will be more inclined to point to the neglect of the G target value to some extent, so the search will be emphasized in the general direction, thus completing the first optimization, gratifying gratifying.
But I do not think so so that everyone can be satisfied, and I made up as so confident, it is certainly a bit small 99 friends.
first of all I would like to point out, Manhattan distance H = abs (this-> x - Goal.x) + abs (this-> y - Goal.y); not sensitive to target distance, because its value is presented diamond distribution point spread outwardly by the target, then this means that the distance a side of rhomboid equivalent, when the mobile this diamond will all have a side entry priority queue, then how to do it? (Note: All points below constitute the side length of the diamond called the equivalent points)
first, the replacement of the Manhattan distance calculation, it is replaced by Euclidean distance (simple point that is in the plane rectangular coordinate distance between two points based formula)
D = sqrt (POW (Goal.x - this-> X, 2) + POW (Goal.y - this-> Y, 2)); // sqrt is the square root, pow (X, 2) for the X ^ 2 side.
However, this egg, what use is it? first of all, according to Euler obtained from the equivalent point different from Manhattan Diamond, it looks better, like a circle of diffusion of a circular by the target point out.

Let's look at it!

These are the case where the Manhattan distance value

continue!

The following is a case of Euclidean distance value

 ![](https://img2018.cnblogs.com/blog/1641852/201909/1641852-20190902210533619-1385322538.png)

    你会发现有一些些不同,首先欧拉数据类型比较小,存在浮点数,这就导致了它不能和G值共存(忘了G值意义的往回看看),而曼哈顿为整数,呈现出有棱有角的形式.从图上看欧拉距离更趋近于圆形而非菱形,这就导致了在一些凹障碍的时候,两个的表示会不太一样,现在我们看看接下来的优化,好滴,这就再举个栗子!
左图为F = G + sideMAX * H, 右图为F = D;

Starting point for the (12,10), the termination point (12, 24).

             ![](https://img2018.cnblogs.com/blog/1641852/201909/1641852-20190902210540292-1176282956.png) ![](https://img2018.cnblogs.com/blog/1641852/201909/1641852-20190902210545770-1846359370.png)




    接着简单说明一下两者的区别的各个的优势,这也是我发这篇文章的最最主要的目的,先看左图搜索次数,其上图表示搜索了点的分布情况,这里我们在其右下角有一个路线的统计,这个196是统计着所有搜索过的路径,简单点看图,对,就左图中上图的方块数量,那个数量就等同于该值,这就可以作为两者的效率的一种简单的比较了(请允许我不用O(N)之类的说法),那么开始好好说明一下吧~    

Efficiency right than on the left is much faster, but because it is not supporting the use and value of G can not be led to its shortest path, which is the difference between the two, as pointed above left, that is generated from the Manhattan diamond as a result, and here I optimize the next step -

Specific heuristic function, it is left to the students want to know it = - =, although I'm not sure there are a few students would like to study this kind of stuff you, but as I began coming out, how they have to show for point stuff it - there are some follow-up research on a shelf, and I have to be able to determine the results down further issue come up to me = - = ~

Guess you like

Origin www.cnblogs.com/juwan/p/11449030.html