用C++写一个黑白棋程序 环境是linux 不要VC

VC++\u9ed1\u767d\u68cb

\u672c\u7a0b\u5e8f\u63d0\u4f9b\u4e94\u5b50\u68cb\u3001\u9ed1\u767d\u68cb\u53cc\u4eba\u5bf9\u4e0b\u7684\u73af\u5883\uff0c\u4ee5\u53ca\u9ed1\u767d\u68cb\u4eba\u673a\u5bf9\u4e0b\u7684\u529f\u80fd\u3002\u5176\u754c\u9762\u6a21\u4effwindows, \u64cd\u4f5c\u7b80\u4fbf\uff0c\u6240\u6709\u64cd\u4f5c\u90fd\u901a\u8fc7\u9f20\u6807\u5b8c\u6210\u3002
\u8fdb\u5165\u7a0b\u5e8f\u540e\uff0c\u4ecegame\u83dc\u5355\u53ef\u9009\u62e9\u6e38\u620f\u7684\u79cd\u7c7b\uff0c\u5728\u6e38\u620f\u8fdb\u884c\u8fc7\u7a0b\u4e2d\u91c7\u7528\u9f20\u6807\u5de6\u952e\u4e0b\u5b50\uff0c\u53f3\u952e\u6094\u68cb\u3002
\u6574\u4e2a\u6e90\u7a0b\u5e8f\u603b\u5171\u7531mouse.c\u3001timedate.c\u3001bmp.c\u3001bww.c\u3001bww.prj\u4e94\u4e2a\u6587\u4ef6\u7ec4\u6210\uff0c\u7ea61500\u4f59\u884c\u3002\u5176\u4e2dmouse.c\u5305\u542b\u9f20\u6807\u76f8\u5173\u7684\u8bed\u53e5\uff1btimedate.c\u7528\u4e8e\u663e\u793a\u5f53\u524d\u7684\u65e5\u671f\u4e0e\u65f6\u95f4\uff1bbmp.c\u7528\u4e8e\u663e\u793a16\u8272\u4f4d\u56fe\u4f5c\u4e3a\u7a0b\u5e8f\u7684\u5c01\u9762\u4ee5\u53ca\u4fbf\u4e8e\u4e2d\u6587\u7684\u663e\u793a\uff1b
bww.c\u662f\u6574\u4e2a\u7a0b\u5e8f\u7684\u6838\u5fc3\u90e8\u5206\uff0c\u4e0b\u9762\u5c06\u5c31bww.c\u4e2d\u7684\u5404\u4e2a\u91cd\u8981\u51fd\u6570\u4f5c\u4e00\u4e0b\u7b80\u8981\u7684\u4ecb\u7ecd\uff1a

void init()\uff1a\u8be5\u51fd\u6570\u7528\u4e8e\u56fe\u5f62\u4ee5\u53ca\u9f20\u6807\u7684\u521d\u59cb\u5316\u3002

void anniu(int x0, int y0, int x1, int y1, int color1, int color2)\uff1a\u8be5\u51fd\u6570\u901a\u8fc7\u5728\u4e00\u5757\u5e73\u9762\u533a\u57df\u7684\u56db\u5468\u7528\u4e24\u79cd\u989c\u8272\u753b\u7ebf\uff0c\u4f7f\u4e4b\u4ea7\u751f\u51f8\u8d77\u6216\u51f9\u9677\u7684\u7acb\u4f53\u6548\u679c\u3002

void showmenu();
void helpmenu()\uff1b
void filemenu(); \u8fd9\u4e94\u4e2a\u51fd\u6570\u4e3b\u8981\u7528\u4e8e\u83dc\u5355\u680f\u53ca\u5404\u7ea7\u83dc\u5355\u7684\u663e\u793a\u3002
void topic();
void about();

void wuziqi()\uff1a\u901a\u8fc7\u8c03\u7528\u8be5\u51fd\u6570\u8fdb\u5165\u4e94\u5b50\u68cb\u7684\u53cc\u4eba\u5bf9\u4e0b\u73af\u5883\u3002
void heibaiqi()\uff1a\u901a\u8fc7\u8c03\u7528\u8be5\u51fd\u6570\u8fdb\u5165\u9ed1\u767d\u68cb\u7684\u53cc\u4eba\u5bf9\u4e0b\u73af\u5883\u3002
void mind2cpu()\uff1a\u901a\u8fc7\u8c03\u7528\u8be5\u51fd\u6570\u8fdb\u5165\u9ed1\u767d\u68cb\u7684\u4eba\u673a\u5bf9\u4e0b\u73af\u5883\u3002

void draw(int type)\uff1a\u8be5\u51fd\u6570\u6839\u636etype\u53c2\u6570\u503c\u7684\u4e0d\u540c\uff0c\u753b\u51fa\u7b26\u5408\u9700\u8981\u7684\u68cb\u76d8\u3002

void win(int type, int winner)\uff1a\u901a\u8fc7\u5bf9\u8be5\u51fd\u6570\u7684\u8c03\u7528\uff0c\u663e\u793a\u80dc\u5229\u7684\u4fe1\u606f\uff0c\u5e76\u8be2\u95ee\u63a5\u7740\u8981\u6267\u884c\u7684\u64cd\u4f5c\u3002

void gameover()\uff1a\u901a\u8fc7\u5bf9\u8be5\u51fd\u6570\u7684\u8c03\u7528\uff0c\u9000\u51fa\u672c\u7a0b\u5e8f\u3002

int xiazi(int xx, int yy, int type)\uff1a\u8be5\u51fd\u6570\u5728\u68cb\u76d8\u5750\u6807\u4e3a\uff08xx, yy\uff09\u5904\u4e0btype\u53c2\u6570\u6240\u5b9a\u4e49\u7684\u68cb\u5b50\u3002

void control(int type)\uff1a\u8be5\u51fd\u6570\u7528\u4e8e\u4e94\u5b50\u68cb\u4e0e\u9ed1\u767d\u68cb\u7684\u53cc\u4eba\u5bf9\u4e0b\u73af\u5883\uff0c\u901a\u8fc7\u5faa\u73af\u4e0d\u65ad\u5730\u63a5\u53d7\u9f20\u6807\u7684\u7684\u6309\u952e\u4fe1\u606f\uff0c\u7136\u540e\u8c03\u7528\u76f8\u5e94\u7684\u51fd\u6570\u6267\u884c\u6240\u8981\u6c42\u7684\u529f\u80fd\u3002

void judge()\uff1a\u8be5\u51fd\u6570\u5224\u65ad\u68cb\u76d8\u4e0a\u662f\u5426\u6709\u540c\u79cd\u989c\u8272\u7684\u68cb\u5b50\u8fde\u6210\u4e86\u4e94\u9897\u4ee5\u4e0a\u6216\u68cb\u76d8\u4ee5\u88ab\u5360\u6ee1\uff0c\u5373\u5224\u65ad\u662f\u5426\u4ee5\u5206\u51fa\u4e86\u80dc\u8d1f\uff0c\u8fd8\u662f\u5e73\u624b\u3002

void huiqi()\uff1a\u8be5\u51fd\u6570\u7528\u4e8e\u6267\u884c\u4e94\u5b50\u68cb\u7684\u6094\u68cb\u529f\u80fd\u3002

void hdisplay();
void display();

void copyqipan()\uff1a\u8be5\u51fd\u6570\u5c06\u6bcf\u4e00\u6b65\u7684\u68cb\u76d8\u72b6\u51b5\u590d\u5236\u5230\u4e00\u4e2a\u5907\u4efd\u6570\u7ec4\u4e2d\uff0c\u4ee5\u5b9e\u73b0\u9ed1\u767d\u68cb\u7684\u6094\u68cb\u529f\u80fd\u3002
int copy_chess (int source[8][8],int dest[8][8])\uff1a\u8be5\u51fd\u6570\u5c06\u524d\u4e00\u6570\u7ec4\u5404\u9879\u590d\u5236\u5230\u540e\u4e00\u6570\u7ec4\u5f53\u4e2d\u3002\u4e3b\u8981\u7528\u4e8e\u9ed1\u767d\u68cb\u7684\u4eba\u5de5\u667a\u80fd\u3002

void hhuiqi(int type)\uff1a\u8be5\u51fd\u6570\u8c03\u7528display()\u51fd\u6570\u5b9e\u73b0\u9ed1\u767d\u68cb\u7684\u6094\u68cb\u529f\u80fd\u3002

