⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 astar.h

📁 A*算法
💻 H
字号:
// 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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -