?? fivedlg.h
字號:
// fiveDlg.h : header file
//
#if !defined(AFX_FIVEDLG_H__49B1B579_34FE_4FB1_B11E_2DB8C76B45CC__INCLUDED_)
#define AFX_FIVEDLG_H__49B1B579_34FE_4FB1_B11E_2DB8C76B45CC__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
/////////////////////////////////////////////////////////////////////////////
// CFiveDlg dialog
//只需要設置N就可以,必須時奇數,且小于等于15!!!!!!!!!
//其余項自動會設置.
#define N 15 //棋盤格子行列數
//以下各項自動設置
//----------------------------------------------------------------------------/
#define WIN 2*N*(N-4) + 2*(N-4)*(N-4) //獲勝棋局的種數
#define CENTER N/2 //棋盤中心
#define CHESSSUM N*N //棋子總數
#define WIDTH N*40 //棋盤寬
#define HEIGHT N*40 //棋盤高
//----------------------------------------------------------------------------/
struct XLIMIT
{
char left , right;
};
struct YLIMIT
{
char top , bottom;
};
class CFiveDlg : public CDialog
{
// Construction
public:
CFiveDlg(CWnd* pParent = NULL); // standard constructor
CDC *mdc,*mdc1; //內存DC
CBitmap *purple,*green,*bgbmp,*temp;//分別是棋子,棋盤位圖和內存DC使用的虛擬位圖
char board[N][N]; //棋盤,0表示玩家的棋子,1表示電腦的,2表示未被落子的位置
bool ptable[N][N][WIN]; //記錄每個棋子是否在玩家的獲勝組合中
bool ctable[N][N][WIN]; //記錄每個棋子是否在電腦的獲勝組合中
char win[2][WIN]; //記錄每種獲勝組合中已經擁有的棋子,如果是5則勝,是7則表示不能完成這種組合
int pcount,ccount; //玩家和電腦各下了多少步棋
bool player,computer,start,over,pwin,cwin,tie;
int k,m,n,count;
int cutnum; //剪枝次數
int calnum; //計算到的棋局數目
bool disScope; //是否顯示搜索范圍
int pWeight[8],cWeight[8]; //計算棋局的評價函數中用到的權值
XLIMIT xlimit[N];
YLIMIT ylimit[N];
int canEnter; //每行記錄四步棋
CString path; //記錄棋譜
int left , right , top , bottom; //當前棋局上棋子的范圍
CPoint searchOrd[N*N]; //存儲搜索的落子順序
int searchSum;
void setSearchOrd(); //設置查找順序數組
void findCPUlast(int &x , int &y); //如果電腦有了活四或沖四,找到這種獲勝組合中的最后一個落子點
void draw(); //屏幕繪制函數
int getMin(int depth , int parentMax);//取得最小值
int getMax(int depth , int parentMin , int &nextx , int &nexty);//取得最大值
bool layCpuChess(int x , int y); //博弈搜索時使用的電腦落子函數
bool layPlayerChess(int x , int y); //博弈搜索時使用的玩家落子函數
void findLastOne(int &x , int &y , int winIndex); //如果玩家有了活四或沖四,找到這種獲勝組合中的最后一個落子點
int putPlayerChess(int x , int y); //玩家的實際落子函數
bool putCpuChess(int x , int y); //電腦的實際落子函數
void init(); //初始化函數,設置獲勝組合數組
int getValue(); //棋局的估價函數
void updateScope(int x , int y);
// Dialog Data
//{{AFX_DATA(CFiveDlg)
enum { IDD = IDD_FIVE_DIALOG };
CProgressCtrl m_progress;
//}}AFX_DATA
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CFiveDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
HICON m_hIcon;
// Generated message map functions
//{{AFX_MSG(CFiveDlg)
virtual BOOL OnInitDialog();
afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
afx_msg void OnPaint();
afx_msg HCURSOR OnQueryDragIcon();
afx_msg void OnTimer(UINT nIDEvent);
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
afx_msg void OnClose();
//}}AFX_MSG
LRESULT OnHotKey(WPARAM wParam , LPARAM lParam);
DECLARE_MESSAGE_MAP()
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_FIVEDLG_H__49B1B579_34FE_4FB1_B11E_2DB8C76B45CC__INCLUDED_)
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -