帮我找下错误 我调试了许久就是不知道怎么改正这个错误
2010-12-12 23:00
337 查看
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <graphics.h>
#define up 72
#define down 80
#define left 75
#define right 77
#define enter 13
#define esc 27
#define h_key 104
#define y_key 121
int quan[5][2]={0,0,1,2,7,9,35,40,125,180};
int state[15][15],goal[15][15][2],num[15][15][2][4];
char win=2,a,b;
int maxgoal,x,y,s=0;
void ai(char ax,char ay,char am,char an)
{
char r,t;
int beginx,beginy,endx,endy;
/*0方向判断*/
if((ax+ay)>=4&&(ax+ay)<=24)
{
beginx=ax-4;beginy=ay+4;
if(beginx<0)
{
beginx=0;
beginy=ay+ax;
}
if(beginy>14)
{
beginx=ax+ay-14;
beginy=14;
}
endx=ax+4;endy=ay-4;
if(endx>14)
{
endx=14;
endy=ax+ay-14;
}
if(endy<0)
{
endx=ax+ay;
endy=0;
}
endx=endx-4;endy=endy+4;
for(r=beginx;r<endx+1;r++)
{
if(num[r][beginy+beginx-r][am][0]!=6)
{
num[r][beginy+beginx-r][an][0]=6;
for(t=0;t<5;t++)
{
goal[r+t][beginy+beginx-r-t][am]=goal[r+t][beginy+beginx-r-t][am]-quan[num[r][beginy+beginx-r][am][0]][am];
}
num[r][beginy+beginx-r][am][0]++;
if(num[r][beginy+beginx-r][am][0]==5)
{
win=am;
}
for(t=0;t<5;t++)
{
goal[r+t][beginy+beginx-r-t][am]=goal[r+t][beginy+beginx-r-t][am]+quan[num[r][beginy+beginx-r][am][0]][am];
}
}
else if(num[r][beginy+beginx-r][an][0]!=6)
{
for(t=0;t<5;t++)
{
goal[r+t][beginy+beginx-r-t][an]=goal[r+t][beginy+beginx-r-t][an]-quan[num[r][beginy+beginx-r][an][0]][an];
}
num[r][beginy+beginx-r][am][0]=6;
num[r][beginy+beginx-r][an][0]=6;
}
}
}
/*1方向判断*/
{
beginx=ax-4;beginy=ay;
if(beginx<0)
{
beginx=0;
}
endx=ax+4;endy=ay;
if(endx>14)
{
endx=14;
}
endx=endx-4;
for(r=beginx;r<endx+1;r++)
{
if(num[r][ay][am][1]!=6)
{
num[r][ay][an][1]=6;
for(t=0;t<5;t++)
{
goal[r+t][ay][am]=goal[r+t][ay][am]-quan[num[r][ay][am][1]][am];
}
num[r][ay][am][1]++;
if(num[r][ay][am][1]==5)
{
win=am;
}
for(t=0;t<5;t++)
{
goal[r+t][ay][am]=goal[r+t][ay][am]+quan[num[r][ay][am][1]][am];
}
}
else if(num[r][ay][an][1]!=6)
{
for(t=0;t<5;t++)
{
goal[r+t][ay][an]=goal[r+t][ay][an]-quan[num[r][ay][an][1]][an];
}
num[r][ay][am][1]=6;
num[r][ay][an][1]=6;
}
}
}
/*2方向判断*/
beginx=ax-4;beginy=ay-4;
if(beginx<0)
{
beginy=beginy-beginx;
beginx=0;
}
if(beginy<0)
{
beginx=beginx-beginy;
beginy=0;
}
endx=ax+4;endy=ay+4;
if(endx>14)
{
endy=endy-endx+14;
endx=14;
}
if(endy>14)
{
endx=endx-endy+14;
endy=14;
}
endx=endx-4;endy=endy-4;
if(beginx<=endx)
{
for(r=beginx;r<endx+1;r++)
{
if(num[r][beginy-beginx+r][am][2]!=6)
{
num[r][beginy-beginx+r][an][2]=6;
for(t=0;t<5;t++)
{
goal[r+t][beginy-beginx+r+t][am]=goal[r+t][beginy-beginx+r+t][am]-quan[num[r][beginy-beginx+r][am][2]][am];
}
num[r][beginy-beginx+r][am][2]++;
if(num[r][beginy-beginx+r][am][2]==5)
{
win=am;
}
for(t=0;t<5;t++)
{
goal[r+t][beginy-beginx+r+t][am]=goal[r+t][beginy-beginx+r+t][am]+quan[num[r][beginy-beginx+r][am][2]][am];
}
}
else if(num[r][beginy-beginx+r][an][2]!=6)
{
for(t=0;t<5;t++)
{
goal[r+t][beginy-beginx+r+t][an]=goal[r+t][beginy-beginx+r+t][an]-quan[num[r][beginy-beginx+r][an][2]][an];
}
num[r][beginy-beginx+r][am][2]=6;
num[r][beginy-beginx+r][an][2]=6;
}
}
}
/*3方向判断*/
{
beginy=ay-4;beginx=ax;
if(beginy<0)
{
beginy=0;
}
endy=ay+4;endx=ax;
if(endy>14)
{
endy=14;
}
endy=endy-4;
for(r=beginy;r<endy+1;r++)
{
if(num[ax][r][am][3]!=6)
{
num[ax][r][an][3]=6;
for(t=0;t<5;t++)
{
goal[ax][r+t][am]=goal[ax][r+t][am]-quan[num[ax][r][am][3]][am];
}
num[ax][r][am][3]++;
if(num[ax][r][am][3]==5)
{
win=am;
}
for(t=0;t<5;t++)
{
goal[ax][r+t][am]=goal[ax][r+t][am]+quan[num[ax][r][am][3]][am];
}
}
else if(num[ax][r][an][3]!=6)
{
for(t=0;t<5;t++)
{
goal[ax][r+t][an]=goal[ax][r+t][an]-quan[num[ax][r][an][3]][an];
}
num[ax][r][am][3]=6;
num[ax][r][an][3]=6;
}
}
}
}
void findmax(char m,char n)
{
char i,j;
a=0;
b=0;
maxgoal=-1;
for(i=0;i<15;i++)
{
for(j=0;j<15;j++)
{
if(state[i][j]==2)
{
if(goal[i][j][m]>maxgoal)
{
a=i;
b=j;
maxgoal=goal[i][j][m];
}
else if(goal[i][j][m]==maxgoal)
{
if(goal[i][j]
>goal[a][b]
)
{
a=i;
b=j;
maxgoal=goal[i][j][m];
}
else if(goal[i][j]
==goal[a][b]
)
{
if(random(2))
{
a=i;
b=j;
maxgoal=goal[i][j][m];
}
}
}
}
}
}
}
void menu()
{
setcolor(RED);
settextstyle(0,0,3);
outtextxy(150,150,"Player first");
outtextxy(150,180,"Computer first");
outtextxy(150,210,"Exit");
}
int show(int y)
{
int oy=0;
char ch=0;
cleardevice();
setbkcolor(BLACK);
setcolor(BLUE);
settextstyle(0,0,4);
outtextxy(200,40,"GOBANG");
settextstyle(0,0,2);
outtextxy(350,90,"www.vcworld.net");
setcolor(WHITE);
settextstyle(0,0,2);
outtextxy(40,280,"operate handbook:");
outtextxy(100,310,"Up,Down,Left,Right key to move");
outtextxy(100,340,"Enter key for sure");
outtextxy(100,370,"H key for help");
outtextxy(100,400,"Esc key to exit");
outtextxy(440,430,"version:1.0");
while(ch!=enter)
{
if((ch==down||ch==right)&&y!=210)
y+=30;
else if((ch==up||ch==left)&&y!=150)
y-=30;
if(oy!=y)
{
setfillstyle(0,BLACK);
bar(140,oy-2,490,oy+24);
setfillstyle(1,BLUE);
bar(140,y-2,490,y+24);
menu();
oy=y;
}
ch=getch();
}
return y;
}
void step(int step)
{
char s[4];
sprintf(s,"%d",step);
setcolor(BLACK);
setfillstyle(1,BLACK);
bar(22,239,100,269);
setcolor(BLUE);
settextstyle(0,0,3);
outtextxy(10,210,"STEP");
outtextxy(23,240,s);
}
void fun(int t)
{
setcolor(BLACK);
setfillstyle(1,BLACK);
bar(539,100,639,300);
setcolor(BLUE);
settextstyle(0,0,3);
if(t==1)
{
outtextxy(540,210," ");
outtextxy(540,240," ");
}
else if(t==0)
{
outtextxy(540,195,"Your");
outtextxy(540,225,"turn");
setcolor(RED);
setfillstyle(1,RED);
pieslice(590,270,0,360,11);
}
else if(t==2)
{
outtextxy(540,210,"Exit");
outtextxy(540,240,"y/n ");
}
else if(t==3)
{
setcolor(RED);
outtextxy(540,210,"You ");
outtextxy(540,240,"win ");
}
else if(t==4)
{
setcolor(RED);
outtextxy(540,210,"You ");
outtextxy(540,240,"lose");
}
else if(t==5)
{
setcolor(RED);
outtextxy(540,210,"GAME");
outtextxy(540,240,"OVER");
}
}
void pan()
{
int r;
cleardevice();
setcolor(WHITE);
for(r=1;r<15;r++)
{
rectangle(124,44,124+r*28,44+r*28);
rectangle(516,436,516-r*28,436-r*28);
}
rectangle(106,26,534,454);
rectangle(105,25,535,455);
rectangle(107,27,533,453);
}
void curr(int co)
{
setcolor(co);
line(x-15,y-10,x-10,y-10);
line(x-10,y-10,x-10,y-15);
line(x+10,y-15,x+10,y-10);
line(x+10,y-10,x+15,y-10);
line(x-15,y+10,x-10,y+10);
line(x-10,y+10,x-10,y+15);
line(x+10,y+10,x+10,y+15);
line(x+10,y+10,x+15,y+10);
}
main()
{
int gd=DETECT,gm,turn,oa,ob,omax;
char ch,i1,i2,i3,i4;
registerbgidriver(EG***GA_driver);
initgraph(&gd,&gm,"");
begin:
for(i1=0;i1<15;i1++)
for(i2=0;i2<15;i2++)
{
state[i1][i2]=2;
for(i3=0;i3<2;i3++)
{
goal[i1][i2][i3]=0;
for(i4=0;i4<4;i4++)
num[i1][i2][i3][i4]=0;
}
}
win=2;s=0;
turn=(show(150)-150)/30;
if(turn==2)
exit(0);
else
{
pan();
if(turn==1)
{
randomize();
a=random(7)+4;
randomize();
b=random(7)+4;
ai(a,b,1,0);
state[a][b]=turn;
s++;
step(s);
turn=0;
x=124+28*a;y=44+28*b;
setcolor(GREEN);
setfillstyle(1,GREEN);
pieslice(x,y,0,360,11);
curr(WHITE);
}
else
{
a=7;
b=7;
x=124+28*a;
y=44+28*b;
curr(WHITE);
step(0);
}
}
while(win==2&&s<225)
{
if(turn==1)
{
fun(1);
findmax(0,1);
omax=maxgoal;oa=a;ob=b;
findmax(1,0);
if(omax>maxgoal)
{
a=oa;
b=ob;
}
else if(omax==maxgoal)
{
if(goal[oa][ob][1]>goal[a][b][0])
{
a=oa;
b=ob;
}
else if(goal[oa][ob][1]==goal[a][b][0])
{
if(random(2))
{
a=oa;
b=ob;
}
}
}
ai(a,b,1,0);
state[a][b]=turn;
s++;
step(s);
turn=0;
x=124+28*a;
y=44+28*b;
setcolor(GREEN);
setfillstyle(1,GREEN);
pieslice(x,y,0,360,11);
curr(WHITE);
}
else
{
fun(0);
ch=getch();
while(ch!=enter)
{
if(ch==esc)
{
fun(2);
if(getch()==y_key)
goto begin;
fun(0);
}
else if(ch==h_key)
{
curr(BLACK);
findmax(1,0);
omax=maxgoal;
oa=a;
ob=b;
findmax(0,1);
x=a;
y=b;
if(omax>maxgoal)
{
a=oa;
b=ob;
}
else if(omax==maxgoal)
{
if(goal[oa][ob][0]>goal[a][b][1])
{
a=oa;
b=ob;
}
else if(goal[oa][ob][0]==goal[a][b][1])
{
if(random(2))
{
a=oa;
b=ob;
}
}
}
x=124+28*a;
y=44+28*b;
curr(WHITE);
}
else if(ch==up)
{
curr(BLACK);
b--;
if(b<0)
b=14;
x=124+28*a;
y=44+28*b;
curr(WHITE);
}
else if(ch==down)
{
curr(BLACK);
b++;
if(b>14)
b=0;
x=124+28*a;
y=44+28*b;
curr(WHITE);
}
else if(ch==left)
{
curr(BLACK);
a--;
if(a<0)
a=14;
x=124+28*a;
y=44+28*b;
curr(WHITE);
}
else if(ch==right)
{
curr(BLACK);
a++;
if(a>14)
a=0;
x=124+28*a;
y=44+28*b;
curr(WHITE);
}
ch=getch();
}
}
if(state[a][b]==2)
{
curr(BLACK);
ai(a,b,0,1);
state[a][b]=turn;
x=124+28*a;
y=44+28*b;
turn=1;
s++;
step(s);
setcolor(RED);
setfillstyle(1,RED);
pieslice(x,y,0,360,11);
}
}
curr(WHITE);
fun(win+3);
getch();
goto begin;
}
#include <stdlib.h>
#include <conio.h>
#include <graphics.h>
#define up 72
#define down 80
#define left 75
#define right 77
#define enter 13
#define esc 27
#define h_key 104
#define y_key 121
int quan[5][2]={0,0,1,2,7,9,35,40,125,180};
int state[15][15],goal[15][15][2],num[15][15][2][4];
char win=2,a,b;
int maxgoal,x,y,s=0;
void ai(char ax,char ay,char am,char an)
{
char r,t;
int beginx,beginy,endx,endy;
/*0方向判断*/
if((ax+ay)>=4&&(ax+ay)<=24)
{
beginx=ax-4;beginy=ay+4;
if(beginx<0)
{
beginx=0;
beginy=ay+ax;
}
if(beginy>14)
{
beginx=ax+ay-14;
beginy=14;
}
endx=ax+4;endy=ay-4;
if(endx>14)
{
endx=14;
endy=ax+ay-14;
}
if(endy<0)
{
endx=ax+ay;
endy=0;
}
endx=endx-4;endy=endy+4;
for(r=beginx;r<endx+1;r++)
{
if(num[r][beginy+beginx-r][am][0]!=6)
{
num[r][beginy+beginx-r][an][0]=6;
for(t=0;t<5;t++)
{
goal[r+t][beginy+beginx-r-t][am]=goal[r+t][beginy+beginx-r-t][am]-quan[num[r][beginy+beginx-r][am][0]][am];
}
num[r][beginy+beginx-r][am][0]++;
if(num[r][beginy+beginx-r][am][0]==5)
{
win=am;
}
for(t=0;t<5;t++)
{
goal[r+t][beginy+beginx-r-t][am]=goal[r+t][beginy+beginx-r-t][am]+quan[num[r][beginy+beginx-r][am][0]][am];
}
}
else if(num[r][beginy+beginx-r][an][0]!=6)
{
for(t=0;t<5;t++)
{
goal[r+t][beginy+beginx-r-t][an]=goal[r+t][beginy+beginx-r-t][an]-quan[num[r][beginy+beginx-r][an][0]][an];
}
num[r][beginy+beginx-r][am][0]=6;
num[r][beginy+beginx-r][an][0]=6;
}
}
}
/*1方向判断*/
{
beginx=ax-4;beginy=ay;
if(beginx<0)
{
beginx=0;
}
endx=ax+4;endy=ay;
if(endx>14)
{
endx=14;
}
endx=endx-4;
for(r=beginx;r<endx+1;r++)
{
if(num[r][ay][am][1]!=6)
{
num[r][ay][an][1]=6;
for(t=0;t<5;t++)
{
goal[r+t][ay][am]=goal[r+t][ay][am]-quan[num[r][ay][am][1]][am];
}
num[r][ay][am][1]++;
if(num[r][ay][am][1]==5)
{
win=am;
}
for(t=0;t<5;t++)
{
goal[r+t][ay][am]=goal[r+t][ay][am]+quan[num[r][ay][am][1]][am];
}
}
else if(num[r][ay][an][1]!=6)
{
for(t=0;t<5;t++)
{
goal[r+t][ay][an]=goal[r+t][ay][an]-quan[num[r][ay][an][1]][an];
}
num[r][ay][am][1]=6;
num[r][ay][an][1]=6;
}
}
}
/*2方向判断*/
beginx=ax-4;beginy=ay-4;
if(beginx<0)
{
beginy=beginy-beginx;
beginx=0;
}
if(beginy<0)
{
beginx=beginx-beginy;
beginy=0;
}
endx=ax+4;endy=ay+4;
if(endx>14)
{
endy=endy-endx+14;
endx=14;
}
if(endy>14)
{
endx=endx-endy+14;
endy=14;
}
endx=endx-4;endy=endy-4;
if(beginx<=endx)
{
for(r=beginx;r<endx+1;r++)
{
if(num[r][beginy-beginx+r][am][2]!=6)
{
num[r][beginy-beginx+r][an][2]=6;
for(t=0;t<5;t++)
{
goal[r+t][beginy-beginx+r+t][am]=goal[r+t][beginy-beginx+r+t][am]-quan[num[r][beginy-beginx+r][am][2]][am];
}
num[r][beginy-beginx+r][am][2]++;
if(num[r][beginy-beginx+r][am][2]==5)
{
win=am;
}
for(t=0;t<5;t++)
{
goal[r+t][beginy-beginx+r+t][am]=goal[r+t][beginy-beginx+r+t][am]+quan[num[r][beginy-beginx+r][am][2]][am];
}
}
else if(num[r][beginy-beginx+r][an][2]!=6)
{
for(t=0;t<5;t++)
{
goal[r+t][beginy-beginx+r+t][an]=goal[r+t][beginy-beginx+r+t][an]-quan[num[r][beginy-beginx+r][an][2]][an];
}
num[r][beginy-beginx+r][am][2]=6;
num[r][beginy-beginx+r][an][2]=6;
}
}
}
/*3方向判断*/
{
beginy=ay-4;beginx=ax;
if(beginy<0)
{
beginy=0;
}
endy=ay+4;endx=ax;
if(endy>14)
{
endy=14;
}
endy=endy-4;
for(r=beginy;r<endy+1;r++)
{
if(num[ax][r][am][3]!=6)
{
num[ax][r][an][3]=6;
for(t=0;t<5;t++)
{
goal[ax][r+t][am]=goal[ax][r+t][am]-quan[num[ax][r][am][3]][am];
}
num[ax][r][am][3]++;
if(num[ax][r][am][3]==5)
{
win=am;
}
for(t=0;t<5;t++)
{
goal[ax][r+t][am]=goal[ax][r+t][am]+quan[num[ax][r][am][3]][am];
}
}
else if(num[ax][r][an][3]!=6)
{
for(t=0;t<5;t++)
{
goal[ax][r+t][an]=goal[ax][r+t][an]-quan[num[ax][r][an][3]][an];
}
num[ax][r][am][3]=6;
num[ax][r][an][3]=6;
}
}
}
}
void findmax(char m,char n)
{
char i,j;
a=0;
b=0;
maxgoal=-1;
for(i=0;i<15;i++)
{
for(j=0;j<15;j++)
{
if(state[i][j]==2)
{
if(goal[i][j][m]>maxgoal)
{
a=i;
b=j;
maxgoal=goal[i][j][m];
}
else if(goal[i][j][m]==maxgoal)
{
if(goal[i][j]
>goal[a][b]
)
{
a=i;
b=j;
maxgoal=goal[i][j][m];
}
else if(goal[i][j]
==goal[a][b]
)
{
if(random(2))
{
a=i;
b=j;
maxgoal=goal[i][j][m];
}
}
}
}
}
}
}
void menu()
{
setcolor(RED);
settextstyle(0,0,3);
outtextxy(150,150,"Player first");
outtextxy(150,180,"Computer first");
outtextxy(150,210,"Exit");
}
int show(int y)
{
int oy=0;
char ch=0;
cleardevice();
setbkcolor(BLACK);
setcolor(BLUE);
settextstyle(0,0,4);
outtextxy(200,40,"GOBANG");
settextstyle(0,0,2);
outtextxy(350,90,"www.vcworld.net");
setcolor(WHITE);
settextstyle(0,0,2);
outtextxy(40,280,"operate handbook:");
outtextxy(100,310,"Up,Down,Left,Right key to move");
outtextxy(100,340,"Enter key for sure");
outtextxy(100,370,"H key for help");
outtextxy(100,400,"Esc key to exit");
outtextxy(440,430,"version:1.0");
while(ch!=enter)
{
if((ch==down||ch==right)&&y!=210)
y+=30;
else if((ch==up||ch==left)&&y!=150)
y-=30;
if(oy!=y)
{
setfillstyle(0,BLACK);
bar(140,oy-2,490,oy+24);
setfillstyle(1,BLUE);
bar(140,y-2,490,y+24);
menu();
oy=y;
}
ch=getch();
}
return y;
}
void step(int step)
{
char s[4];
sprintf(s,"%d",step);
setcolor(BLACK);
setfillstyle(1,BLACK);
bar(22,239,100,269);
setcolor(BLUE);
settextstyle(0,0,3);
outtextxy(10,210,"STEP");
outtextxy(23,240,s);
}
void fun(int t)
{
setcolor(BLACK);
setfillstyle(1,BLACK);
bar(539,100,639,300);
setcolor(BLUE);
settextstyle(0,0,3);
if(t==1)
{
outtextxy(540,210," ");
outtextxy(540,240," ");
}
else if(t==0)
{
outtextxy(540,195,"Your");
outtextxy(540,225,"turn");
setcolor(RED);
setfillstyle(1,RED);
pieslice(590,270,0,360,11);
}
else if(t==2)
{
outtextxy(540,210,"Exit");
outtextxy(540,240,"y/n ");
}
else if(t==3)
{
setcolor(RED);
outtextxy(540,210,"You ");
outtextxy(540,240,"win ");
}
else if(t==4)
{
setcolor(RED);
outtextxy(540,210,"You ");
outtextxy(540,240,"lose");
}
else if(t==5)
{
setcolor(RED);
outtextxy(540,210,"GAME");
outtextxy(540,240,"OVER");
}
}
void pan()
{
int r;
cleardevice();
setcolor(WHITE);
for(r=1;r<15;r++)
{
rectangle(124,44,124+r*28,44+r*28);
rectangle(516,436,516-r*28,436-r*28);
}
rectangle(106,26,534,454);
rectangle(105,25,535,455);
rectangle(107,27,533,453);
}
void curr(int co)
{
setcolor(co);
line(x-15,y-10,x-10,y-10);
line(x-10,y-10,x-10,y-15);
line(x+10,y-15,x+10,y-10);
line(x+10,y-10,x+15,y-10);
line(x-15,y+10,x-10,y+10);
line(x-10,y+10,x-10,y+15);
line(x+10,y+10,x+10,y+15);
line(x+10,y+10,x+15,y+10);
}
main()
{
int gd=DETECT,gm,turn,oa,ob,omax;
char ch,i1,i2,i3,i4;
registerbgidriver(EG***GA_driver);
initgraph(&gd,&gm,"");
begin:
for(i1=0;i1<15;i1++)
for(i2=0;i2<15;i2++)
{
state[i1][i2]=2;
for(i3=0;i3<2;i3++)
{
goal[i1][i2][i3]=0;
for(i4=0;i4<4;i4++)
num[i1][i2][i3][i4]=0;
}
}
win=2;s=0;
turn=(show(150)-150)/30;
if(turn==2)
exit(0);
else
{
pan();
if(turn==1)
{
randomize();
a=random(7)+4;
randomize();
b=random(7)+4;
ai(a,b,1,0);
state[a][b]=turn;
s++;
step(s);
turn=0;
x=124+28*a;y=44+28*b;
setcolor(GREEN);
setfillstyle(1,GREEN);
pieslice(x,y,0,360,11);
curr(WHITE);
}
else
{
a=7;
b=7;
x=124+28*a;
y=44+28*b;
curr(WHITE);
step(0);
}
}
while(win==2&&s<225)
{
if(turn==1)
{
fun(1);
findmax(0,1);
omax=maxgoal;oa=a;ob=b;
findmax(1,0);
if(omax>maxgoal)
{
a=oa;
b=ob;
}
else if(omax==maxgoal)
{
if(goal[oa][ob][1]>goal[a][b][0])
{
a=oa;
b=ob;
}
else if(goal[oa][ob][1]==goal[a][b][0])
{
if(random(2))
{
a=oa;
b=ob;
}
}
}
ai(a,b,1,0);
state[a][b]=turn;
s++;
step(s);
turn=0;
x=124+28*a;
y=44+28*b;
setcolor(GREEN);
setfillstyle(1,GREEN);
pieslice(x,y,0,360,11);
curr(WHITE);
}
else
{
fun(0);
ch=getch();
while(ch!=enter)
{
if(ch==esc)
{
fun(2);
if(getch()==y_key)
goto begin;
fun(0);
}
else if(ch==h_key)
{
curr(BLACK);
findmax(1,0);
omax=maxgoal;
oa=a;
ob=b;
findmax(0,1);
x=a;
y=b;
if(omax>maxgoal)
{
a=oa;
b=ob;
}
else if(omax==maxgoal)
{
if(goal[oa][ob][0]>goal[a][b][1])
{
a=oa;
b=ob;
}
else if(goal[oa][ob][0]==goal[a][b][1])
{
if(random(2))
{
a=oa;
b=ob;
}
}
}
x=124+28*a;
y=44+28*b;
curr(WHITE);
}
else if(ch==up)
{
curr(BLACK);
b--;
if(b<0)
b=14;
x=124+28*a;
y=44+28*b;
curr(WHITE);
}
else if(ch==down)
{
curr(BLACK);
b++;
if(b>14)
b=0;
x=124+28*a;
y=44+28*b;
curr(WHITE);
}
else if(ch==left)
{
curr(BLACK);
a--;
if(a<0)
a=14;
x=124+28*a;
y=44+28*b;
curr(WHITE);
}
else if(ch==right)
{
curr(BLACK);
a++;
if(a>14)
a=0;
x=124+28*a;
y=44+28*b;
curr(WHITE);
}
ch=getch();
}
}
if(state[a][b]==2)
{
curr(BLACK);
ai(a,b,0,1);
state[a][b]=turn;
x=124+28*a;
y=44+28*b;
turn=1;
s++;
step(s);
setcolor(RED);
setfillstyle(1,RED);
pieslice(x,y,0,360,11);
}
}
curr(WHITE);
fun(win+3);
getch();
goto begin;
}
相关文章推荐
- Invalid MyEclipse License - Discontinuing this MyEclipse operation. 出现这个错误怎么改正?
- H. 封印之门(单向路,不知道脑子怎么了,直接就是双向路)
- 你怎么看待《在今天这个故事里,阿里巴巴就是四十大盗》
- 已经添加了服务引用,不知道怎么传用户名密码,不传的话报验证信息错误
- 嗨,睡觉吧,如果让猪猪知道了还不知道怎么生气呢,反正就是睡不着。
- 不知道怎么用这个博客
- pdf转word不知道怎么办?这个超使用的转换技巧你身边的人都不一定知道!
- 这个是看别人改的代码。但是有错误,,,找不到方法来改正错误。。。。今天编了一天的代码,脑细胞都要死完了。真心觉得计算机的工作不好做的啊,好好加油啊。。我的代码啊,不懂了!下面的有错误啊。
- win10系统IIS开启ASP程序错误信息怎么调试?
- 调试的错误就是编程给你最好的东西,因为在每个错误上面都标志着前进的一步
- linux中怎么用右键选项中直接打开终端 tar xzvf abc.tar.gz -C tmp上面的命令将abc.tar.gz这个压缩包解压到当前目录下的tmp目录下,而不是当前目录下,这就是-C
- 穆利堂推荐:员工效率低下怎么办?工作日志,就是解决这个问题的一种简单办法。
- vs2008下debug调试无错误,release调试出错怎么回事
- Attribute class invalid for tag text according to TLD这个struts错误怎么解决啊
- 调试时出现:“没有找到 MSVCR80D.dll,因此这个程序未能启动,重新安装应用程序,可能会修复此问题”错误提示,如何解决?
- 这个VB.NET程序老难了,哪位高手能帮下忙看看,解释下错误,改正下,实在是太感谢了
- swift怎么解决错误提示 'required' initializer 'init(coder:)' must be...这个问题
- 调试ASP程序时,遇到程序运行错误时怎么查看具体错误位置呢?
- gsoap2.8.16在生成头文件时报这个的错误,怎么解决
- 1181链表最好先插入再排序,刚开始边插入边排序不知道怎么出现了错误,以后尽量插入排序分开吧