资源简介
Python版的A*寻路算法,实现了基本的A*算法,可以显示寻路图
代码片段和文件信息
“““{-
Copyright (c) 2009 Pauli Henrikki Rikula
Permission is hereby granted free of charge to any person
obtaining a copy of this software and associated documentation
files (the “Software“) to deal in the Software without
restriction including without limitation the rights to use
copy modify merge publish distribute sublicense and/or sell
copies of the Software and to permit persons to whom the
Software is furnished to do so subject to the following
conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS“ WITHOUT WARRANTY OF ANY KIND
EXPRESS OR IMPLIED INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM DAMAGES OR OTHER LIABILITY
WHETHER IN AN ACTION OF CONTRACT TORT OR OTHERWISE ARISING
FROM OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
-}“““
import heapq
class NotImplemented(Exception):
pass
class Map:
def __init__(self):
pass
def heuristic_estimate_of_distance(self startgoal):
raise NotImplemented
def neighbor_nodes(self x):
raise NotImplemented
def dist_between(self x y):
raise NotImplemented
def reconstruct_path(came_from current_node):
if current_node in came_from:
p = reconstruct_path(came_fromcame_from[current_node])
return p + [current_node]
else:
return []
class HeapItem:
def __init__(selfygoal a_map):
self.node = y
“““f_score Estimated total distance from start to goal through y.“““
self.f_score = None
“““ g_score = Distance from start along optimal path.“““
self.g_score = None
“““h_score the heuristic estimates of the distances to goal“““
self.h_score = a_map.heuristic_estimate_of_distance(y goal)
def set_scores(selfg_score):
self.g_score = g_score
self.f_score = self.h_score + self.g_score
def as_list(self):
return [self.f_score self.g_score self.h_score self.node]
def __repr__(self):
return str(self.as_list())
def type_check(selfother):
return type(self) == type(other)
def __lt__(self other):
return self.type_check(other) and self.as_list().__lt__(other.as_list())
def __le__(self other):
return self.type_check(other) and self.as_list().__le__(other.as_list())
def __eq__(self other):
return self.type_check(other) and self.as_list().__eq__(other.as_list())
def __ne__(self other):
return self.type_check(other) and self.as_list().__ne__(other.as_list())
def __gt__(self other):
return self.type_check(other) and self.as_list().__gt__(other.as_list())
def __ge__(self other):
return self.type_check(other) a
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 2218 2009-02-18 00:42 pathFinder.py
文件 254 2009-02-18 00:43 a_map.txt
文件 5063 2009-02-18 00:42 a_star.py
----------- --------- ---------- ----- ----
7535 3
- 上一篇:ISO7816 协议标准
- 下一篇:操作系统循环首次适应算法
相关资源
- A Pathfinding Project Pro v4.2.2.rar
- unity寻路插件:A*Pathfinding
- A*DijkstraBFS路径搜寻算法演示程序
- 简单A*算法罗马尼亚度假问题
- UNITY自动寻路插件 A* Pathfinding Project
- A*算法和基于深度优先的八数码问题
- ARA* AD*室内机器人导航算法研究
- 基于稀疏A*航迹规划算法
- A星算法实现路径规划
- A*算法解决旅行商问题
- 智能寻路贪吃蛇 AI
- Qt实现的迷宫游戏_源码生成+寻路
- Astar寻路算法
- a* 算法 人工智能 拼图游戏
- NavMesh 2D.unitypackage
- 十进制加法器课程设计常规型微程序
- 2.5D 地图Staggered Diamond Slide 坐标换算及
- SimplePath 1.11(最新完整版)
- 寻路测试2可执行
- Unity3D实现的角色攻击、移动待机死亡
- A星寻路插件
- unity的Navigation寻路完整的.
- 搜索算法演示程序
- Qt实现的迷宫游戏_可执行程序迷宫生
- 模拟红蓝军对战程序
- A*算法旅行商问题实验报告和代码
- 游戏编程中的寻路算法研究
- A*算法的具体思想我见过的写的最好的
- 一种基于A* 算法的动态多路径规划算
- cocos2dx +lua 斜45度A星寻路算法
评论
共有 条评论