A*算法 c++实现

最近舍友突然说起a*算法 虽然之前看过 但是我发现自己记得不是很清楚了 而且从来没去手动实现过 趁着这次就实现一下加深理解 去网上查了下原理 看了几篇别人的实现 然后按自己理解综合一下写出来记录一下(我参考那篇程序运行有好几个问题,而且运行得出路径也是不对的,不知道他有没跑过的。)
Astar.h

#ifndef ASTAR_H
#define ASTAR_H
#include 
#include 
#include 
#include 
#include
using namespace std;


typedef struct Node
{
    int x,y;
    int g; //起始点到当前点实际代价
    int h;//当前节点到目标节点最佳路径的估计代价
    int f;//估计值
    Node* father;
    Node(int x,int y)
    {
        this->x = x;
        this->y = y ;
        this->g = 0;
        this->h = 0;
        this->f = 0;
        this->father = NULL;
    }
    Node(int x,int y,Node* father)
    {
        this->x = x;
        this->y = y ;
        this->g = 0;
        this->h = 0;
        this->f = 0;
        this->father = father;
    }
}Node;
class Astar{
    public:
        Astar();
        ~Astar();
        void search(Node* startPos,Node* endPos);

        void checkPoit(int x,int y,Node* father,int g);
        void NextStep(Node* currentPoint);
        int isContains(vector* Nodelist ,int x,int y);
        void

你可能感兴趣的:(c++)