astar.h

来自「A*算法」· C头文件 代码 · 共 48 行

H
48
字号
// AStar.h: interface for the CAStar class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_ASTAR_H__FED2D936_0161_4933_843F_0A0D71660839__INCLUDED_)
#define AFX_ASTAR_H__FED2D936_0161_4933_843F_0A0D71660839__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "WayPoint.h"
#include <vector>

struct SASNode
{
	int x;
	int y;
	bool bIsOpen;
	bool bIsClose;
	int ParentIndex;
	int H;//预计到目标点的距离
	int G;//沿路径从起始点到当前点的移动耗费
	int F;//G+H
	int NeighborCount;
	int Neighbor[10];//最多可以有10个邻居
	int NeighborDistance[10];//到每个邻居的距离
};

class CAStar  
{
public:
	CAStar();
	bool FindPath(int FromIndex,int ToIndex);
	int GetNodeIndex(int pathIndex);
	int GetNodeCount();
	void InitNodeByWayPoint(CWayPoint *pWayPoint);
	virtual ~CAStar();
private:
	SASNode *pASNode;
	int PathPointCount;//找到的路径上的路点数
	int NodeCount;
	std::vector<int>OpenList;
	std::vector<int>PathList;
};

#endif // !defined(AFX_ASTAR_H__FED2D936_0161_4933_843F_0A0D71660839__INCLUDED_)

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?