Click here to Skip to main content
15,881,561 members
Articles / Artificial Intelligence

Nura Othello - A WTL Based Board Game

Rate me:
Please Sign up or sign in to vote.
4.40/5 (14 votes)
6 Feb 2007CPOL23 min read 79.2K   2.3K   29  
An example of using the WTL library in an artificial intelligence game.
///////////////////////////////////////////////////////////////////////////////
// OthelloMFCDlg.h Ver. 1.7		OthelloMFCDlg.h : 헤더 파일
// Programmer: PARK Youngho
///////////////////////////////////////////////////////////////////////////////

#pragma once

#include "afxwin.h"
#include "../OthelloWindowMFC/OthelloWindowMFC.h"
#include "afxcmn.h"

#define ID_OTHELLO		100
#define OTHELLO_IQNUM	OTHELLO_SMART
//#define OTHELLO_IQNUM	4

#define OTHELLO_XWIDTH	OTHELLO_BOARDWIDTH
#define OTHELLO_YWIDTH	OTHELLO_BOARDWIDTH
#define OTHELLO_XSTART	15
#define OTHELLO_YSTART	15
#define OTHELLO_XBUTTON	88
#define OTHELLO_YBUTTON 25
#define OTHELLO_GAP		15

#define LIMITATION			15
#define TIMESTEP			1000
#define TIMEOVER			-1
#define OTHELLO_TIMEOVER	OTHELLO_USER

// COthelloMFCDlg 대화 상자
class COthelloMFCDlg : public CDialog
{
	OthelloWindowMFC*	m_pOthello;
	int					m_Sel;

	CString				m_strStart, m_strCancel, m_strWithdraw;
	CString				m_strComputerFirst, m_strIQ[OTHELLO_IQNUM];
	CString				m_strPlayer[2], m_strError, m_strOthello;
	CString				m_strTimeLimit, m_strWinTimeLimit, m_strLoseTimeLimit;
	CString				m_strWin, m_strLose, m_strDraw, m_strPass, m_strWait;
	CString				m_strNoPlace;

	char				m_FirstPlayer;
	char				m_CountDown;
	bool				m_bMade;
	bool				m_bTimeLimit;

	CButton				m_Start;
	CButton				m_Cancel;
	CButton				m_Withdraw;
	CButton				m_ComputerFirst;
	CButton				m_TimeLimit;
	CStatic				m_Player[2];
	CProgressCtrl		m_Progress;
	CProgressCtrl		m_Elapsed;
	CListBox			m_IQ;

// 생성
public:
	COthelloMFCDlg(CWnd* pParent = NULL);	// 표준 생성자
	~COthelloMFCDlg();

// 대화 상자 데이터
	enum { IDD = IDD_OthelloMFC_DIALOG };

	protected:
	virtual void DoDataExchange(CDataExchange* pDX);	// DDX/DDV 지원


// 구현
protected:
	HICON m_hIcon;

	// 메시지 맵 함수를 생성했습니다.
	virtual BOOL OnInitDialog (void);
	afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
	afx_msg void OnPaint (void);
	afx_msg HCURSOR OnQueryDragIcon();
	afx_msg LRESULT OnOhelloMessage (WPARAM wParam, LPARAM lParam);
	void ReSize (int cx, int cy);

	DECLARE_MESSAGE_MAP()

	void InitStrings (int lang);
	void InitStringKorean (void);
	void InitStringEnglish (void);
	void CommonInitString (LPCTSTR strIQ);

	inline void AdjustWindowRect (HWND hWnd, RECT* pRc)
	{
		LONG	style		= ::GetWindowLong(hWnd, GWL_STYLE);
		LONG	ex_style	= ::GetWindowLong(hWnd, GWL_EXSTYLE);
		::AdjustWindowRectEx(pRc, style, NULL, ex_style);
	}

	inline void KillAllTimers (void)
	{
		for (int id = 1; id <= 60; id++)
			KillTimer(id);
	}

private:
	void OnOthelloUpdate (void);
	void OnOthelloMyStone (void);
	void OnOthelloYourStone (void);
	void OnOthelloPass (LPARAM lParam);
	void OnOthelloFinish (LPARAM lParam);
	void OnOthelloNoPlace (LPARAM lParam);
	void OnOthelloTimeOver (void);

public:
	afx_msg void OnBnClickedStart (void);
	afx_msg void OnBnClickedCancel (void);
	afx_msg void OnBnClickedComputerfirst (void);
	afx_msg void OnBnClickedTimelimit (void);
	afx_msg void OnBnClickedWithdraw();
	afx_msg void OnLbnSelchangeIq (void);
	afx_msg void OnSize (UINT nType, int cx, int cy);
	afx_msg void OnTimer (UINT nIDEvent);
	afx_msg void OnDestroy (void);
	afx_msg BOOL OnHelpInfo(HELPINFO* pHelpInfo);
};

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Korea (Republic of) Korea (Republic of)
I like programming.
I am teaching at AUCA (American University of Central Asia) now.

Comments and Discussions