Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include<windows.h>
- #include <stdlib.h>
- #include<stdbool.h>
- #include<ctype.h>
- int king_row,king_col;
- char white ='-';
- char black ='.';
- int flag =1 ;
- int lostb =0;
- int lostw =0 ;
- char lost_white[16];
- char lost_black[16];
- char list[8][8][100000]={0};
- int in=-1;
- int d=2;
- int kingswhiterow=0;
- int kingswhitecoloumn=4;
- int kingsblackrow=7;
- int kingsblackcoloumn=4;
- char white_black(int fromr,int fromc){
- if(fromr%2==0&&fromc%2==0){
- return black ;
- }
- else if (fromr%2!=0&&fromc%2!=0){
- return black ;
- }
- else if (fromc%2==0&&fromr%2!=0){
- return white ;
- }
- else {return white ;}
- }
- int max1(int a,int b)
- {
- if(a>b)
- {
- return a;
- }
- else
- {
- return b;
- }
- }
- int min1 (int a,int b)
- {
- if(a<b)
- {
- return a;
- }
- else
- {
- return b;
- }
- }
- char board[8][8];
- char c[5];
- int player=0;
- //char c2[2];
- char pawnw='p',pawnb='P',rookw='r',knightw='n',bishopw='b',queenw='q',kingw='k',rookb='R',knightb='N',bishopb='B',queenb='Q',kingb='K';
- void firstDisplay(){
- for(int i=0;i<8;i++){
- for(int j=0;j<8;j++){
- if(i==1){
- board[i][j]=pawnw;
- }
- else if (i==6){
- board[i][j]=pawnb;
- }
- else if (i!=7||i!=0||i!=1||i!=6){
- if((i==2||i==4)&&(j==0||j==2||j==4||j==6)){
- board[i][j]=black;
- }
- else if ((i==3||i==5)&&(j==1||j==3||j==5||j==7)){
- board[i][j]=black;
- }
- else {
- board[i][j]=white;
- }
- }
- }
- }
- board[0][0]=rookw;
- board[7][0]=rookb;
- board[0][1]=knightw;
- board[7][1]=knightb;
- board[0][2]=bishopw;
- board[7][2]=bishopb;
- board[0][3]=queenw;
- board[7][3]=queenb;
- board[0][4]=kingw;
- board[7][4]=kingb;
- board[0][5]=bishopw;
- board[7][5]=bishopb;
- board[0][6]=knightw;
- board[7][6]=knightb;
- board[0][7]=rookw;
- board[7][7]=rookb;
- board[6][0]=pawnb;
- board[1][0]=pawnw;
- //board[3][4]='k';
- //board[2][2]='A';
- //board[5][0]='a';
- //board[6][3]='-';
- //board[7][5]='k';
- //board[0][4]='-';
- }
- void printDisplay(){
- SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),15);
- system("cls");
- int v=8;
- in++;
- printf("\n");
- printf("lost in black");
- printf(" \t ");
- for(int i=0;i<8;i++)
- {
- printf(" %c",'A'+i);
- }
- printf("\n");
- for(int i =0;i<lostb;i++){SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),3);printf("%c",lost_black[i]);}
- SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),15);
- printf("\n");
- for(int i=7;i>=0;i--){
- if(v!=9)
- {
- printf("\t\t %d ",v);
- v--;
- }
- else
- {
- printf(" ");
- }
- for (int j =0;j<8;j++){
- list[i][j][in]=board[i][j];
- if(check1()&&i==king_row&&j==king_col){SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),4);printf(" %c",board[i][j]); SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),15);}
- else{
- if(board[i][j]==black){board[i][j]=219;SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),3);
- printf(" %c",board[i][j]);
- board[i][j]=black;
- SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),15);}
- else if(board[i][j]==white){board[i][j]=219;
- printf(" %c",board[i][j]);
- board[i][j]=white;}
- else{
- if(isupper(board[i][j])){SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),3);}
- printf(" %c",board[i][j]);
- SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),15);
- }}}
- if(i!=-1)
- {
- printf(" %d",i+1);
- }
- printf("\n\n");
- }
- printf("lost in white");
- printf("\t ");
- for(int i=0;i<8;i++)
- {
- printf(" %c",'A'+i);
- }
- printf("\n");
- for(int i =0;i<lostw;i++){printf("%c",lost_white[i]);}
- printf("\n");
- printf("\n");
- printf("For Undo press U and for Redo press R");
- printf("\n");
- }
- int fromc,fromr,tor,toc;
- void read_move(char c[])
- {
- scanf("%d",&c[4]);
- gets(c);
- if(c[0]=='U'){}
- else if(c[0]=='R'){}
- else{
- fromc=c[0]-65;
- fromr=c[1]-'0'-1;
- //printf("%c",board[fromr][fromc]);
- //printf("To ");
- // gets(c2);
- toc=c[2]-65;
- tor=c[3]-'0'-1;
- }}
- int validinput(int fromr,int fromc,int tor,int toc)
- {if(c[0]=='U'){
- return 1;}
- else if(c[0]=='R'){return 1 ;}
- if(fromr>7||fromc>7||fromr<0||fromc<0)
- {
- return 0;
- }
- else if(tor>7||toc>7||tor<0||toc<0)
- {
- return 0;
- }
- else if(c=='\n')
- {
- return 0;
- }
- else
- {
- return 1;
- }
- }
- int validpawn(int fromr,int fromc,int tor,int toc)
- {
- if(board[fromr][fromc]=='p')
- {
- if((fromr==1)&&(fromc==0||fromc==1||fromc==2||fromc==3||fromc==4||fromc==5||fromc==6||fromc==7))
- {
- if(tor-fromr!=1&&tor-fromr!=2)
- {
- //printf("df");
- return 0;
- }
- else if(tor-fromr==2)
- {
- if(board[tor-1][fromc]!=white&&board[tor-1][fromc]!=black)
- {
- return 0;
- }
- }
- }
- else if(tor-fromr!=1)
- {
- //printf("df");
- return 0;
- }
- if(toc-fromc!=0&&tor-fromr==1)//coloumns
- {
- if(toc-fromc==1||toc-fromc==-1)
- {
- //printf("d");
- if(board[tor][toc]!=white&&board[tor][toc]!=black)
- {
- if(isupper(board[tor][toc]))
- {
- // printf("ad");
- return 1;
- }
- }
- else
- {
- //printf("sdff");
- return 0;
- }
- }
- else
- {
- return 0;
- }
- }
- if(board[tor][toc]!=white&&board[tor][toc]!=black)
- {
- return 0;
- }
- else
- {
- return 1;
- }
- }
- else if(board[fromr][fromc]=='P')
- {
- if((fromr==6)&&(fromc==0||fromc==1||fromc==2||fromc==3||fromc==4||fromc==5||fromc==6||fromc==7))
- {
- if(tor-fromr!=-1&&tor-fromr!=-2)
- {
- return 0;
- }
- else if(tor-fromr==-2)
- {
- if(board[tor+1][fromc]!=white&&board[tor+1][fromc]!=black)
- {
- return 0;
- }
- }
- }
- else if(tor-fromr!=-1)
- {
- return 0;
- }
- if(toc-fromc!=0&&tor-fromr==-1)
- {
- if(toc-fromc==1||toc-fromc==-1)
- {
- if(board[tor][toc]!=black&&board[tor][toc]!=white)//it just need to add all of the same chess colours as it can't move if one of them is there
- {
- if(islower(board[tor][toc]))
- return 1;
- }
- else
- {
- return 0;
- }
- }
- else
- {
- return 0;
- }
- }
- if(board[tor][toc]!=white&&board[tor][toc]!=black)
- {
- return 0;
- }
- else
- {
- return 1;
- }
- }
- }
- int validrook(int fromr,int fromc,int tor,int toc){
- if(board[fromr][fromc]=='r'||board[fromr][fromc]=='R')
- {
- if(board[fromr][fromc]=='r'&&islower(board[tor][toc]))
- {
- return 0;
- }
- else if(board[fromr][fromc]=='R'&&isupper(board[tor][toc]))
- {
- return 0;
- }
- if(tor-fromr==0&&toc-fromc!=0)
- {
- for(int i=min1(toc,fromc)+1;i<max1(toc,fromc);i++)
- {
- if(board[fromr][i]!=white&&board[fromr][i]!=black)
- {
- // printf("empty");
- return 0;
- }
- }
- return 1;
- }
- else if(tor-fromr!=0&&toc-fromc==0)
- {
- for(int i=min1(tor,fromr)+1;i<max1(tor,fromr);i++)
- {
- if(board[i][fromc]!=white&&board[i][fromc]!=black)
- {
- // printf("empty");
- return 0;
- }
- }
- return 1;
- }
- else
- {
- return 0;
- }
- }
- }
- int validknight(int fromr,int fromc,int tor,int toc){
- if(board[fromr][fromc]=='n'||board[fromr][fromc]=='N'){
- if(abs(toc-fromc)==2&&abs(tor-fromr)==1||abs(toc-fromc)==1&&abs(tor-fromr)==2){
- if (board[tor][toc]==white||board[tor][toc]==black){
- return 1 ;
- }
- else if (((board[fromr][fromc]=='n')&&isupper((int)board[tor][toc]))==1||((board[fromr][fromc]=='N')&&islower(board[tor][toc]))){
- return 1;
- }
- }
- }
- return 0 ;
- }
- int validking(int fromr,int fromc,int tor,int toc){
- if(board[fromr][fromc]=='k'||board[fromr][fromc]=='K'){
- if(abs(toc-fromc)==1&&tor-fromr==0||abs(tor-fromr)==1&&toc-fromc==0||abs(tor-fromr)==1&&abs(toc-fromc)==1){
- if (board[tor][toc]==white||board[tor][toc]==black){
- return 1 ;
- }
- else if (((board[fromr][fromc]=='k')&&isupper((int)board[tor][toc]))==1||((board[fromr][fromc]=='K')&&islower(board[tor][toc]))){
- return 1;
- }
- }
- }
- return 0 ;
- }
- int validbishop(int fromr,int fromc,int tor,int toc)
- {
- if(board[fromr][fromc]=='b'||board[fromr][fromc]=='B')
- {
- if(abs(tor-fromr)==abs(toc-fromc))
- {
- if(board[fromr][fromc]=='b'&&islower(board[tor][toc]))
- {
- // printf("a");
- return 0;
- }
- else if(board[fromr][fromc]=='B'&&isupper(board[tor][toc]))
- {
- return 0;
- }
- int j=min1(fromc,toc)+1;
- int detect;
- if((fromr==min1(fromr,tor)&&fromc==min1(fromc,toc))||(tor==min1(fromr,tor)&&toc==min1(fromc,toc)))
- {
- detect=1;
- }
- else
- {
- j=max1(toc,fromc)-1;
- detect=-1;
- }
- for(int i=min1(fromr,tor)+1;i<max1(fromr,tor);i++)
- {
- if(board[i][j]!=white&&board[i][j]!=black)
- {
- return 0;
- }
- j+=detect;
- }
- return 1;
- }
- else
- {
- return 0;
- }
- }
- }
- int validqueen (int fromr,int fromc,int tor,int toc){
- if(board[fromr][fromc]=='q'||board[fromr][fromc]=='Q'){
- if(abs(tor-fromr)==abs(toc-fromc))
- {
- if(board[fromr][fromc]=='q'&&islower(board[tor][toc]))
- {
- //printf("a");
- return 0;
- }
- else if(board[fromr][fromc]=='Q'&&isupper(board[tor][toc]))
- {
- return 0;
- }
- int j=min(fromc,toc)+1;
- int detect;
- if((fromr==min1(fromr,tor)&&fromc==min1(fromc,toc))||(tor==min1(fromr,tor)&&toc==min1(fromc,toc)))
- {
- detect=1;
- }
- else
- {
- j=max1(toc,fromc)-1;
- detect=-1;
- }
- for(int i=min1(fromr,tor)+1;i<max1(fromr,tor);i++)
- {
- if(board[i][j]!=white&&board[i][j]!=black)
- {
- return 0;
- }
- j+=detect;
- }
- return 1;
- }
- else if(board[fromr][fromc]=='q'&&islower(board[tor][toc]))
- {
- return 0;
- }
- else if(board[fromr][fromc]=='Q'&&isupper(board[tor][toc]))
- {
- return 0;
- }
- if(tor-fromr==0&&toc-fromc!=0)
- {
- for(int i=min1(toc,fromc)+1;i<max1(toc,fromc);i++)
- {
- if(board[fromr][i]!=white&&board[fromr][i]!=black)
- {
- // printf("empty");
- return 0;
- }
- }
- return 1;
- }
- else if(tor-fromr!=0&&toc-fromc==0)
- {
- for(int i=min1(tor,fromr)+1;i<max1(tor,fromr);i++)
- {
- if(board[i][fromc]!=white&&board[i][fromc]!=black)
- {
- // printf("empty");
- return 0;
- }
- }
- return 1;
- }
- else
- {
- return 0;
- }
- }
- }
- void make_move (int fromr,int fromc,int tor,int toc){
- if(c[0]=='U'){if(player==1){player=2;}
- else {player=1;}
- undo();}
- else if(c[0]=='R'){if(player==1){player=2;}
- else {player=1;}redomove();}
- else{
- if(board[tor][toc]!=white&&board[tor][toc]!=black){
- if(isupper((int)board[tor][toc])==1){
- lost_black[lostb]=board[tor][toc];
- lostb++;
- }
- else{
- lost_white[lostw]=board[tor][toc];
- lostw++;
- }
- board[tor][toc]=board[fromr][fromc];
- board[fromr][fromc]=white_black(fromr,fromc);
- permotion();
- printDisplay() ;
- }
- else {
- board[tor][toc]=board[fromr][fromc];
- board[fromr][fromc]=white_black(fromr,fromc);
- permotion();
- printDisplay();
- }}}
- int validmove(int fromr,int fromc,int tor,int toc)
- {
- if(islower(board[fromr][fromc])&&player!=1)
- {
- return 0;
- }
- else if(isupper(board[fromr][fromc])&&player!=2)
- {
- return 0;
- }
- if(validinput(fromr,fromc,tor,toc)==1&&validpawn(fromr,fromc,tor,toc)==1)
- {
- return checknow(fromr,fromc,tor,toc);
- }
- else if(validinput(fromr,fromc,tor,toc)==1&&validrook(fromr,fromc,tor,toc)==1)
- {
- return checknow(fromr,fromc,tor,toc);
- }
- else if(validinput(fromr,fromc,tor,toc)==1&&validknight(fromr,fromc,tor,toc)==1)
- {
- return checknow(fromr,fromc,tor,toc);
- }
- else if(validinput(fromr,fromc,tor,toc)==1&&validking(fromr,fromc,tor,toc)==1)
- {
- return checknow(fromr,fromc,tor,toc);
- }
- else if(validinput(fromr,fromc,tor,toc)==1&&validbishop(fromr,fromc,tor,toc)==1)
- {
- return checknow(fromr,fromc,tor,toc);
- }
- else if(validinput(fromr,fromc,tor,toc)==1&&validqueen(fromr,fromc,tor,toc)==1)
- {
- return checknow(fromr,fromc,tor,toc);
- }
- else
- {
- return 0;
- }
- }
- int checknow(fromr,fromc,tor,toc)
- {
- char temp=board[fromr][fromc];
- char temp2=board[tor][toc];
- board[tor][toc]=board[fromr][fromc];
- board[fromr][fromc]=white;
- if(!check())
- {
- board[fromr][fromc]=temp;
- board[tor][toc]=temp2;
- return 1;
- }
- board[fromr][fromc]=temp;
- board[tor][toc]=temp2;
- return 0;
- }
- int check1()
- {player=player%2+1;
- if(player==1)
- {
- for(int i=0;i<8;i++)
- {
- for(int j=0;j<8;j++)
- {
- if(board[i][j]=='k')
- {
- king_row=i;
- king_col=j;
- break;
- }
- }
- }
- }
- else if(player==2)
- {
- for(int i=0;i<8;i++)
- {
- for(int j=0;j<8;j++)
- {
- if(board[i][j]=='K')
- {
- king_row=i;
- king_col=j;
- break;
- }
- }
- }
- }
- int temp=player;
- player=(player%2)+1;
- for(int i=0;i<8;i++)
- {
- for(int j=0;j<8;j++)
- {
- if(validmove(i,j,king_row,king_col))
- {
- //printf("%d %d %d %d\n",i+1,j+1,x+1,y+1);
- player=temp;
- player=player%2+1;
- return 1;
- }
- }
- }
- player=temp;
- player=player%2+1;
- return 0;
- }
- int check()
- {int x,y;
- if(player==1)
- {
- for(int i=0;i<8;i++)
- {
- for(int j=0;j<8;j++)
- {
- if(board[i][j]=='k')
- {
- x=i;
- y=j;
- break;
- }
- }
- }
- }
- else if(player==2)
- {
- for(int i=0;i<8;i++)
- {
- for(int j=0;j<8;j++)
- {
- if(board[i][j]=='K')
- {
- x=i;
- y=j;
- break;
- }
- }
- }
- }
- int temp=player;
- player=(player%2)+1;
- for(int i=0;i<8;i++)
- {
- for(int j=0;j<8;j++)
- {
- if(validmove(i,j,x,y))
- {
- //printf("%d %d %d %d\n",i+1,j+1,x+1,y+1);
- player=temp;
- return 1;
- }
- }
- }
- player=temp;
- return 0;
- }
- int checkmat()
- {
- if(check())
- {
- // printf("asd");
- for(int i=0;i<8;i++)
- {
- for(int j=0;j<8;j++)
- {
- for(int k=0;k<8;k++)
- {
- for(int l=0;l<8;l++)
- {
- if(validmove(i,j,k,l))
- {
- // printf(" fff%d %d %d %d\n",i+1,j+1,k+1,l+1);
- return 0;
- }
- }
- }
- }
- }
- return 1;
- }
- else
- {
- return 0;
- }
- }
- int stalemat()
- {
- if(!check())
- {
- for(int i=0;i<8;i++)
- {
- for(int j=0;j<8;j++)
- {
- if(board[i][j]!=white&&board[i][j]!=black)
- {
- for(int x=0;x<8;x++)
- {
- for(int y=0;y<8;y++)
- {
- if(validmove(i,j,x,y))
- {
- return 0;
- }
- }
- }
- }
- }
- }
- return 1;
- }
- else
- {
- return 0;
- }
- }
- int k=0;
- void playgame()
- {
- printf("CHOOSE 1 FOR SAVED GAME\nCHOOSE 2 FOR NEW GAME\n");
- scanf("%d",&d);
- firstDisplay();
- if(d!=1)
- {
- printDisplay();
- }
- else
- {
- load();
- }
- while(true)
- {
- if(player==1)
- {
- player=2;
- }
- else
- {
- player=1;
- }
- //player=2;
- if(checkmat())
- {
- system("cls");
- printf("\n");
- printf("%d",(player%2)+1);
- printf("WINS!!");
- break;
- }
- else if(check())
- {
- printf("Player %d checks Player %d\a\a\a\a\a\a\a\a\n",(player%2)+1,player);
- }
- else if(stalemat())
- {
- system("cls");
- printf("\n");
- printf("DRAW");
- break;
- }
- //player;
- printf("Player %d's turn: ",player);
- read_move(c);
- if(c[0]!='U'&&c[0]!='R')
- {
- while(validmove(fromr,fromc,tor,toc)!=1)
- {COORD coord ;
- coord.X=17;
- coord.Y=23;
- printf("Invalid MOVE ENTER MOVE AGAIN : ");
- printf("\r");
- SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),coord);
- read_move(c);
- if(c[0]=='U'||c[0]=='R')
- {
- break;
- }
- }
- }
- make_move(fromr,fromc,tor,toc);
- save();
- }
- }
- void save()
- {
- FILE * fpointer;
- fpointer=fopen("save.text","w");
- for(int i=7;i>=0;i--)
- {
- for(int j=0;j<8;j++)
- {
- fprintf(fpointer,"%c",board[i][j]);
- }
- }
- fprintf(fpointer,"%d",player);
- if(lostw!=0)
- {
- for(int i=0;i<=lostw;i++)
- {
- fprintf(fpointer,"%c",lost_white[i]);
- }
- }
- if(lostb!=0)
- {
- for(int i=0;i<=lostb;i++)
- {
- fprintf(fpointer,"%c",lost_black[i]);
- }
- }
- fclose(fpointer);
- }
- char s[150];
- void load()
- {
- FILE * fpointer;
- fpointer=fopen("save.text","r");
- if(fpointer=fopen("save.text","r")){
- int counter=0;
- while(!feof(fpointer))
- {
- fgets(s,200,fpointer);
- for(int i=7;i>=0;i--)
- {
- for(int j=0;j<8;j++)
- {
- board[i][j]=s[counter];
- counter++;
- }
- }
- player=s[counter]-'0';
- counter++;
- int i=0;
- while(islower(s[counter]))
- {
- lost_white[i]=s[counter];
- lostw++;
- i++;
- counter++;
- }
- i=0;
- if(s[counter]=' ')
- {
- counter++;
- }
- while(isupper(s[counter]))
- {
- lost_black[i]=s[counter];
- i++;
- lostb++;
- counter++;
- }
- break;
- }
- printDisplay();
- }
- else{printDisplay();}}
- int cunt=0;
- int cunt2=0;
- int cunt3=0;
- void undo()
- {
- //player=(player%2)+1;
- if(in<=0)
- {
- return ;
- }
- cunt=in;
- player=(player%2)+1;
- int countblack_after=0;
- int countwhite_after=0;
- int countblack_before=0;
- int countwhite_before=0;
- for(int i=7;i>=0;i--)
- {
- for(int j=0;j<8;j++)
- {
- if(board[i][j]!=white&&board[i][j]!=black)
- {
- if(islower(board[i][j]))
- {
- countwhite_before++;
- }
- else if(isupper(board[i][j]))
- {
- countblack_before++;
- }
- }
- board[i][j]=list[i][j][in-1];
- if(board[i][j]!=white&&board[i][j]!=black)
- {
- if(islower(board[i][j]))
- {
- countwhite_after++;
- }
- else if(isupper(board[i][j]))
- {
- countblack_after++;
- }
- }
- }
- }
- if(countwhite_after>countwhite_before)
- {
- lostw--;
- }
- if(countblack_after>countblack_before)
- {
- // printf("%d %d\n",countblack_before,countblack_after);
- lostb--;
- }
- in=in-2;
- printDisplay();
- cunt3=in;
- return ;
- }
- void redomove()
- {
- if(list[0][0][in+1]==0||cunt3!=in)
- {
- if(cunt3!=in)
- {
- list[0][0][in+1]=0;
- }
- return;
- }
- player=(player%2)+1;
- int countblack_after=0;
- int countwhite_after=0;
- int countblack_before=0;
- int countwhite_before=0;
- for(int i=7;i>=0;i--)
- {
- for(int j=0;j<8;j++)
- {
- if(board[i][j]!=white&&board[i][j]!=black)
- {
- if(islower(board[i][j]))
- {
- countwhite_before++;
- }
- else if(isupper(board[i][j]))
- {
- countblack_before++;
- }
- }
- board[i][j]=list[i][j][in+1];
- if(board[i][j]!=white&&board[i][j]!=black)
- {
- if(islower(board[i][j]))
- {
- countwhite_after++;
- }
- else if(isupper(board[i][j]))
- {
- countblack_after++;
- }
- }
- }
- }
- if(countwhite_after<countwhite_before)
- {
- lostw++;
- }
- else if(countblack_after<countblack_before)
- {
- lostb++;
- }
- in-1;
- printDisplay();
- cunt3++;
- }
- char permote='p';
- int permotion()
- {
- if(board[tor][toc]=='p'&&tor==7)
- {
- printf("WHAT DO YOU WANT TO PERMOTE THE PAWN TO?");
- scanf("%c",&permote);
- while(!islower(permote)||permote=='k')
- {
- printf("INVALID PERMOTION\N");
- scanf("%c",&permote);
- }
- board[tor][toc]=permote;
- //p=1;
- return 1;
- }
- else if(board[tor][toc]=='P'&&tor==0)
- {
- printf("WHAT DO YOU WANT TO PERMOTE THE PAWN TO?");
- scanf("%c",&permote);
- while(!isupper(permote)||permote=='K')
- {
- printf("INVALID PERMOTION\N");
- scanf("%c",&permote);
- }
- board[tor][toc]=permote;
- // p=1;
- return 1;
- }
- return 0;
- }
- int main()
- {
- playgame();
- // read_move(c,c2);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement