[Astar_algorithm05]技术文档_A_star
Posted AIplusX
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了[Astar_algorithm05]技术文档_A_star相关的知识,希望对你有一定的参考价值。
- @file: A_star.h
- @brief:A_star类用法的注意事项
- @author:AIplusX
- @version:beta_v0.0
- @date:2021_11_15
- @update:2021_11_15
- @warning:offset_x和offset_y数组的大小有2种形式,大小分别是4和8,分别对应宏定义的曼哈顿距离和欧几里得距离,因为曼哈顿距离只走4个格子,而欧几里得距离要走8个格子,所以在显示算法的时候env_nums要进行更改(曼哈顿距离是4,欧几里得距离是8)。在记录探索和轨迹路径的时候,作者是在堆里面申请的内存,所以vector里面存的都是指针,指向堆里的内存
- @todo:无
#pragma once
#include "Graph.h"
#include <vector>
//#define Manhattan_Distance 0
#define Euclidean_Distance 1
#define MIN(x,y) ((x) >= (y) ? (y) : (x))
class Graph;
class A_star
{
public:
A_star() {};
~A_star();
void Astar_algorithm();
bool judge_env_legal(const Point&);
int calcu_Hn(const Point&);
int calcu_Gn(const Point&);
int calcu_cost(const Point&, const Point&);
void set_start_end_obs_map(Graph&);
void add_openset(Point* p) { openset.push_back(p); };
void add_fatherset(Point* p) { fatherset.push_back(p); };
void delete_openset(const int& idx) {openset.erase(openset.begin() + idx);};
void search_env_block(Point*);
void calcu_type_selection(int&, const int&, const int&);
void show_para_below(Point*);
bool is_alread_set(std::vector<Point*>&, Point*);
void get_trajectory(const Point*);
UserPara get_astar_userpara();
Point* find_min_Fn(int& idx);
private:
int cross_cost = 14;
int plane_cost = 10;
std::vector<Point*> openset;
std::vector<Point*> fatherset;
//std::vector<Point*> trajectory;
std::vector<Point*> obstacleset;
Point start;
Point end;
UserPara user_trajectory;
const int env_nums = 8;
//int offset_x[4] = {0, 1, 0, -1};
//int offset_y[4] = {-1, 0, 1, 0};
int offset_x[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
int offset_y[8] = { -1, -1, -1, 0, 1, 1, 1, 0};
};
以上是关于[Astar_algorithm05]技术文档_A_star的主要内容,如果未能解决你的问题,请参考以下文章
[Astar_algorithm04]A_star类与Astar_algorithm函数
[Astar_algorithm01]A*算法伪代码以及思路