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

📄 aiantdlg.h

📁 本程序实现了在一个二维的网格模型中
💻 H
字号:
// AIAntDlg.h : header file
//

#if !defined(AFX_AIANTDLG_H__4F1DBD88_4F2E_4E81_8706_68483DA8A6C3__INCLUDED_)
#define AFX_AIANTDLG_H__4F1DBD88_4F2E_4E81_8706_68483DA8A6C3__INCLUDED_

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

/////////////////////////////////////////////////////////////////////////////
// CAIAntDlg dialog

class CAnt
{
private:
	int dir;//蚂蚁方向,1 东,2 南,3 西,4 北
	int pos;//蚂蚁位置 1~144;	
	int trydir;//蚂蚁试探过的方向, 0 没有,1 向左一次, 2 向左两次, 3 向左三次, 4全部走过
public:
    CAnt() {dir=1;	pos=1; trydir=0;};
	int  GetPos(){ return pos; };
	int  GetDir(){ return dir; };	
	int  GetTryDir(){ return trydir;}
	void SetPos(const int p){ pos=p; };	
	void SetDir(const int d){ dir=d; };	
	void SetTryDir(const int d){ trydir=d; };


};

class CGrid
{
private:
	int grid[144];//二维网格,0 代表没有信息素
	              //          1 具有信息素,并状态为"关"
	              //          2 具有信息素,并状态为"开"
	              //          3 具有信息素,状态为"开"并且蚂蚁走过该网格
public:
	CGrid() { ReSet();};
	void ReSet(){ for(int i=0;i<144;i++) grid[i]=0; };
	void Set(const int pos,const int num){ grid[pos]=num; };
	int Get(const int pos){ return grid[pos];};
};





class CAIAntDlg : public CDialog
{
public:
	int antnum;//当前蚂蚁编号
	CGrid grid;
	CAnt ant;
	//CPaintDC *mydc;
// Construction
public:
	void Draw();
	void InitGrid();
	void DrawCutline(CDC *dc,const int x,const int y,const int type);
	                                                            //画图例,x,y为座标,type为类型,
	                                                            //0 为无信息素
	                                                            //1 为有信息素,状态为关
	                                                            //2 为有信息素,状态为开
	                                                            //3 为蚂蚁图例
	                                                            //4,5,6,7 为蚂蚁方向,方向东南西北
                                                                
	void DrawGrid(CDC *dc, const int pos, const int type );//画图,pos为位置,type为类型,
	                                                            //0 为无信息素
	                                                            //1 为有信息素,状态为关
	                                                            //2 为有信息素,状态为开
	                                                            //3,4,5,6 为蚂蚁,方向东南西北
	CAIAntDlg(CWnd* pParent = NULL);	// standard constructor
// Dialog Data
	//{{AFX_DATA(CAIAntDlg)
	enum { IDD = IDD_AIANT_DIALOG };
	CButton	m_single;
	CButton	m_reset;
	CButton	m_auto;
	CComboBox	m_aiantchoice;
	//}}AFX_DATA

	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CAIAntDlg)
	protected:
	virtual void DoDataExchange(CDataExchange* pDX);	// DDX/DDV support
	//}}AFX_VIRTUAL

// Implementation
protected:
	HICON m_hIcon;
	// Generated message map functions
	//{{AFX_MSG(CAIAntDlg)
	virtual BOOL OnInitDialog();
	afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
	afx_msg void OnPaint();
	afx_msg HCURSOR OnQueryDragIcon();
	afx_msg void OnClose();
	afx_msg void OnAuto();
	afx_msg void OnReset();
	afx_msg void OnSingle();
	afx_msg void OnTimer(UINT nIDEvent);
	afx_msg void OnSelchangeComboAiant();
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
};

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_AIANTDLG_H__4F1DBD88_4F2E_4E81_8706_68483DA8A6C3__INCLUDED_)

⌨️ 快捷键说明

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