求一个C++实现黑白棋,要求VC++6.0可以编译通过,要求:
1.至少一个棋盘类,至少有三个成员函数:
构造函数(用来初始化棋盘的每一个元素);
棋盘绘制函数(用来输出棋盘的每一个元素);
放置棋子函数
2.每次放置棋子,重新绘制整个棋盘
3.能够实现两人游戏
參考答案:本程序提供五子棋、黑白棋双人对下的环境,以及黑白棋人机对下的功能。其界面模仿windows, 操作简便,所有操作都通过鼠标完成。
进入程序后,从game菜单可选择游戏的种类,在游戏进行过程中采用鼠标左键下子,右键悔棋。
整个源程序总共由mouse.c、timedate.c、bmp.c、bww.c、bww.prj五个文件组成,约1500余行。其中mouse.c包含鼠标相关的语句;timedate.c用于显示当前的日期与时间;bmp.c用于显示16色位图作为程序的封面以及便于中文的显示;
bww.c是整个程序的核心部分,下面将就bww.c中的各个重要函数作一下简要的介绍:
void init():该函数用于图形以及鼠标的初始化。
void anniu(int x0, int y0, int x1, int y1, int color1, int color2):该函数通过在一块平面区域的四周用两种颜色画线,使之产生凸起或凹陷的立体效果。
void showmenu();
void helpmenu();
void filemenu(); 这五个函数主要用于菜单栏及各级菜单的显示。
void topic();
void about();
void wuziqi():通过调用该函数进入五子棋的双人对下环境。
void heibaiqi():通过调用该函数进入黑白棋的双人对下环境。
void mind2cpu():通过调用该函数进入黑白棋的人机对下环境。
void draw(int type):该函数根据type参数值的不同,画出符合需要的棋盘。
void win(int type, int winner):通过对该函数的调用,显示胜利的信息,并询问接着要执行的操作。
void gameover():通过对该函数的调用,退出本程序。
int xiazi(int xx, int yy, int type):该函数在棋盘坐标为(xx, yy)处下type参数所定义的棋子。
void control(int type):该函数用于五子棋与黑白棋的双人对下环境,通过循环不断地接受鼠标的的按键信息,然后调用相应的函数执行所要求的功能。
void judge():该函数判断棋盘上是否有同种颜色的棋子连成了五颗以上或棋盘以被占满,即判断是否以分出了胜负,还是平手。
void huiqi():该函数用于执行五子棋的悔棋功能。
void hdisplay();
void display();
void copyqipan():该函数将每一步的棋盘状况复制到一个备份数组中,以实现黑白棋的悔棋功能。
int copy_chess (int source[8][8],int dest[8][8]):该函数将前一数组各项复制到后一数组当中。主要用于黑白棋的人工智能。
void hhuiqi(int type):该函数调用display()函数实现黑白棋的悔棋功能。
int hpass(int my_self):该函数判断my_self代表一方是否无处可下,但不在屏幕上显示,主要用于黑白棋的人工智能。
int pass(int turn):该函数判断turn代表一方是否无处可下,并在屏幕上显示“PASS”字样。
long hvalue(int pad[8][8], int turn):该函数根据分值表判断turn这一方在pad[8][8]数组所表示的情况下的的分。主要用于黑白棋的人工智能。
int core_think(int my_self):通过递归调用判断电脑走哪一步最合适,MAXSTEP定义了电脑所想的步数,目前我将其值定为4。
void hjudge():该函数计算棋盘当前状况双方的子数,并显示出来,用于两个黑白棋中。
int change(int cx, int cy, int playerorder, int a):判断playerorder一方在(cx, cy)处下子是否能引起改变,根据a的不同以决定是否要在棋盘上表示出来,用于pass的判断,和显示一方下子所引起的双方棋子的变化。
int try_xy(int x, int y, int chess[8][8], int my_self):判断my_self一方在(x, y)处下子是否能引起改变,将此改变记录在chess[8][8]中。
以上即是bww.c文件中主要函数的介绍。由于黑白棋的人工智能是后来才想到要编的,所以有些函数有些重复,并且黑白棋的人工智能很难达到非常高,我是编了好长时间才作成这一个让我可以接受的程度。而且这种算法的效率也很低,导致当MAXSTEP为5时,电脑每走一步就要等好长时间。希望今后我能够找到解决这些不足的好方法。
代码如下:
bmp.h:
#include<conio.h>
#include<stdio.h>
#include<process.h>
#include<graphics.h>
#include<dos.h>
#include<bios.h>
#include<stdlib.h>
#include<time.h>
struct bmphead{
unsigned char b;
unsigned char m;
unsigned long bfsize;
unsigned int bfresterved1;
unsigned int bfresterved2;
unsigned long bfoffbits;
unsigned long bitsize;
unsigned long bmpwidth;
unsigned long bmpheight;
unsigned int bmpplanes;
unsigned int bmpcount;
unsigned long bmpcompression;
unsigned long bmpimgsize;
unsigned long bmpxpeispermeter;
unsigned long bmpypeispermeter;
unsigned long bmpcirused;
unsigned long bmpimportant;
}bmp;
/*----------------------------------------------------------------------------------------------*/
struct ColorIndex
{
unsigned char Blue;
unsigned char Green;
unsigned char Red;
unsigned char Reserved;
}index[16];
int pageno;
/*==============================================================================================*/
void SetPlate(int ColorIndex,char Red,char Green,char Blue)
{
outportb(0x3c8,ColorIndex);
outportb(0x3c9,Red);
outportb(0x3c9,Green);
outportb(0x3c9,Blue);
}
/*----------------------------------------------------------------------------------------------*/
showbmp(int x,int y,char*filename)
{
FILE *fp;
char c,temp1,temp2;
register int m;
int n;
register unsigned long i=0,j=0;
struct palettetype *sq;
HideCur();
if((fp=fopen(filename,"rb"))==NULL)
printf("can't open file!");
else
{
fread(&bmp,sizeof(struct bmphead),1,fp);
fread(index,sizeof(struct ColorIndex),16,fp);
}
if(bmp.bmpwidth%32==0)
n=bmp.bmpwidth/2;
else n=4+bmp.bmpwidth/2-(bmp.bmpwidth/2)%4;
m=9;
SetPlate(57,index[m].Red,index[m].Green,index[m].Blue);
m++;
SetPlate(58,index[m].Red,index[m].Green,index[m].Blue);
m++;
SetPlate(59,index[m].Red,index[m].Green,index[m].Blue);
m++;
SetPlate(60,index[m].Red,index[m].Green,index[m].Blue);
m++;
SetPlate(61,index[m].Red,index[m].Green,index[m].Blue);
m++;
SetPlate(62,index[m].Red,index[m].Green,index[m].Blue);
m++;
SetPlate(63,index[m].Red,index[m].Green,index[m].Blue);
fseek(fp, bmp.bfoffbits,0);
for(m=0; m<bmp.bmpheight; m++){
j=0;
for(i=0;i<n;i++)
{
c=fgetc(fp);
if(j<bmp.bmpwidth)
{
temp1=(c&0xF0)>>4;
temp2=c&0x0F;
putpixel(x+j,y-m,temp1);
j++;
putpixel(x+j,y-m,temp2);
j++;
}
}
}
fclose(fp);
ShowCur();
}
timedate.c:
#include<dos.h>
#include<graphics.h>
int hour=100, minute=100, second=100;
void timedate(int x, int y, int n)
{
int i, j;
settextstyle(0, 0, 1);
setfillstyle(1, LIGHTGRAY);
bar(x, y, x+16, y+7);
j=n%10;
i=(n-j)/10;
setcolor(BLUE);
switch(i){
case 0: outtextxy(x, y, "0"); break;
case 1: outtextxy(x, y, "1"); break;
case 2: outtextxy(x, y, "2"); break;
case 3: outtextxy(x, y, "3"); break;
case 4: outtextxy(x, y, "4"); break;
case 5: outtextxy(x, y, "5"); break;
case 6: outtextxy(x, y, "6"); break;
case 7: outtextxy(x, y, "7"); break;
case 8: outtextxy(x, y, "8"); break;
case 9: outtextxy(x, y, "9"); break;
}
switch(j){
case 0: outtextxy(x+8, y, "0"); break;
case 1: outtextxy(x+8, y, "1"); break;
case 2: outtextxy(x+8, y, "2"); break;
case 3: outtextxy(x+8, y, "3"); break;
case 4: outtextxy(x+8, y, "4"); break;
case 5: outtextxy(x+8, y, "5"); break;
case 6: outtextxy(x+8, y, "6"); break;
case 7: outtextxy(x+8, y, "7"); break;
case 8: outtextxy(x+8, y, "8"); break;
case 9: outtextxy(x+8, y, "9"); break;
}
}
void dat(int x, int y)
{ int a, b;
struct date d;
getdate(&d);
b=d.da_year%100;
a=(d.da_year-b)/100;
timedate(x, y, a);
timedate(x+16, y, b);
outtextxy(x+32, y, "-");
timedate(x+40, y, d.da_mon);
outtextxy(x+56, y, "-");
timedate(x+64, y, d.da_day);
}
void inittim(int x, int y)
{
struct time t;
gettime(&t);
timedate(x, y, t.ti_hour);
outtextxy(x+16, y, ":");
hour=t.ti_hour;
timedate(x+24, y, t.ti_min);
outtextxy(x+40, y, ":");
minute=t.ti_min;
if(t.ti_sec!=second){
timedate(x+48,y,t.ti_sec);
second=t.ti_sec;
}
}
void tim(int x, int y)
{
struct time t;
gettime(&t);
if(t.ti_hour!=hour){
timedate(x, y, t.ti_hour);
outtextxy(x+16, y, ":");
hour=t.ti_hour;
}
if(t.ti_min!=minute){
timedate(x+24, y, t.ti_min);
outtextxy(x+40, y, ":");
minute=t.ti_min;
}
if(t.ti_sec!=second){
timedate(x+48,y,t.ti_sec);
second=t.ti_sec;
}
}
bww.c:
#include <stdio.h>
#include <graphics.h>
#include <stdlib.h>
#include <alloc.h>
#include <bios.h>
#define PLAYER1 1
#define PLAYER2 -1
#define WUQIZI 0
#define QBLACK 1
#define QWHITE -1
#define WUZIQI 0
#define HEIBAIQI 1
#define MAXSTEP 5
int x, y;
int mx, my, state;
int qx, qy;
int zx[230], zy[230];
int zcount;
int step_now=0;
int qipan[15][15];
int hpad[8][8];
int order;
int hcount;
int hqipan[61][8][8];
int x_now, y_now;
int value[8][8]={
1024,-64,128,128,128,128,-64,1024,
-64,-256,1,1,1,1,-256,-64,
128,1,16,16,16,16,1,128,
128,1,16,1,1,16,1,128,
128,1,16,1,1,16,1,128,
128,1,16,16,16,16,1,128,
-64,-256,1,1,1,1,-256,-64,
1024,-64,128,128,128,128,-64,1024
};
void showmenu();
void helpmenu();
void filemenu();
void topic();
void about();
void anniu(int x0, int y0, int x1, int y1, int color1, int color2);
void wuziqi();
void heibaiqi();
void mind2cpu();
void init();
void draw(int type);
void copyqipan();
long hvalue(int pad[8][8], int turn);
int core_think(int my_self);
void hdisplay();
void display();
int copy_chess (int source[8][8],int dest[8][8]);
int hpass(int my_self);
void hhuiqi(int type);
void control(int type);
int pass(int turn);
int xiazi(int xx, int yy, int type);
void judge();
void huiqi();
void hjudge();
int change(int cx,int cy, int playerorder, int a);
int try_xy(int x, int y, int chess[8][8], int my_self);
void win(int type, int winner);
void gameover();
main()
{
init();
sleep(1);
cleardevice();
InitMouse();
showmenu();
}
void showmenu(){
int n=1;
setfillstyle(1,LIGHTGRAY);
bar(1,1,638,478);
setfillstyle(1,BLUE);
bar(6,5,633,20);
anniu(6,5,633,20,DARKGRAY,WHITE);
setcolor(WHITE);
outtextxy(9,9,"Black and White World");
anniu(1,1,638,478,WHITE,DARKGRAY);
setcolor(BLACK);
outtextxy(12,30,"Game");
outtextxy(65,30,"Help");
outtextxy(118,30,"Exit");
setcolor(DARKGRAY);
line(2, 44, 637, 44);
line(54, 23, 54, 41);
line(107, 23, 107, 41);
setcolor(WHITE);
line(2,45,637,45);
line(55,23,55,41);
line(108,23,108,41);
ShowCur();
anniu(7, 50, 633, 458, BLACK, WHITE);
anniu(445, 464, 535, 475, DARKGRAY, WHITE);
anniu(545, 464, 625, 475, DARKGRAY, WHITE);
showbmp(7,458,"border.bmp");
dat(450, 466);
inittim(550,466);
while(1){
tim(550, 466);
Status(&mx, &my, &state);
if(mx>=8 && mx<=48 && my>=25 && my<=40){
if(state&1){
filemenu();
n=0;
}
}
else if(mx>=61 && mx<=101 && my>=25 && my<=40){
if(state&1 && n){
helpmenu();
n=0;
}
}
else if(mx>=114 && mx<=154 && my>=25 && my<=40){
if(state&1){
HideCur();
anniu(114,25,154,40,DARKGRAY,WHITE);
delay(10000);
gameover();
}
}
else if(!n) {
HideCur();
anniu(8,25,48,40,LIGHTGRAY,LIGHTGRAY);
anniu(61,25,101,40,LIGHTGRAY,LIGHTGRAY);
ShowCur();
n=1;
}
}
}
void helpmenu(){
void *bitmap;
int i1=0,i2=0,size;
HideCur();
anniu(61, 25, 101, 40, DARKGRAY, WHITE);
size=imagesize(61, 45, 150, 75);
bitmap=malloc(size);
getimage(61, 45, 150, 75, bitmap);
setfillstyle(1, LIGHTGRAY);
bar(62, 46, 149, 74);
anniu(62, 46, 149, 74, WHITE, DARKGRAY);
setcolor(BLACK);
outtextxy(68, 50, "Topics");
outtextxy(68, 64, "About...");
setcolor(DARKGRAY);
line(63, 59, 148, 59);
setcolor(WHITE);
line(63, 60, 148, 60);
ShowCur();
while(1){
tim(550, 466);
Status(&mx, &my, &state);
if(mx>=62 && mx<=149 && my>=46 && my<=59 && !i1){
i1=1; i2=0;
HideCur();
setfillstyle(1, BLUE);
bar(63, 47, 148, 58);
setcolor(YELLOW);
outtextxy(68, 50, "Topics");
setfillstyle(1, LIGHTGRAY);
bar(63, 61, 148, 73);
setcolor(BLACK);
outtextxy(68, 64, "About...");
ShowCur();
}
else if(mx>=62 && mx<=149 && my>=46 && my<=59 && i1 && state&1){
delay(500);
topic();
}
else if(mx>=62 && mx<=149 && my>=60 && my<=74 && i2 && state&1){
delay(500);
HideCur(); putimage(61, 45, bitmap, COPY_PUT);
free(bitmap);
i1=0;i2=0;
ShowCur();
about();
break;
}
else if(mx>=62 && mx<=149 && my>=60 && my<=74 && !i2){
i2=1; i1=0;
HideCur();
setfillstyle(1,LIGHTGRAY);
bar(63,47,148,58);
setcolor(BLACK);
outtextxy(68,50,"Topics");
setfillstyle(1,BLUE);
bar(63,61,148,73);
setcolor(YELLOW);
outtextxy(68,64,"About...");
ShowCur();
}
else if(mx<=62 ||mx>=149 ||my<=43 ||my>=75){
if(i1 || i2 || mx<=60 || mx>=102){
HideCur();
putimage(61,45,bitmap,COPY_PUT);
free(bitmap);
i1=0;i2=0;
ShowCur();
break;
}
}
}
}
void filemenu()
{
void *bitmap;
int i1=0,i2=0,size;
HideCur();
anniu(8, 25, 48, 40, DARKGRAY, WHITE);
size=imagesize(8, 45, 97, 75);
bitmap=malloc(size);
getimage(8, 45, 97, 75, bitmap);
setfillstyle(1, LIGHTGRAY);
bar(9, 46, 96, 74);
anniu(9, 46, 96, 74, WHITE, DARKGRAY);
setcolor(BLACK);
outtextxy(15,50,"WuZiQi");
outtextxy(15,64,"HeiBaiQi");
setcolor(DARKGRAY);
line(10,59, 95,59);
setcolor(WHITE);
line(10,60,95,60);
ShowCur();
while(1){
tim(550,466);
Status(&mx, &my, &state);
if(mx>=9 && mx<=96 && my>=46 && my<=59 && !i1){
i1=1; i2=0;
HideCur();
setfillstyle(1,BLUE);
bar(10,47,95,58);
setcolor(YELLOW);
outtextxy(15,50,"WuZiQi");
setfillstyle(1,LIGHTGRAY);
bar(10,61,95,73);
setcolor(BLACK);
outtextxy(15,64,"HeiBaiQi");
ShowCur();
}
else if(mx>=9 && mx<=96 && my>=60 && my<=74 && !i2){
i2=1; i1=0;
HideCur();
setfillstyle(1,LIGHTGRAY);
bar(10,47,95,58);
setcolor(BLACK);
outtextxy(15,50,"WuZiQi");
setfillstyle(1,BLUE);
bar(10,61,95,73);
setcolor(YELLOW);
outtextxy(15,64,"HeiBaiQi");
ShowCur();
}
else if(mx>=9 && mx<=96 && my>=46 && my<=59 && i1 && state&1){
delay(500);
HideCur();
putimage(8, 45, bitmap, COPY_PUT);
free(bitmap);
i1=0; i2=0;
anniu(8, 25, 48, 40, LIGHTGRAY, LIGHTGRAY);
wuziqi();
}
else if(mx>=9 && mx<=96 && my>=60 && my<=74 && i2 && state&1){
delay(500);
HideCur();
putimage(8, 45, bitmap, COPY_PUT);
free(bitmap);
i1=0; i2=0;
anniu(8, 25, 48, 40, LIGHTGRAY, LIGHTGRAY);
heibaiqi();
}
else if(mx<=9 ||mx>=96 ||my<=43 ||my>=75){
if(i1 || i2 || mx<=7 || mx>=49){
HideCur();
putimage(8,45,bitmap,COPY_PUT);
free(bitmap);
i1=0;i2=0;
ShowCur();
break;
}
}
}
}
void topic()
{
showbmp(0,478,"topic.bmp");
ShowCur();
while(1){
Status(&mx, &my, &state);
if(state&1){
HideCur();
closegraph();
init();
cleardevice();
InitMouse();
showmenu();
}
}
}
void about()
{
int i=1;
showbmp(175,320,"about.bmp");
ShowCur();
while(i){
Status(&mx, &my, &state);
tim(550,466);
if(state&1){
HideCur();
showbmp(7,458,"border.bmp");
ShowCur();
break;
}
}
return;
}
void anniu(int x0, int y0, int x1, int y1, int color1, int color2)
{
setcolor(color1);
line(x0-1, y0-1, x1+1, y0-1);
line(x0-1, y0-1, x0-1, y1+1);
setcolor(color2);
line(x1+1, y1+1, x1+1, y0-1);
line(x1+1, y1+1, x0-1, y1+1);
}
void wuziqi()
{
register int i, j;
zcount=0;
for (i=0; i<=300; i++){
zx[i]=0;
zy[i]=0;
}
for (i=0; i<=14; i++)
for (j=0; j<=14; j++)
qipan[i][j]=0;
draw(WUZIQI);
control(WUZIQI);
}
void heibaiqi()
{
int i, j;
for (i=0; i<=8; i++)
for (j=0; j<=8; j++)
hpad[i][j]=0;
setfillstyle(1,LIGHTGRAY);
bar(210,190,430,310);
anniu(210,190,430,310,WHITE,DARKGRAY);
anniu(209,189,431,311,BLACK,BLACK);
anniu(220,205,310,295,WHITE,DARKGRAY);
anniu(330,205,420,295,WHITE,DARKGRAY);
setcolor(BLACK);
rectangle(218,203,312,297);
rectangle(328,203,422,297);
settextstyle(0, HORIZ_DIR, 2);
outtextxy(250,220,"1P");
outtextxy(250,265,"2P");
outtextxy(363,220,"1P");
outtextxy(355,265,"CPU");
settextstyle(0, HORIZ_DIR, 1);
outtextxy(257,245,"vs");
outtextxy(370,245,"vs");
ShowCur();
while(1){
tim(550,466);
Status(&mx, &my, &state);
if(mx>=220 && mx<=310 && my>=205 && my<=295 && state&1){
HideCur();
anniu(220,205,310,295,DARKGRAY,DARKGRAY);
delay(10000);
draw(HEIBAIQI);
ShowCur();
control(HEIBAIQI);
}
else if(mx>=330 && mx<=420 && my>=205 && my<=295 && state&1){
HideCur();
anniu(330,205,420,295,DARKGRAY,DARKGRAY);
delay(10000);
draw(HEIBAIQI);
ShowCur();
mind2cpu();
}
}
}
void mind2cpu()
{
int type, i, k, x ,y;
hcount=0;
copyqipan();
while(1){
tim(550,466);
Status(&mx, &my, &state);
qx=(mx-160)/40;
qy=(my-93)/40;
if(mx>=30 && mx<=80 && my>=240 && my<=255 && state&1){
setlinestyle(SOLID_LINE, 0, 1);
anniu(30, 240, 80, 255, DARKGRAY,WHITE);
delay(7000);
HideCur();
showmenu();
}
if (state&2 && hcount>=1){
HideCur();
hhuiqi(0);
ShowCur();
delay(10000);
}
if (mx<=480 && mx>=160 && my<=413 && my>=93 && hpad[qx][qy]==WUQIZI && state&1){
k=change(qx,qy,PLAYER1,0);
if(k){
order=PLAYER1;
HideCur();
xiazi(qx,qy,HEIBAIQI);
change(qx,qy,PLAYER1,1);
hcount++;
copyqipan();
hjudge();
ShowCur();
i=pass(PLAYER2);
if(i) {
delay(8000);
continue;
}
do{
core_think(PLAYER2);
HideCur();
hdisplay();
hcount++;
copyqipan();
ShowCur();
hjudge();
i=pass(PLAYER1);
}while(i);
} }
}
}
void init()
{
int Graphdriver = DETECT, Graphmode, Errorcode;
/*registerbgidriver(EGAVGA_driver); */
initgraph(&Graphdriver, &Graphmode, "");
Errorcode=graphresult();
if (Errorcode!=0){
printf("Graphics system error:%s\n", grapherrormsg(Errorcode));
exit(1);
}
else return;
}
void draw(int type)
{
int i, j, step;
int size;
if (type==WUZIQI) step=25;
else step=40;
setfillstyle(1, BROWN);
setcolor(CYAN);
bar(120, 53, 520, 453);
setlinestyle(0,0,1);
anniu(120,53,520,453,WHITE,0);
setcolor(BLACK);
rectangle(118,51,522,455);
setfillstyle(1,BLUE);
bar(7,50,117,458);
bar(523,50,633,458);
setfillstyle(1,LIGHTGRAY);
bar(30,240,80,255);
setlinestyle(SOLID_LINE, 0, 1);
anniu(30,240,80,255,WHITE,DARKGRAY);
setcolor(BLACK);
rectangle(28, 238, 82, 257);
setcolor(BLACK);
outtextxy(40,245,"QUIT");
setlinestyle(SOLID_LINE, 0, THICK_WIDTH);
setcolor(BLACK);
line(120+step, 53+step, 120+step, 453-step);
line(120+step, 53+step, 520-step, 53+step);
line(520-step, 453-step, 120+step, 453-step);
line(520-step, 53+step, 520-step, 453-step);
setlinestyle(SOLID_LINE, 0, NORM_WIDTH);
setcolor(BLACK);
for (i=120+2*step,j=53+2*step; i<=520-2*step; i+=step,j+=step){
line(i, 53+step, i, 453-step);
line(120+step, j, 520-step, j);
}
if (type==HEIBAIQI){
order=PLAYER1;
xiazi(3, 3, HEIBAIQI);
xiazi(4, 4, HEIBAIQI);
order=PLAYER2;
xiazi(3, 4, HEIBAIQI);
xiazi(4, 3, HEIBAIQI);
setlinestyle(SOLID_LINE, 0, THICK_WIDTH);
setcolor(LIGHTGREEN);
line(535, 130, 620, 130);
line(535, 210, 620, 210);
line(535, 290, 620, 290);
line(536, 130, 536, 290);
line(619, 130, 619, 290);
setlinestyle(SOLID_LINE, 0, NORM_WIDTH);
line(535, 240, 620, 240);
line(535, 160, 620, 160);
settextstyle(TRIPLEX_FONT,HORIZ_DIR,3);
outtextxy(542, 133, "BLACK");
outtextxy(542, 213, "WHITE");
settextstyle(TRIPLEX_FONT, HORIZ_DIR, 5);
setcolor(LIGHTMAGENTA);
outtextxy(555, 162, "02");
outtextxy(555, 242, "02");
}
return;
}
void copyqipan()
{
register int i, j;
for(i=0; i<=7; i++)
for(j=0; j<=7; j++)
hqipan[hcount][i][j]=hpad[i][j];
return;
}
long hvalue(int pad[8][8], int turn)
{
register int i, j;
long valueit=0;
for(i=0; i<=7; i++)
for(j=0; j<=7; j++){
if(pad[x][y]==turn){
valueit+=value[i][j];
}
else if(pad[x][y]==-turn){
valueit-=value[i][j];
}
}
return valueit;
}
int core_think(int my_self)
{ int chess_bak[8][8],oponent=-my_self;
int tempscore;
int value_temp,value_best=-30000;