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

📄 nodestate.h

📁 人工智能中经典算法-宽度搜索和启发是搜索(A*算法)在VC环境下的实现代码
💻 H
字号:
// NodeState.h: interface for the CNodeState class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_NODESTATE_H__B8B8864A_3FC6_49D9_B7CE_1D0E1B7D17DA__INCLUDED_)
#define AFX_NODESTATE_H__B8B8864A_3FC6_49D9_B7CE_1D0E1B7D17DA__INCLUDED_

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

///////////////////////////
typedef CPoint		Position;
typedef CPtrList	List; 
typedef int			DataType;
//////////////////////////

#define WM_ERROR	WM_USER+1
//////////////////////////
#define Up		0
#define Right	1
#define Down	2
#define Left	3 
///////////////////////////
#define NoError		0L
#define ErrorCode	1L
#define ErrorCode1	2L
#define ErrorCode2	3L
#define ErrorCode3	4L
///////////////////////////
#define MaxItem		3
#define Blank		0
///////////////////////////
#define Cannot		0
#define NotYet		1
#define AlReady		2
///////////////////////////
#define MaxNodeNo	5000

class CNodeState  
{
public:
	CNodeState();
	virtual ~CNodeState();
private:
	void	FindBlankPosition();
private:
	int			m_CurrentG;//当前节点的G值
	int			m_CurrentCount;//当前节点的计数,便于显示
	int			m_NodeData[3][3];//当前节点的数码数据
	BOOL		m_bAnswer;//是否正解
	UINT		m_NodeType;//节点类型
public:
	int			GetCurrentCount();//取得节点计数值
	void		SetCurrentCount(int Count);//设置节点计数值
	BOOL		GetIsAAnswer();//该节点是否是解
	int			GetCurrentG();//取得当前G值
	void		SetCurrentG(int CurG);//设置当前节点G值
	void		SetNodeType(UINT nodeType);//设置节点类型
	UINT		GetNodeType();//取得节点类型
	void		SetThisIsAAnswer();//设置该节点是正解
	BOOL		IsEqual(CNodeState *Item);//判断Item节点是否与当前节点相等
	bool		IsEqual(int goalstate[3][3]);
	int			GetNodeData(int i,int j);//取得节点状态表示
	Position	GetBlankPosition();//取得空白位位置
	void		MoveBlank(UINT MoveDirection);//根据MoveDirection移动当前状态在的空白位
	void		LoadData(CNodeState *Item);//从Item节点中Copy状态值到当前节点
	void		LoadData(int Data, int i, int j);//获得i,j位位的状态具体值
protected:
	Position	m_BlankPosition; //空白位位置	


};

#endif // !defined(AFX_NODESTATE_H__B8B8864A_3FC6_49D9_B7CE_1D0E1B7D17DA__INCLUDED_)

⌨️ 快捷键说明

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