FIVECHESSDLG.H
资源名称:WuZiQi.rar [点击查看]
上传用户:gt3658
上传日期:2022-07-09
资源大小:97k
文件大小:5k
源码类别:
棋牌游戏
开发平台:
Visual C++
- // FiveChessDlg.h : header file
- //
- #if !defined(AFX_FIVECHESSDLG_H__F888AC17_7D22_4BB3_820D_75A90E080BE3__INCLUDED_)
- #define AFX_FIVECHESSDLG_H__F888AC17_7D22_4BB3_820D_75A90E080BE3__INCLUDED_
- #if _MSC_VER > 1000
- #pragma once
- #endif // _MSC_VER > 1000
- #define WM_LIBEN WM_USER + 31
- #include <Afxtempl.h>
- #include "WinXPButtonST.h"
- ////////////////////////////////////////////////////////////////////
- // Author: 楚天追梦
- // Date: 2004.6.30
- // Description: 五子棋人机对战的简单实现
- // Email: lcd5@163.com
- // 评分标准:
- // 成5: 100000
- // 活4、双死4、死4活3: 10000
- // 双活3、活3双活2: 5000
- // 活3死3: 1000
- // 死4: 500
- // 单活3: 200
- // 双活2: 100
- // 双死3: 50
- // 单活2: 10
- // 单死3: 5
- ////////////////////////////////////////////////////////////////////
- class Step
- {
- public:
- Step():x(0),y(0),side(0),deep(0)
- {
- }
- //x,y表示在数组中的位置
- int x;
- int y;
- //side表示下子方
- int side;
- int deep ;
- };
- class GameStatus
- {
- public:
- GameStatus():deep(0),score(0),is_machine(false)
- {
- }
- int deep;
- int score;
- bool is_machine;
- Step st;//当前走步
- int fivearray[20][20];
- };
- /////////////////////////////////////////////////////////////////////////////
- // CFiveChessDlg dialog
- class CFiveChessDlg : public CDialog
- {
- // Construction
- public:
- CFiveChessDlg(CWnd* pParent = NULL); // standard constructor
- // Dialog Data
- //{{AFX_DATA(CFiveChessDlg)
- enum { IDD = IDD_FIVECHESS_DIALOG };
- CWinXPButtonST m_bt_newbegin;
- CWinXPButtonST m_bt_regrete;
- CWinXPButtonST m_bt_begin;
- CComboBox m_combox;
- CButton m_mainboard;
- //}}AFX_DATA
- // ClassWizard generated virtual function overrides
- //{{AFX_VIRTUAL(CFiveChessDlg)
- public:
- virtual BOOL Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext = NULL);
- protected:
- virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
- virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
- virtual BOOL OnCommand(WPARAM wParam, LPARAM lParam);
- //}}AFX_VIRTUAL
- private:
- //画网格
- void DrawGrid();
- //画棋子
- void DrawChess(CPoint point);
- void DrawChess(int x,int y,bool is_current);
- void DrawAllChess();
- int step_x;
- int step_y;
- //当前走步
- Step m_currentstep;
- //上个走步
- Step oldstep;
- bool flag;
- bool is_myturn;
- bool closeflag;
- //存储棋子布局数组
- int Fivearray[20][20];
- //走步序列
- CList<Step,Step&>StepList;
- NOTIFYICONDATA tnd;
- //判断是否已获胜
- bool IsSuccess();
- //从左到右相同棋子数
- int LeftRight(int i, int j,int side);
- //从上到下相同棋子数
- int UpDown(int i, int j,int side);
- //从左上到右下相同的棋子数
- int LupToRdown(int i, int j,int side);
- //从右上到左下的相同棋子数
- int RuptoLdown(int i, int j,int side);
- //搜索左到右棋子的状态
- int LeftToRight_Status(int i, int j ,int arrray[][20]);
- //搜索出上到下的状态
- int UpToDown_Status(int i, int j ,int arrray[][20]);
- //搜索出左上到右下的状态
- int LeftUpToRightDown_Status(int i, int j ,int arrray[][20]);
- //搜索出左下到右上的状态
- int LeftDownToRightUp_Status(int i, int j ,int array[][20]);
- //返回当前状态的分数
- int SearchValue(int array[][20],Step &st,bool machine);
- //返回当前棋盘的分数
- void GetCurrentScore( GameStatus &board_situation);
- //返回对仅当前棋盘分析得出的最好走步
- int SearchMaxValue(Step &st,int array[][20]);
- //递归搜索最好走步
- int DeepSearch(GameStatus ts,Step &st,bool machine,int value);
- // Implementation
- protected:
- HICON m_hIcon;
- // Generated message map functions
- //{{AFX_MSG(CFiveChessDlg)
- virtual BOOL OnInitDialog();
- afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
- afx_msg void OnPaint();
- afx_msg HCURSOR OnQueryDragIcon();
- afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);
- afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
- afx_msg void OnBegin();
- afx_msg void OnRegret();
- afx_msg void OnNewBegin();
- afx_msg void OnTimer(UINT nIDEvent);
- afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
- afx_msg void OnDestroy();
- afx_msg LRESULT OnLiben(WPARAM wParam,LPARAM lParam);
- afx_msg void OnClose();
- afx_msg void OnMenucancel();
- afx_msg void OnMenuOPen();
- //}}AFX_MSG
- DECLARE_MESSAGE_MAP()
- };
- //{{AFX_INSERT_LOCATION}}
- // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
- #endif // !defined(AFX_FIVECHESSDLG_H__F888AC17_7D22_4BB3_820D_75A90E080BE3__INCLUDED_)