欢迎来到天天文库
浏览记录
ID:38379001
大小:38.00 KB
页数:4页
时间:2019-06-11
《2011年7月9日点格棋程序框架》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、//2011年7月9日点格棋程序框架//输入左上起点行列坐标和方向,如A0-或B1
2、//梅险和贾楠//后续版本功能建议计算胜负,按照规则以文件形式输入输出,人工智能等#include#includeintplayer=0;//游戏者0-A,1-Bintsizei=6,sizej=6;//棋盘尺寸点数inta[100][100]={0};//存储(梅:建议后期分点棋盘,线棋盘,格棋盘分别存储)voidinitmap(){inti,j;for(i=0;i3、4、3:printf("│");break;case4:printf("A");break;case5:printf("B");break;default:printf(" ");}}printf("");}}intplay0(){chari,d;intj,s=0;/*scanf("%c",&i);scanf("%d",&j);scanf("%c",&d);*/cout<<"turnof"<>i;if(i=='Q')return-1;cin>>j>>d;s=s*10;s=s+i-'A';s=s*10;s=s+5、j;s=s*10;if(d=='-')s=s+0;elses=s+1;returns;}intplay1(){chari,d;intj,s=0;/*scanf("%c",&i);scanf("%d",&j);scanf("%c",&d);*/cout<<"turnof"<>i;if(i=='Q')return-1;cin>>j>>d;s=s*10;s=s+i-'A';s=s*10;s=s+j;s=s*10;if(d=='-')s=s+0;elses=s+1;returns;}intmove(intplaygo6、){inti,j,d,m,n;intresult=0;d=playgo%10;playgo/=10;j=playgo%10;playgo/=10;i=playgo%10;if(d==0)//横线{a[i*2][j*2+1]=2;if(i>0&&a[i*2-2][j*2+1]==2&&a[i*2-1][j*2]==3&&a[i*2-1][j*2+2]==3){a[i*2-1][j*2+1]=player+4;result=1;}if(i7、i*2+1][j*2+2]==3){a[i*2+1][j*2+1]=player+4;result=1;}}else{a[i*2+1][j*2]=3;if(j>0&&a[i*2+1][j*2-2]==3&&a[i*2][j*2-1]==2&&a[i*2+2][j*2-1]==2){a[i*2+1][j*2-1]=player+4;result=1;}if(j8、4;result=1;}}returnresult;}intmain(){inti,j,sum=0;intn=0;intb,c;intplaygo=0;intbox=0;initmap();drawmap();playgo=play0();sum++;printf("%d",playgo);while(playgo!=-1&&sum<=60){box=move(playgo);drawmap();if(box==0)player=1-player;if(player==0)playgo=play0();sum++;printf(9、"%d",playgo);}return0;}
3、4、3:printf("│");break;case4:printf("A");break;case5:printf("B");break;default:printf(" ");}}printf("");}}intplay0(){chari,d;intj,s=0;/*scanf("%c",&i);scanf("%d",&j);scanf("%c",&d);*/cout<<"turnof"<>i;if(i=='Q')return-1;cin>>j>>d;s=s*10;s=s+i-'A';s=s*10;s=s+5、j;s=s*10;if(d=='-')s=s+0;elses=s+1;returns;}intplay1(){chari,d;intj,s=0;/*scanf("%c",&i);scanf("%d",&j);scanf("%c",&d);*/cout<<"turnof"<>i;if(i=='Q')return-1;cin>>j>>d;s=s*10;s=s+i-'A';s=s*10;s=s+j;s=s*10;if(d=='-')s=s+0;elses=s+1;returns;}intmove(intplaygo6、){inti,j,d,m,n;intresult=0;d=playgo%10;playgo/=10;j=playgo%10;playgo/=10;i=playgo%10;if(d==0)//横线{a[i*2][j*2+1]=2;if(i>0&&a[i*2-2][j*2+1]==2&&a[i*2-1][j*2]==3&&a[i*2-1][j*2+2]==3){a[i*2-1][j*2+1]=player+4;result=1;}if(i7、i*2+1][j*2+2]==3){a[i*2+1][j*2+1]=player+4;result=1;}}else{a[i*2+1][j*2]=3;if(j>0&&a[i*2+1][j*2-2]==3&&a[i*2][j*2-1]==2&&a[i*2+2][j*2-1]==2){a[i*2+1][j*2-1]=player+4;result=1;}if(j8、4;result=1;}}returnresult;}intmain(){inti,j,sum=0;intn=0;intb,c;intplaygo=0;intbox=0;initmap();drawmap();playgo=play0();sum++;printf("%d",playgo);while(playgo!=-1&&sum<=60){box=move(playgo);drawmap();if(box==0)player=1-player;if(player==0)playgo=play0();sum++;printf(9、"%d",playgo);}return0;}
4、3:printf("│");break;case4:printf("A");break;case5:printf("B");break;default:printf(" ");}}printf("");}}intplay0(){chari,d;intj,s=0;/*scanf("%c",&i);scanf("%d",&j);scanf("%c",&d);*/cout<<"turnof"<>i;if(i=='Q')return-1;cin>>j>>d;s=s*10;s=s+i-'A';s=s*10;s=s+
5、j;s=s*10;if(d=='-')s=s+0;elses=s+1;returns;}intplay1(){chari,d;intj,s=0;/*scanf("%c",&i);scanf("%d",&j);scanf("%c",&d);*/cout<<"turnof"<>i;if(i=='Q')return-1;cin>>j>>d;s=s*10;s=s+i-'A';s=s*10;s=s+j;s=s*10;if(d=='-')s=s+0;elses=s+1;returns;}intmove(intplaygo
6、){inti,j,d,m,n;intresult=0;d=playgo%10;playgo/=10;j=playgo%10;playgo/=10;i=playgo%10;if(d==0)//横线{a[i*2][j*2+1]=2;if(i>0&&a[i*2-2][j*2+1]==2&&a[i*2-1][j*2]==3&&a[i*2-1][j*2+2]==3){a[i*2-1][j*2+1]=player+4;result=1;}if(i7、i*2+1][j*2+2]==3){a[i*2+1][j*2+1]=player+4;result=1;}}else{a[i*2+1][j*2]=3;if(j>0&&a[i*2+1][j*2-2]==3&&a[i*2][j*2-1]==2&&a[i*2+2][j*2-1]==2){a[i*2+1][j*2-1]=player+4;result=1;}if(j8、4;result=1;}}returnresult;}intmain(){inti,j,sum=0;intn=0;intb,c;intplaygo=0;intbox=0;initmap();drawmap();playgo=play0();sum++;printf("%d",playgo);while(playgo!=-1&&sum<=60){box=move(playgo);drawmap();if(box==0)player=1-player;if(player==0)playgo=play0();sum++;printf(9、"%d",playgo);}return0;}
7、i*2+1][j*2+2]==3){a[i*2+1][j*2+1]=player+4;result=1;}}else{a[i*2+1][j*2]=3;if(j>0&&a[i*2+1][j*2-2]==3&&a[i*2][j*2-1]==2&&a[i*2+2][j*2-1]==2){a[i*2+1][j*2-1]=player+4;result=1;}if(j8、4;result=1;}}returnresult;}intmain(){inti,j,sum=0;intn=0;intb,c;intplaygo=0;intbox=0;initmap();drawmap();playgo=play0();sum++;printf("%d",playgo);while(playgo!=-1&&sum<=60){box=move(playgo);drawmap();if(box==0)player=1-player;if(player==0)playgo=play0();sum++;printf(9、"%d",playgo);}return0;}
8、4;result=1;}}returnresult;}intmain(){inti,j,sum=0;intn=0;intb,c;intplaygo=0;intbox=0;initmap();drawmap();playgo=play0();sum++;printf("%d",playgo);while(playgo!=-1&&sum<=60){box=move(playgo);drawmap();if(box==0)player=1-player;if(player==0)playgo=play0();sum++;printf(
9、"%d",playgo);}return0;}
此文档下载收益归作者所有