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

📄 go.h

📁 围棋人机对弈程序源码 此版本目前还只能下布局阶段
💻 H
字号:
#pragma once

#define HUMAN 0 //棋手下棋状态
#define COMPUTER 1 //程序下棋状态
#define CLOSED 4 //关闭状态

#define BLACK 0 //黑棋
#define WHITE 1 //白旗
#define BLANK 2 //空白
#define FRAME 3 //棋盘外

#define UP 0 //上方
#define DOWN 1 //下方
#define LEFT 2 //左方
#define RIGHT 3 //右方
#define LTOP 4 //左上
#define RTOP 5 //右上
#define LBOT 6 //左下
#define RBOT 7 //右下

#define PROLOG 0 //序盘定式阶段

//动态整数集合类
struct IntElement
{
	int num;
	struct IntElement* next;
}typedef IntElem;

class CIntGather
{
public:
	CIntGather();
	~CIntGather();
	
	IntElem* head;//表头
	int length;//长度

	void Add(int elem);
	void Remove(int elem);
	void Reset();
};


//棋串类
class CGoString
{
public:
	CGoString(int n,int c);
	
	int nColor;//棋串颜色,黑0白1
	CIntGather Nodes;//子列表
	CIntGather Breaths;//气列表
    int nEyesNumber;//眼数
};


//动态棋串集合类
struct GoStringElement
{
	CGoString* pString;
	struct GoStringElement* next;
}typedef GoStrElem;

class CGoStringGather
{
public:
	CGoStringGather();
	~CGoStringGather();

	GoStrElem* head;
	int length;

	void Add(CGoString* elem);
	void Remove(CGoString* elem);
	void Reset();
};


//定式类
class CGoForm
{
public:
	CGoForm();
	~CGoForm();

	_ConnectionPtr pConn;//数据库连接对象指针
	_RecordsetPtr pRecs;//记录集对象指针

	int nFormState[4];//四角定式状态
	CString sFormSteps[4];//四角定式步骤
	int nActiveForm;//当前定式区

	CString MapTo(int n,int dir);//将棋步映射为用dir坐标系表示的字符串
	int MapFrom(CString s,int dir);//将用dir坐标系表示的字符串映射为棋步
	CString Symmetrical(CString str);//获得某行棋步骤的对称步骤
	int CheckForm(CString str);//检查某行棋步骤是否依照定式
    void GetFormNextSteps(CString str,CString term,int dir,CIntGather* pResult);//获得满足条件的下一步定式走法列表    
	void UpdateFormState(int n,int color);//更新定式状态
	int ChoseFormStep(int color);//选择定式下法
};


//棋局类
class CGo
{
public:
	CGo();
	~CGo();

    CGoString* pHolder[361];//棋盘各点所属串的指针列表
    CGoStringGather Strings;//各棋串列表
    int nSteps;//落子步数
	int StepList[1000];//棋步列表
	int nHotPlace;//打劫位置
	int nStage;//棋局阶段标志
	CGoForm* pForm;//定式类指针

	void Reset();//重开新局
	int Check(int n,int dir);//检查n点周边状态
	int KillString(int n);//杀掉棋串
	void JoinString(int n,int m);//合并棋串
	int CanGo(int n);//判断是否合法落子点
	void Go(int n);//落子并更新棋局
	void ReGo();//悔棋一手
	int ComputerChoice();//电脑选步
};

⌨️ 快捷键说明

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