文件名称:a_game_road_find
介绍说明--下载内容均来自于网络,请自行研究使用
A*算法是一个求最短路径的函数,为许多即时战略游戏所用刀(或许人家大型的即时战略游戏笔者算法更好,不管它)。它由两个函数组成,一个是评估函数,也就是确定人物移动的下一个位置必须离目标位置最近,评估函数评估的结果越精确,则寻径的速度越快;另一个就是寻径函数,也就根据评估的结果做出响应,然后从新位置继续评估下一个位置,若无路可走(四周都是障碍什么的),那么折回一个路径节点,尝试其他方向,这个算法有个缺点,随着游戏中人物增多,相应的处理节点就增多了,会影响处理速度,而且占用大量的内存。
有兴趣的朋友可以改成动态的寻径,就是当入口和出口位置都在变化的时候进行寻径,这个代码也只有200多行。
我的算法还不能算是最优的,因为评估函数只不过是简单的测试两点距离(这会带来误差),选择离出口最短的且非障碍物的方向,进行下一个路径节点的移动。-A* algorithm is a shortest path function, To many time strategy games as a knife (and perhaps others of immediate large-scale strategy game better writer algorithm, regardless of it). It consists of two components function, a function is to assess, is to determine the movement of people under one location to be away from the target location recently to assess the function of the assessment results more precise, Routing is the faster; Another is the routing function, also based on the results of the assessment to respond, then the new location to continue to assess a position where, if there is no way out (what are surrounded by the barrier), then retrace a path nodes, try other directions, this algorithm has a shortcoming, as the game figures increased, corresponding to the processing nod
有兴趣的朋友可以改成动态的寻径,就是当入口和出口位置都在变化的时候进行寻径,这个代码也只有200多行。
我的算法还不能算是最优的,因为评估函数只不过是简单的测试两点距离(这会带来误差),选择离出口最短的且非障碍物的方向,进行下一个路径节点的移动。-A* algorithm is a shortest path function, To many time strategy games as a knife (and perhaps others of immediate large-scale strategy game better writer algorithm, regardless of it). It consists of two components function, a function is to assess, is to determine the movement of people under one location to be away from the target location recently to assess the function of the assessment results more precise, Routing is the faster; Another is the routing function, also based on the results of the assessment to respond, then the new location to continue to assess a position where, if there is no way out (what are surrounded by the barrier), then retrace a path nodes, try other directions, this algorithm has a shortcoming, as the game figures increased, corresponding to the processing nod
(系统自动生成,下载前可以参看下载内容)
下载文件列表
a_game_road_find.txt