|
dl
|
A星寻路算法 更多...
#include <dl_astar.h>
类 | |
| class | AStarNode |
| class | AStarPriorityQueue |
Public 类型 | |
| using | AStarPoint = T |
| using | AStarCost = COST |
| using | FuncCost = std::function<AStarCost(const AStarPoint&, const AStarPoint&)> |
| using | FuncLink = std::function<void(AStar*, const AStarPoint&)> |
Public 成员函数 | |
| AStarPoint | AbsPoint (const AStarPoint &a, const AStarPoint &b) |
| AStarCost | AStarGetH (const AStarPoint &p0, const AStarPoint &p1) |
| 默认获取H方法 | |
| AStar (const AStarPoint &size, FuncCost func_g, FuncCost func_h=nullptr, FuncLink func_link=nullptr, size_t max_node=10000) | |
| 定制一个A星寻路 | |
| void | SetSize (const AStarPoint &size) |
| bool | Search (const AStarPoint &source, const AStarPoint &target, bool target_near, std::list< AStarPoint > &list_path, std::list< AStarPoint > *fail_path=nullptr) |
| 搜索 | |
| void | AddNode (const AStarPoint &xy, AStarCost k_cost) |
| 添加节点(在func_link回调函数使用) | |
| void | SetLinkDiagonal (bool diagonal) |
| 设置是否对角线可走(使用默认连接函数才有效) | |
| void | SetFuncLink (FuncLink func_link) |
| 修改连接函数 | |
| ~AStar () | |
静态 Public 成员函数 | |
| static bool | AStarNodeCompare (AStarNode *n1, AStarNode *n2) |
在文件 dl_astar.h 第 39 行定义.
在文件 dl_astar.h 第 37 行定义.
| using dl::AStar< T, COST >::FuncCost = std::function<AStarCost(const AStarPoint&, const AStarPoint&)> |
在文件 dl_astar.h 第 40 行定义.
| using dl::AStar< T, COST >::FuncLink = std::function<void(AStar*, const AStarPoint&)> |
在文件 dl_astar.h 第 41 行定义.
|
inline |
定制一个A星寻路
| [in] | size | 地图大小,传0不检查 |
| [in] | func_g | 估价g函数(从p0点到p1点实际代价,一般取p1的代价值,p0与p1应为相邻节点) |
| [in] | func_h | 估价h函数(从p0点到目标点估计代价,一般为距离) |
| [in] | func_link | 连接函数(加入节点的相邻节点) |
| [in] | max_node | 节点上限(超过返回失败) |
在文件 dl_astar.h 第 130 行定义.
在文件 dl_astar.h 第 319 行定义.
|
inline |
在文件 dl_astar.h 第 99 行定义.
|
inline |
|
inline |
|
inlinestatic |
在文件 dl_astar.h 第 55 行定义.
|
inline |
搜索
| [in] | source | 起始点 |
| [in] | target | 目标点 |
| [in] | target_near | 如果为真,在相邻目标点就返回路径,而不考虑目标点是否可通行 |
| [out] | list_path | 返回路径,包含首尾节点(target_near为真时,不返回尾节点) |
| [out] | fail_path | 寻路失败时返回的部分路径 |
| 是否成功 |
在文件 dl_astar.h 第 166 行定义.
|
inline |
修改连接函数
在文件 dl_astar.h 第 313 行定义.
|
inline |
设置是否对角线可走(使用默认连接函数才有效)
在文件 dl_astar.h 第 304 行定义.
|
inline |
在文件 dl_astar.h 第 152 行定义.