int hpass(int my_self)\uff1a\u8be5\u51fd\u6570\u5224\u65admy_self\u4ee3\u8868\u4e00\u65b9\u662f\u5426\u65e0\u5904\u53ef\u4e0b\uff0c\u4f46\u4e0d\u5728\u5c4f\u5e55\u4e0a\u663e\u793a\uff0c\u4e3b\u8981\u7528\u4e8e\u9ed1\u767d\u68cb\u7684\u4eba\u5de5\u667a\u80fd\u3002
int pass(int turn)\uff1a\u8be5\u51fd\u6570\u5224\u65adturn\u4ee3\u8868\u4e00\u65b9\u662f\u5426\u65e0\u5904\u53ef\u4e0b\uff0c\u5e76\u5728\u5c4f\u5e55\u4e0a\u663e\u793a\u201cPASS\u201d\u5b57\u6837\u3002

long hvalue(int pad[8][8], int turn)\uff1a\u8be5\u51fd\u6570\u6839\u636e\u5206\u503c\u8868\u5224\u65adturn\u8fd9\u4e00\u65b9\u5728pad[8][8]\u6570\u7ec4\u6240\u8868\u793a\u7684\u60c5\u51b5\u4e0b\u7684\u7684\u5206\u3002\u4e3b\u8981\u7528\u4e8e\u9ed1\u767d\u68cb\u7684\u4eba\u5de5\u667a\u80fd\u3002

int core_think(int my_self)\uff1a\u901a\u8fc7\u9012\u5f52\u8c03\u7528\u5224\u65ad\u7535\u8111\u8d70\u54ea\u4e00\u6b65\u6700\u5408\u9002\uff0cMAXSTEP\u5b9a\u4e49\u4e86\u7535\u8111\u6240\u60f3\u7684\u6b65\u6570\uff0c\u76ee\u524d\u6211\u5c06\u5176\u503c\u5b9a\u4e3a4\u3002

void hjudge()\uff1a\u8be5\u51fd\u6570\u8ba1\u7b97\u68cb\u76d8\u5f53\u524d\u72b6\u51b5\u53cc\u65b9\u7684\u5b50\u6570\uff0c\u5e76\u663e\u793a\u51fa\u6765\uff0c\u7528\u4e8e\u4e24\u4e2a\u9ed1\u767d\u68cb\u4e2d\u3002

int change(int cx, int cy, int playerorder, int a)\uff1a\u5224\u65adplayerorder\u4e00\u65b9\u5728(cx, cy)\u5904\u4e0b\u5b50\u662f\u5426\u80fd\u5f15\u8d77\u6539\u53d8\uff0c\u6839\u636ea\u7684\u4e0d\u540c\u4ee5\u51b3\u5b9a\u662f\u5426\u8981\u5728\u68cb\u76d8\u4e0a\u8868\u793a\u51fa\u6765\uff0c\u7528\u4e8epass\u7684\u5224\u65ad\uff0c\u548c\u663e\u793a\u4e00\u65b9\u4e0b\u5b50\u6240\u5f15\u8d77\u7684\u53cc\u65b9\u68cb\u5b50\u7684\u53d8\u5316\u3002
int try_xy(int x, int y, int chess[8][8], int my_self)\uff1a\u5224\u65admy_self\u4e00\u65b9\u5728(x, y)\u5904\u4e0b\u5b50\u662f\u5426\u80fd\u5f15\u8d77\u6539\u53d8\uff0c\u5c06\u6b64\u6539\u53d8\u8bb0\u5f55\u5728chess[8][8]\u4e2d\u3002

