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

📄 data.c

📁 牛角棋的源码
💻 C
字号:

//data.c

#include <stdio.h>

/*
************************************************************************
Board representation
************************** 
				0
				| \
				|  1
				| /\
				|/  \
				2─━3			Assigned a number N
				|  /|			associated with
				| / |			each intersection
				|/  |
				4─━5			on board
				|  /|
				| / |
				|/  |
				6─━7
				|  /|
				| / |
				|/  |
				8─━9

				︱‖∥∕/\﹨∥∣
	Here, we track the position by recording each stone's intersecion on 
board. The structure stoneIntersection[] is initialized by the initial 
position.
*************************************************************************
*/
int stoneIntersection[3] = {0, 8, 9};


/*
************************************************************************
Pre-table for move generation
******************************
	preTable[color][from][moveIndex]= to, to ∈[0, 9]. 
	1) In this table, a valid move is represented by a number between 
0 and 9; the value INV means no more moves.
	2) Where, color == 0, red stone moves pre-table; color == 1, blue
stone moves pre-table.
*************************************************************************
*/
#define INV		-1

//对照上面的棋盘编码图,并参照牛角棋的规则,可有如下预置表
int preTable[2][10][5] =
{
	{	/*red stone moves table*/
		{2, 1, INV},		{2, 3, 0, INV}, 
		{4, 3, 1, 0, INV},	{5, 4, 2, 1, INV}, 
		{6, 5, 3, 2, INV},	{7, 6, 4, 3, INV},
		{8, 7, 5, 4, INV},	{9, 8, 6, 5, INV}, 
		{9, 7, 6, INV},		{8, 7, INV},
	},
	{	/*blue stone moves table*/
		{INV},			{0, INV}, 
		{3, 1, 0, INV},		{2, 1, INV}, 
		{2, 3, 5, INV},		{3, 4, INV},
		{4, 5, 7, INV},		{5, 6, INV}, 
		{6, 7, 9, INV},		{7, 8, INV},
	},
};


/*
************************************************************************
Global data for search
*************************************************************************
*/
#define   MAXDEPTH   100
int moveList[1024];			//着法列表
int* pList[MAXDEPTH+2];			//各层着法列表的首地址
int maxDepth;				//当前的最大搜索深度
int bestRootMove;
int rootAlpha;
int rootBeta;


/*
************************************************************************
repetition detected
*************************************************************************
*/
int  posStack[MAXDEPTH];		//保存历史局面,用于探测循环


/*
************************************************************************
Other global data
*************************************************************************
*/
int			side;		//哪一方
int			newGame;		

FILE		*inputStream;
char		*args[256];
int		nArgs;
char		buffer[512];
char		cmdBuffer[4096];
unsigned int	timeRemaining;		//本方剩余的总时间
unsigned int	oTimeRemaining;		//对手剩余的总时间
int		traceOut = 1;

⌨️ 快捷键说明

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