當前位置:編程學習大全網 - 源碼下載 - VC++黑白棋

VC++黑白棋

本程序提供五子棋、黑白棋雙人對下的環境,以及黑白棋人機對下的功能。其界面模仿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;

  • 上一篇:08CMS的功能特點
  • 下一篇:構建源代碼
  • copyright 2024編程學習大全網