Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void move_piece(int i1, int j1,int i2, int j2,int turn){
- /* for player 1*/
- if(turn==1){
- /*moving pawn*/
- if(domain[i1][j1]=='p')
- {
- if(i1==1){
- /*if next square is correct and empty*/
- if((i2-i1==1||i2-i1==2)&&j1==j2&& occupied[i2][j2]==0&&occupied[i1+1][j2]==0){
- save_step(i1,j1,i2,j2,domain[i2][j2],domain[i1][j1]);
- domain[i2][j2]=domain[i1][j1];
- occupied[i1][j1]=0;
- occupied[i2][j2]=1;
- } else if(i2==i1+1&&(j2==j1-1||j2==j1+1)&&occupied[i2][j2]==2)
- {
- save_step(i1,j1,i2,j2,domain[i2][j2],domain[i1][j1]);
- killed2[number_killed2]=domain[i2][j2];
- domain[i2][j2]=domain[i1][j1];
- number_killed2++;
- occupied[i1][j1]=0;
- occupied[i2][j2]=1;
- }
- else
- {
- printf("Incorrect move.\nPlease re-enter your move.");
- movement();
- }
- }
- else if((i2-i1==1)&&j1==j2&& occupied[i2][j2]==0){
- save_step(i1,j1,i2,j2,domain[i2][j2],domain[i1][j1]);
- if(i2==7)
- {
- premote(&domain[i1][j1]);
- }
- domain[i2][j2]=domain[i1][j1];
- occupied[i1][j1]=0;
- occupied[i2][j2]=1;
- return;
- }
- /*eaten player 2 piece*/
- else if(i2==i1+1&&(j2==j1-1||j2==j1+1)&&occupied[i2][j2]==2)
- { save_step(i1,j1,i2,j2,domain[i2][j2],domain[i1][j1]);
- if(i2==7)
- {
- premote(&domain[i1][j1]);
- }
- killed2[number_killed2]=domain[i2][j2];
- domain[i2][j2]=domain[i1][j1];
- number_killed2++;
- occupied[i1][j1]=0;
- occupied[i2][j2]=1;
- }
- else
- {
- printf("Incorrect move.\nPlease re-enter your move.");
- movement();
- }
- return;
- }
- /*moving tabya*/
- if(domain[i1][j1]=='r')
- {
- /*moving through the row*/
- if(i2==i1)
- {
- int n;
- if(j2>j1){
- for(n=j1+1;n<j2;n++)
- {
- if(occupied[i1][n])
- {
- printf("Incorrect move(a piece inside the path).\nPlease re-enter your move.");
- movement();
- goto OUT;
- }}}
- if(j1>j2)
- {
- for(n=j1-1;n>j2;n--)
- {
- if(occupied[i1][n])
- {
- printf("Incorrect move(a piece inside the path).\nPlease re-enter your move.");
- movement();
- goto OUT;
- }}
- }
- if(occupied[i1][j2]==1)
- {
- printf("Incorrect move(moving over your own piece).\nPlease re-enter your move.");
- movement();
- return;
- }save_step(i1,j1,i2,j2,domain[i2][j2],domain[i1][j1]);
- if(occupied[i2][j2]==2)
- {
- occupied[i2][j2]=1;
- occupied[i1][j1]=0;
- killed2[number_killed2]=domain[i2][j2];
- domain[i2][j2]=domain[i1][j1];
- number_killed2++;
- }
- if(occupied[i2][j2]==0)
- {
- domain[i2][j2]=domain[i1][j1];
- occupied[i1][j1]=0;
- occupied[i2][j2]=1;
- }
- }
- else if(j2==j1)
- {
- int n;
- if(i2>i1)
- {
- for(n=i1+1;n<i2;n++)
- {
- if(occupied[n][j1])
- {
- printf("Incorrect move(a piece inside the path).\nPlease re-enter your move.");
- movement();
- return;
- }}}
- if(i1>i2)
- {
- for(n=i1-1;n>i2;n--)
- {
- if(occupied[n][j1])
- {
- printf("Incorrect move(a piece inside the path).\nPlease re-enter your move.");
- movement();
- return;
- }}
- }
- if(occupied[i2][j2]==1)
- {
- printf("Incorrect move(moving over your own piece).\nPlease re-enter your move.");
- movement();
- return;
- }save_step(i1,j1,i2,j2,domain[i2][j2],domain[i1][j1]);
- if(occupied[i2][j2]==2)
- {
- occupied[i1][j1]=0;
- occupied[i2][j2]=1;
- killed2[number_killed2]=domain[i2][j2];
- domain[i2][j2]=domain[i1][j1];
- number_killed2++;
- }
- if(occupied[i2][j2]==0)
- {
- occupied[i1][j1]=0;
- occupied[i2][j2]=1;
- domain[i2][j2]=domain[i1][j1];
- }
- }else
- {
- printf("Incorrect move.\nPlease re-enter your move.");
- movement();
- }
- }
- /*moving the knight*/
- if(domain[i1][j1]=='n')
- {
- if((i2==i1+2&&(j2==j1-1||j2==j1+1))||(i2==i1-2&&(j2==j1-1||j2==j1+1))||(j2==j1+2&&(i2==i1-1||i2==i1+1))||(j2==j1-2&&(i2==i1-1||i2==i1+1)))
- {
- if(occupied[i2][j2]==1)
- {
- printf("Incorrect move(moving over your own piece).\nPlease re-enter your move.");
- movement();
- return;
- }save_step(i1,j1,i2,j2,domain[i2][j2],domain[i1][j1]);
- if(occupied[i2][j2]==2)
- {
- occupied[i1][j1]=0;
- occupied[i2][j2]=1;
- killed2[number_killed2]=domain[i2][j2];
- domain[i2][j2]=domain[i1][j1];
- number_killed2++;
- }
- if(occupied[i2][j2]==0)
- {
- domain[i2][j2]=domain[i1][j1];
- occupied[i1][j1]=0;
- occupied[i2][j2]=1;
- }
- }else
- {
- printf("Incorrect move.\nPlease re-enter your move.");
- movement();
- }
- }
- if(domain[i1][j1]=='b')
- {
- int n,m;
- if(j2-j1==i2-i1 || j2-j1==i1-i2)
- {
- if(j2>j1&&i2>i1)
- {
- m=j1+1;
- for(n=i1+1;n<i2;n++)
- {
- if(occupied[n][m++])
- {
- printf("Incorrect move(a piece inside the path).\nPlease re-enter your move.");
- movement();
- return;
- }
- }
- }
- else if(j1>j2 && i2>i1)
- {
- m=j1-1;
- for(n=i1+1;n<i2;n++)
- {
- if(occupied[n][m--])
- {
- printf("Incorrect move(a piece inside the path).\nPlease re-enter your move.");
- movement();
- return;
- }
- }
- }
- else if (i1>i2 && j2>j1)
- {
- m=j1+1;
- for(n=i1-1;n>i2;n--)
- {
- if(occupied[n][m++])
- {
- printf("Incorrect move(a piece inside the path).\nPlease re-enter your move.");
- movement();
- return;
- }
- }
- }
- else if(i2<i1 && j2<j1)
- {
- m=j1-1;
- for(n=i1-1;n>i2;n--)
- {
- if(occupied[n][m--])
- {
- printf("Incorrect move(a piece inside the path).\nPlease re-enter your move.");
- movement();
- return;
- }
- }
- }}
- else{
- printf("Incorrect move.\nPlease re-enter your move.");
- movement();
- return;
- }
- if(occupied[i2][j2]==1)
- {
- printf("Incorrect move(moving over your own piece).\nPlease re-enter your move.");
- movement();
- return;
- }
- if(occupied[i2][j2]==2)
- {
- save_step(i1,j1,i2,j2,domain[i2][j2],domain[i1][j1]);
- occupied[i1][j1]=0;
- occupied[i2][j2]=1;
- killed2[number_killed2]=domain[i2][j2];
- domain[i2][j2]=domain[i1][j1];
- number_killed2++;
- }
- if(occupied[i2][j2]==0)
- {
- save_step(i1,j1,i2,j2,domain[i2][j2],domain[i1][j1]);
- domain[i2][j2]=domain[i1][j1];
- occupied[i1][j1]=0;
- occupied[i2][j2]=1;
- }
- }
- }
- if(domain[i1][j1]=='q')
- {
- int n,m;
- if(j2-j1==i2-i1 || j2-j1==i1-i2)
- {
- if(j2>j1&&i2>i1)
- {
- m=j1+1;
- for(n=i1+1;n<i2;n++)
- {
- if(occupied[n][m++])
- {
- printf("Incorrect move(a piece inside the path).\nPlease re-enter your move.");
- movement();
- goto OUT;
- }
- }
- }
- else if(j1>j2 && i2>i1)
- {
- m=j1-1;
- for(n=i1+1;n<i2;n++)
- {
- if(occupied[n][m--])
- {
- printf("Incorrect move(a piece inside the path).\nPlease re-enter your move.");
- movement();
- return;
- }
- }
- }
- else if (i1>i2 && j2>j1)
- {
- m=j1+1;
- for(n=i1-1;n>i2;n--)
- {
- if(occupied[n][m++])
- {
- printf("Incorrect move(a piece inside the path).\nPlease re-enter your move.");
- movement();
- return;
- }
- }
- }
- else if(i2<i1 && j2<j1)
- {
- for(n=i1-1;n>i2;n--)
- {
- m=j1-1;
- if(occupied[n][m--])
- {
- printf("Incorrect move(a piece inside the path).\nPlease re-enter your move.");
- movement();
- return;
- }
- }
- }
- if(occupied[i2][j2]==1)
- {
- printf("Incorrect move(moving over your own piece).\nPlease re-enter your move.");
- movement();
- return;
- }
- if(occupied[i2][j2]==2)
- { save_step(i1,j1,i2,j2,domain[i2][j2],domain[i1][j1]);
- occupied[i1][j1]=0;
- occupied[i2][j2]=1;
- killed2[number_killed2]=domain[i2][j2];
- domain[i2][j2]=domain[i1][j1];
- number_killed2++;
- }
- if(occupied[i2][j2]==0)
- { save_step(i1,j1,i2,j2,domain[i2][j2],domain[i1][j1]);
- domain[i2][j2]=domain[i1][j1];
- occupied[i1][j1]=0;
- occupied[i2][j2]=1;
- }
- }
- else if(i2==i1)
- {
- int n;
- if(j2>j1){
- for(n=j1+1;n<j2;n++)
- {
- if(occupied[i1][n])
- {
- printf("Incorrect move(a piece inside the path).\nPlease re-enter your move.");
- movement();
- return;
- }}}
- if(j1>j2)
- {
- for(n=j1-1;n>j2;n--)
- {
- if(occupied[i1][n])
- {
- printf("Incorrect move(a piece inside the path).\nPlease re-enter your move.");
- movement();
- return;
- }}
- }
- if(occupied[i1][j2]==1)
- {
- printf("Incorrect move(moving over your own piece).\nPlease re-enter your move.");
- movement();
- return;
- }
- if(occupied[i2][j2]==2)
- {save_step(i1,j1,i2,j2,domain[i2][j2],domain[i1][j1]);
- occupied[i2][j2]=1;
- occupied[i1][j1]=0;
- killed2[number_killed2]=domain[i2][j2];
- domain[i2][j2]=domain[i1][j1];
- number_killed2++;
- }
- if(occupied[i2][j2]==0)
- {save_step(i1,j1,i2,j2,domain[i2][j2],domain[i1][j1]);
- domain[i2][j2]=domain[i1][j1];
- occupied[i1][j1]=0;
- occupied[i2][j2]=1;
- }
- }
- else if(j2==j1)
- {
- int n;
- if(i2>i1)
- {
- for(n=i1+1;n<i2;n++)
- {
- if(occupied[n][j1])
- {
- printf("Incorrect move(a piece inside the path).\nPlease re-enter your move.");
- movement();
- return;
- }}}
- if(i1>i2)
- {
- for(n=i1-1;n>i2;n--)
- {
- if(occupied[n][j1])
- {
- printf("Incorrect move(a piece inside the path).\nPlease re-enter your move.");
- movement();
- return;
- }}
- }
- if(occupied[i2][j2]==1)
- {
- printf("Incorrect move(moving over your own piece).\nPlease re-enter your move.");
- movement();
- }
- if(occupied[i2][j2]==2)
- { save_step(i1,j1,i2,j2,domain[i2][j2],domain[i1][j1]);
- occupied[i1][j1]=0;
- occupied[i2][j2]=1;
- killed2[number_killed2]=domain[i2][j2];
- domain[i2][j2]=domain[i1][j1];
- number_killed2++;
- }
- if(occupied[i2][j2]==0)
- { save_step(i1,j1,i2,j2,domain[i2][j2],domain[i1][j1]);
- occupied[i1][j1]=0;
- occupied[i2][j2]=1;
- domain[i2][j2]=domain[i1][j1];
- }
- }
- else
- {
- printf("Incorrect move.\nPlease re-enter your move.");
- movement();
- }
- }
- if(domain[i1][j1]=='k')
- {
- move_king(i1,j1,i2,j2);
- }
- /******* PLAYER 2**********/
- if(turn==2)
- {
- if(domain[i1][j1]=='P')
- {
- if(i1==6){
- /*if next square is correct and empty*/
- if((i1-i2==1||i1-i2==2)&&j1==j2&& occupied[i2][j2]==0&&occupied[i1-1][j2]==0){
- save_step(i1,j1,i2,j2,domain[i2][j2],domain[i1][j1]);
- domain[i2][j2]=domain[i1][j1];
- occupied[i1][j1]=0;
- occupied[i2][j2]=2;
- }else if((i1-i2==1)&&j1==j2&& occupied[i2][j2]==0){
- save_step(i1,j1,i2,j2,domain[i2][j2],domain[i1][j1]);
- domain[i2][j2]=domain[i1][j1];
- occupied[i1][j1]=0;
- occupied[i2][j2]=2;
- }
- else
- {
- printf("Incorrect move.\nPlease re-enter your move.");
- movement();
- }
- }
- else if((i1-i2==1)&&j1==j2&& occupied[i2][j2]==0){
- save_step(i1,j1,i2,j2,domain[i2][j2],domain[i1][j1]);
- if(i2==0)
- {
- premote(&domain[i1][j1]);
- }
- domain[i2][j2]=domain[i1][j1];
- occupied[i1][j1]=0;
- occupied[i2][j2]=2;
- }
- /*eaten player 1 piece*/
- else if(i2==i1-1&&(j2==j1-1||j2==j1+1)&&occupied[i2][j2]==1)
- {
- save_step(i1,j1,i2,j2,domain[i2][j2],domain[i1][j1]);
- if(i2==0)
- {
- premote(&domain[i1][j1]);
- }
- killed1[number_killed1]=domain[i2][j2];
- domain[i2][j2]=domain[i1][j1];
- number_killed1++;
- occupied[i1][j1]=0;
- occupied[i2][j2]=2;
- }
- else
- {
- printf("Incorrect move.\nPlease re-enter your move.");
- movement();
- return;
- }
- return;
- }
- if(domain[i1][j1]=='R')
- {
- if(i2==i1)
- {
- int n;
- if(j2>j1){
- for(n=j1+1;n<j2;n++)
- {
- if(occupied[i1][n])
- {
- printf("Incorrect move(a piece inside the path).\nPlease re-enter your move.");
- movement();
- return;
- }}}
- if(j1>j2)
- {
- for(n=j1-1;n>j2;n--)
- {
- if(occupied[i1][n])
- {
- printf("Incorrect move(a piece inside the path).\nPlease re-enter your move.");
- movement();
- return;
- }}
- }
- if(occupied[i1][j2]==2)
- {
- printf("Incorrect move(moving over your own piece).\nPlease re-enter your move.");
- movement();
- return;
- }
- if(occupied[i2][j2]==1)
- { save_step(i1,j1,i2,j2,domain[i2][j2],domain[i1][j1]);
- occupied[i2][j2]=2;
- occupied[i1][j1]=0;
- killed1[number_killed1]=domain[i2][j2];
- domain[i2][j2]=domain[i1][j1];
- number_killed1++;
- }
- if(occupied[i2][j2]==0)
- { save_step(i1,j1,i2,j2,domain[i2][j2],domain[i1][j1]);
- domain[i2][j2]=domain[i1][j1];
- occupied[i1][j1]=0;
- occupied[i2][j2]=2;
- }
- }
- else if(j2==j1)
- {
- int n;
- if(i2>i1)
- {
- for(n=i1+1;n<i2;n++)
- {
- if(occupied[n][j1])
- {
- printf("Incorrect move(a piece inside the path).\nPlease re-enter your move.");
- movement();
- return;
- }}}
- if(i1>i2)
- {
- for(n=i1-1;n>i2;n--)
- {
- if(occupied[n][j1])
- {
- printf("Incorrect move(a piece inside the path).\nPlease re-enter your move.");
- movement();
- return;
- }}
- }
- if(occupied[i2][j2]==2)
- {
- printf("Incorrect move(moving over your own piece).\nPlease re-enter your move.");
- movement();
- return;
- }
- if(occupied[i2][j2]==1)
- { save_step(i1,j1,i2,j2,domain[i2][j2],domain[i1][j1]);
- occupied[i1][j1]=0;
- occupied[i2][j2]=2;
- killed1[number_killed1]=domain[i2][j2];
- domain[i2][j2]=domain[i1][j1];
- number_killed1++;
- }
- if(occupied[i2][j2]==0)
- { save_step(i1,j1,i2,j2,domain[i2][j2],domain[i1][j1]);
- occupied[i1][j1]=0;
- occupied[i2][j2]=2;
- domain[i2][j2]=domain[i1][j1];
- }
- }else
- {
- printf("Incorrect move.\nPlease re-enter your move.");
- movement();
- return;
- }
- }
- if(domain[i1][j1]=='N')
- {
- if((i2==i1+2&&(j2==j1-1||j2==j1+1))||(i2==i1-2&&(j2==j1-1||j2==j1+1))||(j2==j1+2&&(i2==i1-1||i2==i1+1))||(j2==j1-2&&(i2==i1-1||i2==i1+1)))
- {
- if(occupied[i2][j2]==2)
- {
- printf("Incorrect move(moving over your own piece).\nPlease re-enter your move.");
- movement();
- return;
- }
- if(occupied[i2][j2]==1)
- { save_step(i1,j1,i2,j2,domain[i2][j2],domain[i1][j1]);
- occupied[i1][j1]=0;
- occupied[i2][j2]=2;
- killed1[number_killed1]=domain[i2][j2];
- domain[i2][j2]=domain[i1][j1];
- number_killed1++;
- }
- if(occupied[i2][j2]==0)
- { save_step(i1,j1,i2,j2,domain[i2][j2],domain[i1][j1]);
- domain[i2][j2]=domain[i1][j1];
- occupied[i1][j1]=0;
- occupied[i2][j2]=2;
- }
- }else
- {
- printf("Incorrect move.\nPlease re-enter your move.");
- movement();
- }
- }
- if(domain[i1][j1]=='B')
- {
- int n,m;
- if(j2-j1==i2-i1 || j2-j1==i1-i2)
- {
- m=j1+1;
- if(j2>j1&&i2>i1)
- {
- for(n=i1+1;n<i2;n++)
- {
- if(occupied[n][m++])
- {
- printf("Incorrect move(a piece inside the path).\nPlease re-enter your move.");
- movement();
- goto OUT;
- }
- }
- }
- else if(j1>j2 && i2>i1)
- {
- m=j1-1;
- for(n=i1+1;n<i2;n++)
- {
- if(occupied[n][m--])
- {
- printf("Incorrect move(a piece inside the path).\nPlease re-enter your move.");
- movement();
- goto OUT;
- }
- }
- }
- else if (i1>i2 && j2>j1)
- {
- m=j1+1;
- for(n=i1-1;n>i2;n--)
- {
- if(occupied[n][m++])
- {
- printf("Incorrect move(a piece inside the path).\nPlease re-enter your move.");
- movement();
- return;
- }
- }
- }
- else if(i2<i1 && j2<j1)
- {
- m=j1-1;
- for(n=i1-1;n>i2;n--)
- {
- if(occupied[n][m--])
- {
- printf("Incorrect move(a piece inside the path).\nPlease re-enter your move.");
- movement();
- return;
- }
- }
- }}
- else{
- printf("Incorrect move.\nPlease re-enter your move.");
- movement();
- return;
- }
- if(occupied[i2][j2]==2)
- {
- printf("Incorrect move(moving over your own piece).\nPlease re-enter your move.");
- movement();
- return;
- }
- if(occupied[i2][j2]==1)
- {save_step(i1,j1,i2,j2,domain[i2][j2],domain[i1][j1]);
- occupied[i1][j1]=0;
- occupied[i2][j2]=2;
- killed1[number_killed1]=domain[i2][j2];
- domain[i2][j2]=domain[i1][j1];
- number_killed1++;
- }
- if(occupied[i2][j2]==0)
- {save_step(i1,j1,i2,j2,domain[i2][j2],domain[i1][j1]);
- domain[i2][j2]=domain[i1][j1];
- occupied[i1][j1]=0;
- occupied[i2][j2]=2;
- }
- }
- if(domain[i1][j1]=='Q')
- {
- int n,m;
- if(j2-j1==i2-i1 || j2-j1==i1-i2)
- {
- m=j1+1;
- if(j2>j1&&i2>i1)
- {
- for(n=i1+1;n<i2;n++)
- {
- if(occupied[n][m++])
- {
- printf("Incorrect move(a piece inside the path).\nPlease re-enter your move.");
- movement();
- return;
- }
- }
- }
- else if(j1>j2 && i2>i1)
- {
- m=j1-1;
- for(n=i1+1;n<i2;n++)
- {
- if(occupied[n][m--])
- {
- printf("Incorrect move(a piece inside the path).\nPlease re-enter your move.");
- movement();
- return;
- }
- }
- }
- else if (i1>i2 && j2>j1)
- {
- m=j1+1;
- for(n=i1-1;n>i2;n--)
- {
- if(occupied[n][m++])
- {
- printf("Incorrect move(a piece inside the path).\nPlease re-enter your move.");
- movement();
- return;
- }
- }
- }
- else if(i2<i1 && j2<j1)
- {
- m=j1-1;
- for(n=i1-1;n>i2;n--)
- {
- if(occupied[n][m--])
- {
- printf("Incorrect move(a piece inside the path).\nPlease re-enter your move.");
- movement();
- return;
- }
- }
- }
- if(occupied[i2][j2]==2)
- {
- printf("Incorrect move(moving over your own piece).\nPlease re-enter your move.");
- movement();
- }
- if(occupied[i2][j2]==1)
- { save_step(i1,j1,i2,j2,domain[i2][j2],domain[i1][j1]);
- occupied[i1][j1]=0;
- occupied[i2][j2]=2;
- killed1[number_killed1]=domain[i2][j2];
- domain[i2][j2]=domain[i1][j1];
- number_killed1++;
- }
- if(occupied[i2][j2]==0)
- { save_step(i1,j1,i2,j2,domain[i2][j2],domain[i1][j1]);
- domain[i2][j2]=domain[i1][j1];
- occupied[i1][j1]=0;
- occupied[i2][j2]=2;
- }
- }
- else if(i2==i1)
- {
- int n;
- if(j2>j1){
- for(n=j1+1;n<j2;n++)
- {
- if(occupied[i1][n])
- {
- printf("Incorrect move(a piece inside the path).\nPlease re-enter your move.");
- movement();
- return;
- }}}
- if(j1>j2)
- {
- for(n=j1-1;n>j2;n--)
- {
- if(occupied[i1][n])
- {
- printf("Incorrect move(a piece inside the path).\nPlease re-enter your move.");
- movement();
- return;
- }}
- }
- if(occupied[i1][j2]==2)
- {
- printf("Incorrect move(moving over your own piece).\nPlease re-enter your move.");
- movement();
- return;
- }
- if(occupied[i2][j2]==1)
- { save_step(i1,j1,i2,j2,domain[i2][j2],domain[i1][j1]);
- occupied[i2][j2]=2;
- occupied[i1][j1]=0;
- killed1[number_killed1]=domain[i2][j2];
- domain[i2][j2]=domain[i1][j1];
- number_killed1++;
- }
- if(occupied[i2][j2]==0)
- { save_step(i1,j1,i2,j2,domain[i2][j2],domain[i1][j1]);
- domain[i2][j2]=domain[i1][j1];
- occupied[i1][j1]=0;
- occupied[i2][j2]=2;
- }
- }
- else if(j2==j1)
- {
- int n;
- if(i2>i1)
- {
- for(n=i1+1;n<i2;n++)
- {
- if(occupied[n][j1])
- {
- printf("Incorrect move(a piece inside the path).\nPlease re-enter your move.");
- movement();
- return;
- }}}
- if(i1>i2)
- {
- for(n=i1-1;n>i2;n--)
- {
- if(occupied[n][j1])
- {
- printf("Incorrect move(a piece inside the path).\nPlease re-enter your move.");
- movement();
- return;
- }}
- }
- if(occupied[i2][j2]==2)
- {
- printf("Incorrect move(moving over your own piece).\nPlease re-enter your move.");
- movement();
- return;
- }
- if(occupied[i2][j2]==1)
- { save_step(i1,j1,i2,j2,domain[i2][j2],domain[i1][j1]);
- occupied[i1][j1]=0;
- occupied[i2][j2]=2;
- killed1[number_killed1]=domain[i2][j2];
- domain[i2][j2]=domain[i1][j1];
- number_killed1++;
- }
- if(occupied[i2][j2]==0)
- { save_step(i1,j1,i2,j2,domain[i2][j2],domain[i1][j1]);
- occupied[i1][j1]=0;
- occupied[i2][j2]=2;
- domain[i2][j2]=domain[i1][j1];
- }
- }
- else
- {
- printf("Incorrect move.\nPlease re-enter your move.");
- movement();
- return;
- }
- }
- if(domain[i1][j1]=='K')
- {
- move_king(i1,j1,i2,j2);
- }
- }
- OUT : return;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement