wzq.cpp
资源名称:高级五子棋.rar [点击查看]
上传用户:sjsmail
上传日期:2009-08-28
资源大小:260k
文件大小:19k
源码类别:
棋牌游戏
开发平台:
Visual C++
- #include "stdafx.h"
- #include "7.h"
- #include "wzq.h"
- #include "dim.h"
- #ifdef _DEBUG
- #undef THIS_FILE
- static char THIS_FILE[]=__FILE__;
- #define new DEBUG_NEW
- #endif
- wzq::wzq(CDC2*tqp,CDC2*tqzh,CDC2*tqzb,CDC2*tmask,CDC2*dead,CDC*dc)
- {
- SetDc(tqp,tqzh,tqzb,tmask,dead,dc);
- }
- /*___________________________________________________________________________________________*/
- wzq::~wzq(){}
- /*___________________________________________________________________________________________*/
- wzq::wzq()
- { wzq::dcseted=false; }
- /*___________________________________________________________________________________________*/
- void wzq::DrawQZ(int nx,int ny,bool style)//画棋子
- {
- if (wzq::dcseted==false)return;
- if (nx>15||ny>15) return;
- if (style==false )
- {
- dc->BitBlt(nx*29+7,ny*29+7,28,28,mask,0,0,MERGEPAINT);
- dc->BitBlt(nx*29+7,ny*29+7,28,28,qzb,0,0,SRCAND);
- }
- else
- {
- dc->BitBlt(nx*29+7,ny*29+7,28,28,mask,0,0,MERGEPAINT);
- dc->BitBlt(nx*29+7,ny*29+7,28,28,qzh,0,0,SRCAND);
- }
- }
- /*___________________________________________________________________________________________*/
- void wzq::SetDc(CDC2*tqp,CDC2*tqzh,CDC2*tqzb,CDC2*tmask,CDC2*dead,CDC*dc)//设置DC
- {
- wzq::mask =tmask;
- wzq::qp =tqp;
- wzq::qzb =tqzb;
- wzq::qzh =tqzh;
- wzq::dc =dc;
- wzq::dead=dead;
- wzq::dcseted=true;
- }
- /*___________________________________________________________________________________________*/
- void wzq::NewGame()//新游戏
- {
- if (wzq::dcseted==false)return;
- for(int i1=0 ; i1<=14;i1++)
- {
- for(int i2=0 ; i2<=14;i2++)
- {
- map[i1][i2]=0;
- for(int i3=0 ; i3<=3;i3++)
- {
- user[i1][i2][i3]=255;
- pc[i1][i2][i3]=255;
- }
- }
- }
- for (int ix=0;ix<225;ix++)
- {
- wzq::wzs[ix].used=false;
- }
- CSize x=qp->GetSize();
- dc->BitBlt(0, 0,x.cx,x.cy,qp,0,0,SRCCOPY);//画棋盘
- wzq::twinner.winner=0;
- wzq::nturn=0;
- wzq::nowd2 =0;
- if (wzq::Model==1)
- {
- userBd(7,7);
- }
- }
- /*___________________________________________________________________________________________*/
- void wzq::draw()//重画
- {
- if (wzq::dcseted==false)return;
- CSize x=qp->GetSize() ;
- dc->BitBlt(0, 0,x.cx,x.cy,qp,0,0,SRCCOPY);//画棋盘
- for(int i1=0 ; i1<15;i1++)
- {
- for(int i2=0 ; i2<15;i2++)
- {
- if (map[i1][i2]==1){this->DrawQZ(i1,i2,false);}
- else{if (map[i1][i2]==2){this->DrawQZ(i1,i2,true);}}
- }
- }
- if (wzq::twinner.winner!=0)
- {
- int x1=wzq::twinner.nx1 , y1=wzq::twinner.ny1;
- int xj,yj;
- if(wzq::twinner.nx2-wzq::twinner.nx1>0)
- {
- xj=1;
- }
- else
- {
- if (wzq::twinner.nx2-wzq::twinner.nx1==0)
- {
- xj=0;
- }
- else
- {
- xj=-1;
- }
- }
- if(wzq::twinner.ny2-wzq::twinner.ny1>0)
- {
- yj=1;
- }
- else
- {
- if (wzq::twinner.ny2-wzq::twinner.ny1==0)
- {
- yj=0;
- }
- else
- {
- yj=-1;
- }
- }
- if (wzq::twinner.winner!=0)
- {
- for (int ii=1 ; ii<=5 ; ii++)
- {
- dc->BitBlt(x1*29+7,y1*29+7,28,28,mask,0,0,MERGEPAINT);
- dc->BitBlt(x1*29+7,y1*29+7,28,28,dead,0,0,SRCAND);
- x1+=xj;
- y1+=yj;
- }
- }
- }
- }
- /*___________________________________________________________________________________________*/
- bool wzq::userAd(int nx,int ny)//黑色下子
- {
- if (wzq::dcseted==false)return false;
- if (map[nx][ny]==0)
- {
- map[nx][ny]=1;
- DrawQZ(nx,ny,false);
- return true;
- }
- else
- {
- return false;
- }
- wzq::DrawQZ(nx,ny,true);
- }
- /*___________________________________________________________________________________________*/
- bool wzq::userBd(int nx,int ny)//白色下子
- {
- if (wzq::dcseted==false)return false;
- if (map[nx][ny]==0)
- {
- map[nx][ny]=2;
- DrawQZ(nx,ny,true);
- return true;
- }
- else
- {
- return false;
- }
- wzq::DrawQZ(nx,ny,false);
- }
- /*__________________________________________________________________________________________*/
- bool wzq::bewinner2(bool style,int nx,int ny)//胜败
- {
- int tx1=0,tx2=0,ty1=0,ty2=0;
- int yx1=0,yx2=0,yy1=0,yy2=0;
- int st=(int)style+1;
- for (int x1=-5 ; x1<= 5 ; x1++)
- {
- if (map[nx+x1][ny]==st)
- {
- tx1++;
- if (tx1==1) yx1=x1;
- if (tx1>=5)
- {
- twinner.winner =st;
- twinner.nx1= nx+yx1;
- twinner.nx2 =nx+yx1+5;
- twinner.ny1 =ny;
- twinner.ny2 =ny;
- return true;
- }
- }
- else
- {
- tx1=0;
- }
- if (map[nx][ny+x1]==st)
- {
- ty1++;
- if (ty1==1) yy1=x1;
- if (ty1>=5)
- {
- twinner.winner =st;
- twinner.nx1= nx;
- twinner.nx2 =nx;
- twinner.ny1 =ny+yy1;
- twinner.ny2 =ny+yy1+5;
- return true;
- }
- }
- else
- {
- ty1=0;
- }
- if (map[nx+x1][ny+x1]==st)
- {
- tx2++;
- if (tx2==1) yx2=x1;
- if (tx2>=5)
- {
- twinner.winner =st;
- twinner.nx1= nx+yx2;
- twinner.nx2 =nx+yx2+5;
- twinner.ny1 =ny+yx2;
- twinner.ny2 =ny+yx2+5;
- return true;
- }
- }
- else
- {
- tx2=0;
- }
- if (map[nx+x1][ny-x1]==st)
- {
- ty2++;
- if (ty2==1) yy2=x1;
- if (ty2>=5)
- {
- twinner.winner =st;
- twinner.nx1= nx+yy2;
- twinner.nx2 =nx+yy2+5;
- twinner.ny1 =ny-yy2;
- twinner.ny2 =ny-yy2-5;
- return true;
- }
- }
- else
- {
- ty2=0;
- }
- }
- return false;
- }
- /*__________________________________________________________________________________________*/
- bool wzq::downzi(int nx,int ny)//外部调用此函数下子
- {
- bool turnback;
- if (nx<0||nx>14||ny<0||nx>14) return false;
- if (wzq::nturn==-1)return false;
- if (wzq::Model==2 )
- {
- if (wzq::nturn==1)
- {
- turnback=userAd(nx,ny);
- if (bewinner2(false,nx,ny)==true)wzq::nturn=-1;
- wzq::nturn =turnback?0:1;
- setback(nx,ny,false);
- }
- else
- {
- turnback=userBd(nx,ny);
- if(bewinner2(true,nx,ny)==true)wzq::nturn =-1;
- wzq::nturn =turnback?1:0;
- setback(nx,ny,true);
- }
- }
- else
- {
- if (wzq::Model==1)
- {
- if (userAd(nx,ny)==false)return false;
- if(bewinner2(false,nx,ny)==true)wzq::nturn =-1;
- CPoint aigo=wzq::AiGo(true);
- setback(nx,ny,false);
- userBd(aigo.x,aigo.y);
- setback(aigo.x,aigo.y,true);
- if(bewinner2(true,aigo.x,aigo.y)==true)wzq::nturn =-1;
- }
- else
- {
- if (wzq::Model==0)
- {
- if (userBd(nx,ny)==false)return false;
- if(bewinner2(true,nx,ny)==true)wzq::nturn =-1;
- CPoint aigo=wzq::AiGo(false);
- setback(nx,ny,true);
- userAd(aigo.x,aigo.y);
- setback(aigo.x,aigo.y,false);
- if(bewinner2(false,aigo.x,aigo.y)==true)wzq::nturn =-1;
- }
- }}
- return turnback;
- }
- /*____________________________________________________________________________________*/
- bool wzq::goback()//悔棋
- { if (wzq::getbackble==false) return false;
- wzq::nowd2--;
- if (wzq::Model==2)
- {
- map[wzq::wzs[nowd2].ix][wzq::wzs[nowd2].iy]=0;
- wzq::nturn= wzq::wzs[nowd2].color ;
- wzq::wzs[nowd2].used=false;
- wzq::dc->BitBlt(wzq::wzs[nowd2].ix*29+7,wzq::wzs[nowd2].iy*29+7,28,28,wzq::qp,wzq::wzs[nowd2].ix*29+7,wzq::wzs[nowd2].iy*29+7,SRCCOPY);
- }
- else
- {
- map[wzq::wzs[nowd2].ix][wzq::wzs[nowd2].iy]=0;
- wzq::wzs[nowd2].used=false;
- wzq::dc->BitBlt(wzq::wzs[nowd2].ix*29+7,wzq::wzs[nowd2].iy*29+7,28,28,wzq::qp,wzq::wzs[nowd2].ix*29+7,wzq::wzs[nowd2].iy*29+7,SRCCOPY);
- wzq::nowd2--;
- map[wzq::wzs[nowd2].ix][wzq::wzs[nowd2].iy]=0;
- wzq::wzs[nowd2].used=false;
- wzq::dc->BitBlt(wzq::wzs[nowd2].ix*29+7,wzq::wzs[nowd2].iy*29+7,28,28,wzq::qp,wzq::wzs[nowd2].ix*29+7,wzq::wzs[nowd2].iy*29+7,SRCCOPY);
- }
- if (wzq::twinner.winner!=0)
- {
- wzq::twinner.winner =0;
- wzq::draw();
- }
- return false;
- }
- /*__________________________________________________________________________________________*/
- bool wzq::bejs(int nx,int ny)
- {
- /*++此处添加禁手控制++*/
- //因为我不熟悉五子棋的规则,所以没有设置禁手
- return false;
- }
- /*__________________________________________________________________________________________*/
- void wzq::fillin(bool color,bool player,bool type)
- {
- int ix,iy;
- for (ix=0 ;ix<=14;ix++)
- {
- for (iy=0 ;iy<=14;iy++)
- {
- if (map[ix][iy]==0)
- {
- for (int im=0 ; im<=3 ; im++)
- {
- setqx(ix,iy,color,player,im,type);
- }
- }
- }
- }
- }
- /*__________________________________________________________________________________________*/
- void wzq::setqx(int nx ,int ny,bool style,bool player,int st,bool type)
- {
- bool ok=true;
- int ia,ib;
- int ix,iy;
- int i2,i2j;
- int tem1,tem2;
- int x;
- int i3;
- int m1,m3;
- int i;
- int wx=nx,wy=ny,tem3=0;
- switch (st)
- {
- case 0:
- i2=1,i2j=0;break;
- case 1:
- i2=0,i2j=1;break;
- case 2:
- i2=1,i2j=1;break;
- case 3:
- i2=1,i2j=-1;break;
- }
- unsigned char temp3[15]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
- unsigned char temp4[15]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
- begin:
- if (map[wx][wy]!=0)return;
- i3=0;
- ix=i2;
- iy=i2j;
- ia=1,ib=1;
- //right==========================================================================================//
- x=map[wx-ix][wy-iy];
- while(!(x!=(int)style+1||wx-ix<0||wy-iy<0))
- {
- ia++;
- ix+=i2;
- iy+=i2j;
- x=map[wx-ix][wy-iy];
- }
- ix=i2,iy=i2j;
- //left====================================================================================//
- x=map[wx+ix][wy+iy];
- while(!(x!=(int)style+1||wx+ix>14||wy+iy>14))
- {
- ix+=i2;
- iy+=i2j;
- ib++;
- x=map[wx+ix][wy+iy];
- }
- //偏移=======================================================================================//
- if (ib==1&&ia==1)
- {
- if (tem3==0)
- {
- wx+=i2,wy+=i2j;
- tem3=1;
- goto begin;
- }
- else
- {
- if (tem3==1)
- {
- wx-=i2*2,wy-=i2j*2;
- tem3=2;
- goto begin;
- }
- else
- {
- if (tem3==2)return;
- }
- }
- }
- ix=0,iy=0;
- switch (st)
- {
- case 0:
- {
- m1=(ia!=1&&ib==1),m3=(ib!=1&&ia==1);
- for(i=0; i<1+ia+ib;i++)
- {
- tem1=wx-ia+ix-m1;
- if (tem1<0||tem1>14){ix+=1;continue;}
- x=map[tem1][wy];
- temp3[i3]=ntoc(x,type,style);
- ix+=1;
- i3++;
- }
- ix=0,i3=0;
- for (i=0 ; i<1+ia+ib;i++)
- {
- tem1=wx+ib-ix+m3;
- if (tem1<0||tem1>14){ix+=1;continue;}
- x=map[tem1][wy];
- temp4[i3]=ntoc(x,type,style);
- ix+=1;
- i3++;
- }
- break;
- }
- case 1:
- {
- m1=(ia!=1&&ib==1),m3=(ib!=1&&ia==1);
- for(i=0; i<1+ia+ib;i++)
- {
- tem1=wy-ia+iy-m1;
- if (tem1<0||tem1>14){iy+=1;continue;}
- x=map[wx][tem1];
- temp3[i3]=ntoc(x,type,style);
- iy+=1;
- i3++;
- }
- iy=0,i3=0;
- for (i=0 ; i<1+ia+ib;i++)
- {
- tem1=wy+ib-iy+m3;
- if (tem1<0||tem1>14){iy+=1;continue;}
- x=map[wx][tem1];
- temp4[i3]=ntoc(x,type,style);
- iy+=1;
- i3++;
- }
- break;
- }
- break;
- case 2:
- {
- m1=(ia!=1&&ib==1),m3=(ib!=1&&ia==1);
- for (i=0 ; i<1+ia+ib ; i++)
- {
- tem1=wx-ia+ix-m1;
- tem2=wy-ia+iy-m1;
- if (tem1<0||tem1>14||tem2<0||tem2>14){ix+=1,iy+=1;continue;}
- x=map[tem1][tem2];
- temp3[i3]=ntoc(x,type,style);
- iy+=1;
- ix+=1;
- i3++;
- }
- iy=0,ix=0,i3=0;
- for (i=0 ; i<1+ia+ib ; i++)
- {
- tem1=wx+ib-ix+m3;
- tem2=wy+ib-iy+m3;
- if (tem1<0||tem1>14||tem2<0||tem2>14){ix+=1,iy+=1;continue;}
- x=map[tem1][tem2];
- temp4[i3]=ntoc(x,type,style);
- iy+=1;
- ix+=1;
- i3++;
- }
- break;
- }
- case 3:
- {
- m1=(ia!=1&&ib==1),m3=(ib!=1&&ia==1);
- for (i=0 ; i<1+ia+ib ; i++)
- {
- tem1=wx-ia+ix-m1;
- tem2=wy+ia+iy+m1;
- if (tem1<0||tem1>14||tem2<0||tem2>14){ix+=1,iy-=1;continue;}
- x=map[tem1][tem2];
- temp3[i3]=ntoc(x,type,style);
- iy-=1;
- ix+=1;
- i3++;
- }
- iy=0,ix=0,i3=0;
- for (i=0 ; i<1+ia+ib ; i++)
- {
- tem1=wx+ib-ix+m3;
- tem2=wy-ib-iy-m3;
- if (tem1<0||tem1>14||tem2<0||tem2>14){ix+=1,iy+=1;continue;}
- x=map[tem1][tem2];
- temp4[i3]=ntoc(x,type,style);
- iy-=1;
- ix+=1;
- i3++;
- }
- break;
- }
- };
- //tj===================================================//
- if ( (strcmp("00H0",(const char *)&temp3[1])==0 || strcmp("00H0",(const char *)&temp4[1])==0 || strcmp("00H0",(const char *)&temp3[0])==0 || strcmp("00H0",(const char *)&temp4[0])==0)&&tem3!=0)return;
- if ( (strcmp("00B0",(const char *)&temp3[1])==0 || strcmp("00B0",(const char *)&temp4[1])==0 || strcmp("00B0",(const char *)&temp3[0])==0 || strcmp("00B0",(const char *)&temp4[0])==0)&&tem3!=0)return;
- if ( (strcmp("00HHHB",(const char *)&temp3[1])==0 || strcmp("00HHHB",(const char *)&temp4[1])==0 || strcmp("00HHHB",(const char *)&temp3[0])==0 || strcmp("00HHHB",(const char *)&temp4[0])==0)&&tem3!=0)return;
- /*++此处添加更多的屏蔽++*/
- if (tem3==0)
- {for (i=0 ; i<=61 ; i++)
- {
- if (strcmp(wds[i],(const char *)&temp3[1])==0||strcmp(wds[i],(const char *)&temp4[1])==0||strcmp(wds[i],(const char *)&temp3[0])==0||strcmp(wds[i],(const char *)&temp4[0])==0)
- {
- if (player==false)
- {
- pc[nx][ny][st]=i;
- return;
- }
- else
- {
- user[nx][ny][st]=i;
- return;
- }
- }
- }
- }
- else
- {
- for (i=0 ; i<=61 ; i++)
- {
- if (strcmp(wds[i],(const char *)&temp3[0])==0||strcmp(wds[i],(const char *)&temp4[0])==0)
- {
- if (player==false)
- {
- pc[nx][ny][st]=i;
- return;
- }
- else
- {
- user[nx][ny][st]=i;
- return;
- }
- }
- }
- }
- }
- /*__________________________________________________________________________________________*/
- CPoint wzq::AiGo(bool color)
- {
- CPoint turnback(-1,-1);
- clear(false);
- fillin(color,false,true);
- fillin(!color,false,false);
- wzq::aitype2 =getaitype();
- unsigned char found=255;
- for (int ix=0 ;ix<=14;ix++)
- {
- for (int iy=0 ;iy<=14;iy++)
- {
- for (int im=0 ; im<=3 ; im++)
- {
- if (pc[ix][iy][im]<=found)
- {
- found=pc[ix][iy][im];
- turnback.x=ix,turnback.y=iy;
- }
- }
- }
- }
- if (found<=23)
- return turnback;
- else
- return getmax(color);
- }
- /*__________________________________________________________________________________________*/
- void wzq::setall()
- {
- for (int ix=0 ;ix<=14;ix++)
- {
- for (int iy=0 ;iy<=14;iy++)
- {
- wzq::nicest2[ix][iy]=0;
- }
- }
- }
- /*____________________________________________________________________________________*/
- char wzq::ntoc(char num,bool type,bool style)
- {
- if (num==0)
- return '0';
- else
- if (type==true)
- {
- if (num==(int)style+1)
- return 'H';
- else
- return 'B';
- }
- else
- {
- if (num!=(int)style+1)
- return 'H';
- else
- return 'B';
- }
- }
- /*_____________________________________________________________________________________*/
- void wzq::checkgo(int x,int y,bool color,int nu,int inx,int iny)//预测函数
- {
- wzq::trygo[x][y]=(char)color+1;
- clear(true);
- fillin(color,true,true);
- fillin(!color,true,false);
- CPoint temp=getbg(true);
- bool four1=false,four2=false,three1=false,three2=false;
- bool four3=false,four4=false,three3=false,three4=false;
- for (int i=0 ; i<=3 ; i++)
- {
- if (user[temp.x][temp.y][i]>=3&&user[temp.x][temp.y][i]<=5)
- {
- wzq::nicest2[inx][iny]=2;//lose
- return;
- }
- else
- {
- if (user[temp.x][temp.y][i]<3)//win
- {
- wzq::nicest2[inx][iny]=1;
- return;
- }
- else
- {
- if (user[temp.x][temp.y][i]>=6&&user[temp.x][temp.y][i]<=14)
- {
- if(four1==true)four2=true;else four1=true;
- }
- else
- {
- if (user[temp.x][temp.y][i]>=15&&user[temp.x][temp.y][i]<=23)
- {
- if(four3==true)four4=true;else four3=true;
- }
- else
- {
- if (user[temp.x][temp.y][i]==24||user[temp.x][temp.y][i]==25)
- {
- if(three1==true)three2=true;else three1=true;
- }
- else
- {
- if (user[temp.x][temp.y][i]==26||user[temp.x][temp.y][i]==27)
- {
- if(three3==true)three4=true;else three3=true;
- }
- }
- }
- }
- }
- }
- }/*++此处添加更多的胜败判断++*/
- if (three1+three2+four1+four2>=2)
- {
- wzq::nicest2[inx][iny]=1;//lose
- return;
- }
- else
- {
- if (three3+three4+four3+four4>=2)
- {wzq::nicest2[inx][iny]=2;//win
- return;
- }
- }
- if (nu>=wzq::aitype2)
- {
- wzq::nicest2[inx][iny]=3;
- return;
- }
- int xxx=nu+1;
- checkgo(temp.x ,temp.y ,!color,xxx,inx,iny);
- }
- /*_____________________________________________________________________________________*/
- CPoint wzq::getmax(bool color)
- {
- CPoint turnback(0,0);
- setall();
- begin:
- bool x=0;
- int fx=0,fy=1;
- for (int ix=0 ;ix<=14;ix++)
- {
- for (int iy=0;iy<=14;iy++)
- {
- if (wzq::nicest2[ix][iy]==0)
- {
- if (bj2(ix,iy,fx,fy,false)==true)
- fx=ix,fy=iy,x=1;
- }
- }
- }
- //找最大
- //if (x==-1){turnback.x=7,turnback.y=7;return turnback;}//如果第一步返回7,7
- if (x==0)
- {x=0;
- for (int ix=0 ;ix<=14;ix++)
- {
- for (int iy=0 ;iy<=14;iy++)
- {
- if (wzq::nicest2[ix][iy]!=1/*不输*/)
- {
- if (bj2(ix,iy,turnback.x,turnback.y,false)==true)turnback.x=ix,turnback.y=iy,x=1;
- }
- }
- }
- if (x==0)
- {x=0;
- for (int ix=0 ;ix<=14;ix++)
- {
- for (int iy=0 ;iy<=14;iy++)
- {
- if (bj2(ix,iy,turnback.x,turnback.y,false)==true)turnback.x=ix,turnback.y=iy,x=1;
- }
- }
- }
- if (x==0)turnback.x =7,turnback.y =7;
- return turnback;
- }//找完
- for (ix=0 ;ix<=14;ix++)
- {
- for (int iy=0 ;iy<=14;iy++)
- {
- wzq::trygo[ix][iy]=wzq::map[ix][iy];
- }
- }
- //填
- wzq::checkgo(fx,fy, color,1,fx,fy);
- //预测
- if (nicest2[fx][fy]==2)//win
- {
- turnback.x=fx,turnback.y=fy;
- return turnback;
- }
- else
- {
- goto begin;//重来一次
- }
- //判断
- }
- /*_____________________________________________________________________________________*/
- CPoint wzq::getbg(bool style )
- {
- CPoint turnback;
- int ix1=0,iy1=0;
- for (int ix=0 ;ix<=14;ix++)
- {
- for (int iy=0 ;iy<=14;iy++)
- {
- if (bj2(ix,iy,ix1,iy1,style)==true)
- {
- ix1=ix,iy1=iy;
- }
- }
- }
- turnback.x=ix1;
- turnback.y=iy1;
- return turnback;
- }
- /*_____________________________________________________________________________________*/
- bool wzq::bj2(int x1,int y1,int x2,int y2,bool style)
- {
- unsigned char a[4];
- unsigned char b[4];
- unsigned char temp1;
- int i;
- if (style==false)
- {
- for (i=0 ; i<=3 ;i++)
- {a[i]=1;
- a[i]=pc[x1][y1][i];
- b[i]=pc[x2][y2][i];
- }
- }
- else
- {
- for (i=0 ; i<=3 ;i++)
- {a[i]=1;
- a[i]=user[x1][y1][i];
- b[i]=user[x2][y2][i];
- }
- }
- //...
- for (i=0 ; i<=3 ; i++)
- {
- for (int i2=0 ; i2<=2-i; i2++)
- {
- if (a[i2]>a[i2+1])
- {
- temp1=a[i2];
- a[i2]=a[i2+1];
- a[i2+1]=temp1;
- }
- if (b[i2]>b[i2+1])
- {
- temp1=b[i2];
- b[i2]=b[i2+1];
- b[i2+1]=temp1;
- }
- }
- }
- //冒泡排序
- for (i=0 ; i<=3 ; i++)
- {
- if (a[i]<b[i])
- {
- return true;
- }
- else
- {
- if (a[i]>b[i])
- {
- return false;
- }
- }
- }
- return false;
- }
- void wzq::clear(bool style)
- {
- int ix,iy;
- if (style==false)
- for ( ix=0 ;ix<=14;ix++)
- {
- for (iy=0 ;iy<=14;iy++)
- {
- for (int im=0 ; im<=3 ; im++)
- {
- wzq::pc[ix][iy][im]=255;
- }
- }
- }
- else
- {
- for (ix=0 ;ix<=14;ix++)
- {
- for (iy=0 ;iy<=14;iy++)
- {
- for (int im=0 ; im<=3 ; im++)
- {
- wzq::user[ix][iy][im]=255;
- }
- }
- }
- }
- }
- int wzq::getaitype()
- {
- if (wzq::AItype==0)
- return 6;
- else
- if (wzq::AItype==1)
- return 10;
- else
- if (wzq::AItype==2 )
- return 20;
- else
- return 10;
- }
- void wzq::setback(int nx,int ny,bool style)
- {
- wzq::wzs[wzq::nowd2].used=true;
- wzq::wzs[wzq::nowd2].color=style;
- wzq::wzs[wzq::nowd2].ix =nx;
- wzq::wzs[wzq::nowd2].iy =ny;
- wzq::nowd2++;
- }