\u4ee5\u4e0a\u5373\u662fbww.c\u6587\u4ef6\u4e2d\u4e3b\u8981\u51fd\u6570\u7684\u4ecb\u7ecd\u3002\u7531\u4e8e\u9ed1\u767d\u68cb\u7684\u4eba\u5de5\u667a\u80fd\u662f\u540e\u6765\u624d\u60f3\u5230\u8981\u7f16\u7684\uff0c\u6240\u4ee5\u6709\u4e9b\u51fd\u6570\u6709\u4e9b\u91cd\u590d\uff0c\u5e76\u4e14\u9ed1\u767d\u68cb\u7684\u4eba\u5de5\u667a\u80fd\u5f88\u96be\u8fbe\u5230\u975e\u5e38\u9ad8\uff0c\u6211\u662f\u7f16\u4e86\u597d\u957f\u65f6\u95f4\u624d\u4f5c\u6210\u8fd9\u4e00\u4e2a\u8ba9\u6211\u53ef\u4ee5\u63a5\u53d7\u7684\u7a0b\u5ea6\u3002\u800c\u4e14\u8fd9\u79cd\u7b97\u6cd5\u7684\u6548\u7387\u4e5f\u5f88\u4f4e\uff0c\u5bfc\u81f4\u5f53MAXSTEP\u4e3a5\u65f6\uff0c\u7535\u8111\u6bcf\u8d70\u4e00\u6b65\u5c31\u8981\u7b49\u597d\u957f\u65f6\u95f4\u3002\u5e0c\u671b\u4eca\u540e\u6211\u80fd\u591f\u627e\u5230\u89e3\u51b3\u8fd9\u4e9b\u4e0d\u8db3\u7684\u597d\u65b9\u6cd5\u3002


\u4ee3\u7801\u5982\u4e0b\uff1a
bmp.h:
#include
#include
#include
#include
#include
#include
#include
#include


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
#include

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
#include
#include
#include
#include

#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=25 && my<=40){
if(state&1){
filemenu();
n=0;
}
}
else if(mx>=61 && mx=25 && my<=40){
if(state&1 && n){

helpmenu();
n=0;
}
}
else if(mx>=114 && mx=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=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=46 && my<=59 && i1 && state&1){
delay(500);
topic();
}

else if(mx>=62 && mx=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=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=149 ||my=75){
if(i1 || i2 || 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=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=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=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=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=96 ||my=75){
if(i1 || i2 || 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=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=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=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=160 && 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;

\u697c\u4e0a\u7684\u56de\u7b54\u4e0d\u51c6\u786e\u3002
\u5b9e\u9645\u4e0a\u697c\u4e3b\u63d0\u51fa\u7684\u95ee\u9898\u662f\u60f3\u89e3\u51b3\u8de8\u5e73\u53f0\u5f00\u53d1\u7684\u79fb\u690d\u95ee\u9898\u3002
\u56de\u7b54\u662f\uff1a\u4e0d\u53ef\u4ee5\u628avc\u88c5\u5728linux\u4e0a\uff0c\u4f46\u662f\u53ef\u4ee5\u5c06windows\u4e2d\u7528vc\u5f00\u53d1\u7684\u5e94\u7528\u7a0b\u5e8f\u79fb\u690d\u5230linux\u4e2d\u8fd0\u884c\u3002\u9700\u8981\u4e24\u4e2a\u6b65\u9aa4\u3002
1\uff0c\u5728windows\u4e0b\u7528vc\u7f16\u8bd1\u8fc7\u7684\u7a0b\u5e8f\u4e0d\u80fd\u5305\u542b\u64cd\u4f5c\u7cfb\u7edf\u4e2d\u7684\u5143\u7d20\uff0c\u4f8b\u5982windows sdk\uff0cmfc\u7b49\u7b49\uff0c\u8981\u5b8c\u5168\u7b26\u5408ansi c\uff0b\uff0b\u7684\u6807\u51c6\uff0c\u4e0elinux \u4e0b\u7684c\uff0b\uff0b\u7f16\u8bd1\u5668\u76f8\u5bf9\u5e94\u3002
2\uff0c\u9700\u8981\u8c03\u6574\u7f16\u8bd1\u5668\u5bf9\u5e94\u7684makefile\u6587\u4ef6\uff0c\u8fd9\u6837\u914d\u7f6e\u540e\u624d\u80fd\u751f\u6210\u7406\u60f3\u7684exe\u5e94\u7528\u7a0b\u5e8f\u3002

扩展阅读:c++教程 ... 约瑟夫环c++ ... 约瑟夫环链序问题c++代码 ... c++处理约瑟夫环 ... c++简单约瑟夫环问题 ... 颜色深度10bpc和8bpc ... 约瑟夫环问题c++思路 ... 用 s输出菱形 ... 约瑟夫环c++代码数据结构 ...

本站交流只代表网友个人观点,与本站立场无关
欢迎反馈与建议,请联系电邮
2024© 车视网