complete source code of chess

#include<iostream>
#include<string>
#include<conio.h>
#include<windows.h>
#include<math.h>
#include<cstdlib>
#include<fstream>
#include<vector>
using namespace std;


void initalize(char bor[][8], int rows){
for(int i=0;i<8;i++){
for(int j=0;j<8;j++){
bor[i][j]=' ';
}
}
}
void game(char bor[][8],int rows){
initalize(bor,8);
for(int i=0;i<8;i++){
for(int j=0;j<8;j++){
bor[0][0]=bor[0][7]='R';
bor[0][1]=bor[0][6]='N';
bor[0][2]=bor[0][5]='B';
bor[0][4]='K';
bor[0][3]='Q';
bor[1][0]=bor[1][7]='P';
bor[1][1]=bor[1][6]='P';
bor[1][2]=bor[1][5]='P';
bor[1][3]=bor[1][4]='P';
bor[7][0]=bor[7][7]='r';
bor[7][1]=bor[7][6]='n';
bor[7][2]=bor[7][5]='b';
bor[7][4]='k';
bor[7][3]='q';
bor[6][0]=bor[6][7]='p';
bor[6][1]=bor[6][6]='p';
bor[6][2]=bor[6][5]='p';
bor[6][3]=bor[6][4]='p';
}
}
}
void printBoard(char bor[][8],int rows){
//cout<<"\n";
for(int i=0;i<8;i++){
cout<<"|     ";
if(i==7){cout<<"|";
}
}
cout<<endl;
for(int i=0;i<8;i++){
for(int j=0;j<8;j++){
cout<<"|  "<<bor[i][j]<<"  ";
if(j==7){cout<<"|";}
}
cout<<endl;
for(int j=0;j<8;j++){
cout<<"|_____";
if( j==7){cout<<"|";}
}
cout<<endl;
}
}
void Takesource(char bor[8][8],int &turn,int &row,int &col  )//for 1st player move
{
bool flag=false;
while(flag==false){
cout<<"ENTER source:"<<endl;
cin>>row>>col;

if((row>7||row<0)||(col>7||col<0)){cout<<"invalid mone enter again;"<<endl;
flag=false;}
 

else if(bor[row][col]==' '){cout<<"invalid mone enter again;"<<endl;
flag=false;}
//*******check if player1 enter opponent cordinate
else if(turn==0&&bor[row][col]=='p'){
cout<<"\nyou can't select opponents piece: enter again";
flag=false;
}
else if(turn==0&&bor[row][col]=='k'){
cout<<"\nyou can't select opponents piece: enter again";
flag=false;
}
else if(turn==0&&bor[row][col]=='q'){
cout<<"\nyou can't select opponents piece: enter again";
flag=false;
}
else if(turn==0&&bor[row][col]=='b'){
cout<<"\nyou can't select opponents piece: enter again";
flag=false;
}
else if(turn==0&&bor[row][col]=='n'){
cout<<"\nyou can't select opponents piece: enter again";
flag=false;
}
else if(turn==0&&bor[row][col]=='r'){
cout<<"\nyou can't select opponents piece: enter again";
flag=false;
}
//*******check if player1 enter opponent cordinate
else if(turn==1&&bor[row][col]=='P'){
cout<<"\nyou can't select opponents piece: enter again";
flag=false;
}
else if(turn==1&&bor[row][col]=='K'){
cout<<"\nyou can't select opponents piece: enter again";
flag=false;
}
else if(turn==1&&bor[row][col]=='Q'){
cout<<"\nyou can't select opponents piece: enter again";
flag=false;
}
else if(turn==1&&bor[row][col]=='B'){
cout<<"\nyou can't select opponents piece: enter again";
flag=false;
}
else if(turn==1&&bor[row][col]=='N'){
cout<<"\nyou can't select opponents piece: enter again";
flag=false;
}
else if(turn==1&&bor[row][col]=='R'){
cout<<"\nyou can't select opponents piece: enter again";
flag=false;
}
//*******check if player enter opponent cordinate  ends here

else {flag=true;}
}
}
void Takedestination(char bor[8][8],int &turn,int &r,int &c )//for 1st player move
{
bool flag=false;
while(flag==false){
cout<<"ENTER destination:"<<endl;
cin>>r>>c;
if((r>7||r<0)||(c>7||c<0)){cout<<"invalid mone enter again;"<<endl;
flag=false;}
 

else if(bor[r][c]=='K'||bor[r][c]=='k'){cout<<"invalid mone enter again;"<<endl;
flag=false;}
//*******check if player1 enter opponent cordinate
else if(turn==1&&bor[r][c]=='p'){
cout<<"\nyou can't select own piece: enter again";
flag=false;
}
else if(turn==1&&bor[r][c]=='k'){
cout<<"\nyou can't select own  piece: enter again";
flag=false;
}
else if(turn==1&&bor[r][c]=='q'){
cout<<"\nyou can't select own  piece: enter again";
flag=false;
}
else if(turn==1&&bor[r][c]=='b'){
cout<<"\nyou can't select own  piece: enter again";
flag=false;
}
else if(turn==1&&bor[r][c]=='n'){
cout<<"\nyou can't select own  piece: enter again";
flag=false;
}
else if(turn==1&&bor[r][c]=='r'){
cout<<"\nyou can't select own piece: enter again";
flag=false;
}
//*******check if player1 enter opponent cordinate
else if(turn==0&&bor[r][c]=='P'){
cout<<"\nyou can't select own  piece: enter again";
flag=false;
}
else if(turn==0&&bor[r][c]=='K'){
cout<<"\nyou can't select own  piece: enter again";
flag=false;
}
else if(turn==0&&bor[r][c]=='Q'){
cout<<"\nyou can't select own  piece: enter again";
flag=false;
}
else if(turn==0&&bor[r][c]=='B'){
cout<<"\nyou can't select own  piece: enter again";
flag=false;
}
else if(turn==0&&bor[r][c]=='N'){
cout<<"\nyou can't select own  piece: enter again";
flag=false;
}
else if(turn==0&&bor[r][c]=='R'){
cout<<"\nyou can't select own  piece: enter again";
flag=false;
}
//*******check if player enter opponent cordinate  ends here

else {flag=true;}
}
}
void TakeInput(char bor[8][8],int &turn,int &row,int &col,int &r,int &c  )
{
Takesource(bor,turn,row,col  );

Takedestination( bor, turn,r,c  );
}
void poun(char bor[][8],int &turn,int &row,int &col,int &r,int &c)//poun 1st move
{    
//row and col stands for source and r and c stands for destination
if(bor[row][col]='P'){
if((row==1&&c==col)){
 if((bor[row+1][col])==' ')
if((r==row+2 ||r==row+1)){
if(bor[r][c]==' ')
  bor[r][c]=bor[row][col];
bor[row][col]=' ';
 
  }
else {cout<<"invalid move;";turn--;} 
}
else if ((row>1)&&(r==row+1)&&(c==col)&&(bor[r][c]==' ')){
    //if((bor[row+1][col])==' ')
if(bor[r][c]==' '){
bor[r][c]=bor[row][col];
bor[row][col]=' ';}
else {cout<<"invalid move;";turn--;} 
}
 
else if((row>1)&&((c==col+1)||(c==col-1))){
if((bor[r][c]=='p'||bor[r][c]=='k'||bor[r][c]=='q'||bor[r][c]=='n'||bor[r][c]=='b'||bor[r][c]=='r')){
  bor[r][c]=bor[row][col];
bor[row][col]=' ';
}
else {cout<<"invalid move;";turn--;}  
}
  else if(r<row&&c<col){cout<<"invalid move;";turn--;} 
 
}
 
}
void poun2(char bor[][8],int &turn,int &row,int &col,int &r,int &c)//poun 1st move
{  
if(bor[row][col]='p'){
if((row==6&&c==col)){
 if((bor[row-1][col])==' ')
if((r==row-2 ||r==row-1)){
if(bor[r][c]==' ')
  bor[r][c]=bor[row][col];
bor[row][col]=' ';
 
  }
else {cout<<"invalid move;";turn--;} 
}
else if ((row<6)&&(r==row-1)&&(c==col)&&(bor[r][c]==' ')){
    
if(bor[r][c]==' '){
bor[r][c]=bor[row][col];
bor[row][col]=' ';}
else {cout<<"invalid move;";turn--;} 
}
 
else if((row<6)&&((c==col+1)||(c==col-1))){
if((bor[r][c]=='P'||bor[r][c]=='K'||bor[r][c]=='Q'||bor[r][c]=='N'||bor[r][c]=='B'||bor[r][c]=='R')){
  bor[r][c]=bor[row][col];
bor[row][col]=' ';
}
else {cout<<"invalid move;";turn--;} 
}
else if(r<row&&c<col){ cout<<"invalid move;";turn--;} 
 
}
  
}
void RockMove(char bor[][8],int &turn,int &row,int &col,int &r,int &c)
{
if(bor[row][col]=='R'||bor[row][col]=='r'){
int x=0,y=0;
bool flag=true;
if(c==col&&row!=r){
if(r>row){x=row;y=r;}
else if(r<row){x=r;y=row;}
                  x=x+1;
while(x<y){
if(bor[x][c]!=' '){flag=false;}else {flag=true;}
 
x++;  
}
if(flag==true){bor[r][c]=bor[row][col]; bor[row][col]=' ';}
   
else {cout<<"invalid move;";turn--;} 
}
else if(c!=col&&row==r){
if(c>col){x=col;y=c;}
else if(c<col){x=c;y=col;}
                  x=x+1;
while(x<y){
if(bor[r][x]!=' '){flag=false;}else {flag=true;}
 
x++;  
}
if(flag==true){
bor[r][c]=bor[row][col]; 
bor[row][col]=' ';}
   
else {cout<<"invalid move;";turn--;} 
}
}
}
void Night(char bor[][8],int &turn,int &row,int &col,int &r,int &c){
if (bor[row][col]=='N'||bor[row][col]=='n'){
if(row==r||col==c){
cout<<"\ninvalid move";
turn--;}


else if((r<row)&&(r==row-2)&&(c==col+1||c==col-1)){
bor[r][c]=bor[row][col]; 
bor[row][col]=' ';
}
else if((r>row)&&(r==row+2)&&(c==col+1||c==col-1)){
if(bor[r][c]=='p'||bor[r][c]==' '||bor[r][c]=='q'||bor[r][c]=='n'||bor[r][c]=='b'||bor[r][c]=='r'){
bor[r][c]=bor[row][col]; 
bor[row][col]=' ';
}
}
else if((c==col+2||c==col-2)){
if((r<row)&&(r==row-1))
if(bor[r][c]=='p'||bor[r][c]==' '||bor[r][c]=='q'||bor[r][c]=='n'||bor[r][c]=='b'||bor[r][c]=='r'){
bor[r][c]=bor[row][col]; 
bor[row][col]=' ';
}
else if((r>row)&&(r==row+1)){
if(bor[r][c]=='p'||bor[r][c]==' '||bor[r][c]=='q'||bor[r][c]=='n'||bor[r][c]=='b'||bor[r][c]=='r'){
bor[r][c]=bor[row][col]; 
bor[row][col]=' ';
}
}
}
else{
cout<<"\ninvalid move";
turn--;}
}
}
void King(char bor[][8],int &turn,int &row,int &col,int &r,int &c){
if(bor[row][col]=='K'||bor[row][col]=='k')
{
//if one step up/down
if((col==c)&&abs(row-r)>1){
cout<<"\nillegal move:";
turn--;
}
else if((col==c)&&(r==row+1||r==row-1)){bor[r][c]=bor[row][col]; 
bor[row][col]=' '; }
//if one step forward/backward
else if((row==r)&&(c==col+1||c==col-1)){bor[r][c]=bor[row][col]; 
bor[row][col]=' '; }
//if diagonall moved king
else if(((r==row+1||r==row-1))&&(c==col+1||c==col-1)){bor[r][c]=bor[row][col]; 
bor[row][col]=' '; }
}
else{
cout<<"\ninvalid move:";
turn--;
}
}
void Bishop(char bor[][8],int &turn,int &row,int &col,int &r,int &c){
if((bor[row][col]=='B'||bor[row][col]=='b'))
{
int x=0,y=0;
bool flag=true;
if((r>row)&&(c<col)&&(col-c==r-row)){
x=row,y=r;
//int d=y-x;
x=x+1;
int z=col-1;
while((x<r&&z>c)){
if(bor[x][z]!=' '){flag=false;}else {flag=true;}
 
x++;  
z--;
}
if(flag==true){bor[r][c]=bor[row][col]; bor[row][col]=' ';}
else if(flag==false) {turn--;}
}    
else if((r<row)&&(c>col)&&(c-col==row-r)){
x=r,y=row;
//int x=0,y=0;
bool flag=true;
//int d=y-x;
//if((c==col+d)){
int b=row-1;
int z=col+1;
while((b>r&&z<c)){
if(bor[b][z]!=' '){flag=false;}else {flag=true;}
 
b--;  
z++;
}
if(flag==true){bor[r][c]=bor[row][col]; bor[row][col]=' ';}
else if(flag==false) {turn--;}
}    
else if((r>row)&&(c>col)&&(c-col==r-row)){
x=0,y=0;
x=row,y=r;
bool flag=true;
//int d=y-x;
x=x+1;
int z=col+1;
while((x<r&&z<c)){
if(bor[x][z]!=' '){flag=false;}else {flag=true;}
 
x++;  
z++;
}
if(flag==true){bor[r][c]=bor[row][col]; bor[row][col]=' ';}
else if(flag==false) {turn--;}
}    
else if((r<row)&&(c<col)&&(col-c==row-r)){
x=r,y=row;
//int x=0,y=0;
bool flag=true;
//int d=y-x;
//if((c==col+d)){
int b=row-1;
int z=col-1;
while((b>r&&z>c)){
if(bor[b][z]!=' '){flag=false;}else {flag=true;}
 
b--;  
z--;
}
if(flag==true){bor[r][c]=bor[row][col]; bor[row][col]=' ';}
else if(flag==false) {turn--;}
}    
}
else{
cout<<"\ninvalid move:";
turn--;
}
}
void QueenMove(char bor[][8],int &turn,int &row,int &col,int &r,int &c)
{
if(bor[row][col]=='Q'||bor[row][col]=='q'){
int x=0,y=0;
bool flag=true;
if(c==col&&row!=r){
if(r>row){x=row;y=r;}
else if(r<row){x=r;y=row;}
                  x=x+1;
while(x<y){
if(bor[x][c]!=' '){flag=false;}else {flag=true;}
 
x++;  
}
if(flag==true){bor[r][c]=bor[row][col]; bor[row][col]=' ';}
   
else {cout<<"invalid move;";turn--;} 
}
else if(c!=col&&row==r){
if(c>col){x=col;y=c;}
else if(c<col){x=c;y=col;}
                  x=x+1;
while(x<y){
if(bor[r][x]!=' '){flag=false;}else {flag=true;}
 
x++;  
}
if(flag==true){
bor[r][c]=bor[row][col]; 
bor[row][col]=' ';}
   else if(flag==false) {turn--;}
}
else if((r>row)&&(c<col)&&(col-c==r-row)){
int x=0,y=0;
x=row,y=r;
bool flag=true;
x=x+1;
int z=col-1;
while((x<r&&z>c)){
if(bor[x][z]!=' '){flag=false;}else {flag=true;}
 
x++;  
z--;
}
if(flag==true){bor[r][c]=bor[row][col]; bor[row][col]=' ';}
else if(flag==false) {turn--;}
}    
else if((r<row)&&(c>col)&&(c-col==row-r)){
x=r,y=row;
bool flag=true;
int b=row-1;
int z=col+1;
while((b>r&&z<c)){
if(bor[b][z]!=' '){flag=false;}else {flag=true;}
 
b--;  
z++;
}
if(flag==true){bor[r][c]=bor[row][col]; bor[row][col]=' ';}
else if(flag==false) {turn--;}
}    
else if((r>row)&&(c>col)&&(c-col==r-row)){
x=0,y=0;
x=row,y=r;
bool flag=true;
x=x+1;
int z=col+1;
while((x<r&&z<c)){
if(bor[x][z]!=' '){flag=false;}else {flag=true;}
 
x++;  
z++;
}
if(flag==true){bor[r][c]=bor[row][col]; bor[row][col]=' ';}
else if(flag==false) {turn--;}
}    
else if((r<row)&&(c<col)&&(col-c==row-r)){
x=r,y=row;
bool flag=true;
int b=row-1;
int z=col-1;
while((b>r&&z>c)){
if(bor[b][z]!=' '){flag=false;}else {flag=true;}
 
b--;  
z--;
}
if(flag==true){bor[r][c]=bor[row][col]; bor[row][col]=' ';}
else if(flag==false) {turn--;}
}    
}
else{
cout<<"\ninvalid move:";
turn--;
}
}

void player2checkpawn(char board[][8],int i,int j,bool &isCheckmate)
{
if(board[i+1][j]=='k'||board[i+1][j+1]=='k'||board[i+1][j-1]=='k'){isCheckmate=true;}
}
void player1checkpawn(char board[][8],int i,int j,bool &isCheckmate)
{
if(board[i+1][j]=='K'||board[i+1][j+1]=='K'||board[i+1][j-1]=='K'){isCheckmate=true;}
}
void player1checkrook(char board[][8],int i,int j,bool &isCheckmate)
{
int x=i;
int y=j;
while(x<8)
{
if(board[x+1][y]=='K'){isCheckmate=true;}
x++;
}
x=i;
y=j;
while(x>0)
{
if(board[x-1][y]=='K'){isCheckmate=true;}
x--;
}
x=i;
y=j;
while(y<8)
{
if(board[x][y+1]=='K'){isCheckmate=true;}
x++;
}
x=i;
y=j;
while(y>0)
{
if(board[x][y-1]=='K'){isCheckmate=true;}
x--;
}

}
void player2checkrook(char board[][8],int i,int j,bool &isCheckmate)
{
int x=i;
int y=j;
while(x<8)
{
if(board[x+1][y]=='k'){isCheckmate=true;}
x++;
}
x=i;
y=j;
while(x>0)
{
if(board[x-1][y]=='k'){isCheckmate=true;}
x--;
}
x=i;
y=j;
while(y<8)
{
if(board[x][y+1]=='k'){isCheckmate=true;}
x++;
}
x=i;
y=j;
while(y>0)
{
if(board[x][y-1]=='k'){isCheckmate=true;}
x--;
}

}
void player1checkking(char board[][8],int i,int j,bool &isCheckmate)
{
if(board[i-1][j-1]=='K'||board[i-1][j+1]=='K'||board[i-1][j]=='K'||board[i+1][j]=='K'||board[i+1][j]=='K'||board[i+1][j+1]=='K'||board[i+1][j-1]=='K'||board[i][j-1]=='K'||board[i][j+1]=='K'){isCheckmate=true;}
}
void player2checkking(char board[][8],int i,int j,bool &isCheckmate)
{
if(board[i-1][j-1]=='k'||board[i-1][j+1]=='k'||board[i-1][j]=='k'||board[i+1][j]=='k'||board[i+1][j]=='k'||board[i+1][j+1]=='k'||board[i+1][j-1]=='k'||board[i][j-1]=='k'||board[i][j+1]=='k'){isCheckmate=true;}
}
void player1checkbishop(char board[][8],int i,int j,bool &isCheckmate)
{
int x=i;
int y=j;
while(x<8&&y<8)
{
if(board[x+1][y+1]=='K')
{
isCheckmate=true;
}
x++;y++;
}
x=i;
y=j;
while(x<8&&y>=0)
{
if(board[x-1][y+1]=='K')
{
isCheckmate=true;
}
x--;y++;
}

x=i;
y=j;
while(x>=8&&y>=0)
{
if(board[x-1][y-1]=='K')
{
isCheckmate=true;
}
x--;y--;
}

x=i;
y=j;
while(x<8&&y>=0)
{
if(board[x+1][y-1]=='K')
{
isCheckmate=true;
}
x++;y--;
}


}
void player2checkbishop(char board[][8],int i,int j,bool &isCheckmate)
{
int x=i;
int y=j;
while(x<8&&y<8)
{
if(board[x+1][y+1]=='k')
{
isCheckmate=true;
}
x++;y++;
}
x=i;
y=j;
while(x<8&&y>=0)
{
if(board[x-1][y+1]=='k')
{
isCheckmate=true;
}
x--;y++;
}

x=i;
y=j;
while(x>=8&&y>=0)
{
if(board[x-1][y-1]=='k')
{
isCheckmate=true;
}
x--;y--;
}

x=i;
y=j;
while(x<8&&y>=0)
{
if(board[x+1][y-1]=='k')
{
isCheckmate=true;
}
x++;y--;
}


}

void player1checkqueen(char board[][8],int i,int j,bool &isCheckmate)
{
int x=i;
int y=j;
while(x<8)
{
if(board[x+1][y]=='K'){isCheckmate=true;}
x++;
}
x=i;
y=j;
while(x>0)
{
if(board[x-1][y]=='K'){isCheckmate=true;}
x--;
}
x=i;
y=j;
while(y<8)
{
if(board[x][y+1]=='K'){isCheckmate=true;}
x++;
}
x=i;
y=j;
while(y>0)
{
if(board[x][y-1]=='K'){isCheckmate=true;}
x--;
}

x=i;
y=j;
while(x<8&&y<8)
{
if(board[x+1][y+1]=='K')
{
isCheckmate=true;
}
x++;y++;
}
x=i;
y=j;
while(x<8&&y>=0)
{
if(board[x-1][y+1]=='K')
{
isCheckmate=true;
}
x--;y++;
}

x=i;
y=j;
while(x>=8&&y>=0)
{
if(board[x-1][y-1]=='K')
{
isCheckmate=true;
}
x--;y--;
}

x=i;
y=j;
while(x<8&&y>=0)
{
if(board[x+1][y-1]=='K')
{
isCheckmate=true;
}
x++;y--;
}

}
void player2checkqueen(char board[][8],int i,int j,bool &isCheckmate)
{
int x=i;
int y=j;
while(x<8)
{
if(board[x+1][y]=='k'){isCheckmate=true;}
x++;
}
x=i;
y=j;
while(x>0)
{
if(board[x-1][y]=='k'){isCheckmate=true;}
x--;
}
x=i;
y=j;
while(y<8)
{
if(board[x][y+1]=='k'){isCheckmate=true;}
x++;
}
x=i;
y=j;
while(y>0)
{
if(board[x][y-1]=='k'){isCheckmate=true;}
x--;
}

x=i;
y=j;
while(x<8&&y<8)
{
if(board[x+1][y+1]=='k')
{
isCheckmate=true;
}
x++;y++;
}
x=i;
y=j;
while(x<8&&y>=0)
{
if(board[x-1][y+1]=='k')
{
isCheckmate=true;
}
x--;y++;
}

x=i;
y=j;
while(x>=8&&y>=0)
{
if(board[x-1][y-1]=='k')
{
isCheckmate=true;
}
x--;y--;
}

x=i;
y=j;
while(x<8&&y>=0)
{
if(board[x+1][y-1]=='k')
{
isCheckmate=true;
}
x++;y--;
}

}
void player1checkknight(char board[][8],int i,int j,bool &isCheckmate)
{
if(board[i-2][j-2]=='K'||board[i-2][j+1]=='K'||board[i-1][j-2]=='K'||board[i-1][j+2]=='K'||board[i+1][j-2]=='K'||board[i+1][j+2]=='K'||board[i+2][j-1]=='K'||board[i+2][j+2]=='K'){isCheckmate=true;}
}
void player2checkknight(char board[][8],int i,int j,bool &isCheckmate)
{
if(board[i-2][j-2]=='k'||board[i-2][j+1]=='k'||board[i-1][j-2]=='k'||board[i-1][j+2]=='k'||board[i+1][j-2]=='k'||board[i+1][j+2]=='k'||board[i+2][j-1]=='k'||board[i+2][j+2]=='k'){isCheckmate=true;}
}
bool checkmate(char bor[][8],int &turn)
{
bool isCheckmate=false;
for(int i=0;i<8;i++)
{
for(int j=0;j<8;j++)
{
char ch=bor[i][j];
if(turn%2==0)
{
if(ch=='P'){player2checkpawn(bor,i,j,isCheckmate);}
if(ch=='K'){player2checkking(bor,i,j,isCheckmate);}
if(ch=='N'){player2checkknight(bor,i,j,isCheckmate);}
if(ch=='B'){player2checkbishop(bor,i,j,isCheckmate);}
if(ch=='Q'){player2checkqueen(bor,i,j,isCheckmate);}
if(ch=='R'){player2checkrook(bor,i,j,isCheckmate);}

}
else
{
if(ch=='p'){player1checkpawn(bor,i,j,isCheckmate);}
if(ch=='k'){player1checkking(bor,i,j,isCheckmate);}
if(ch=='n'){player1checkknight(bor,i,j,isCheckmate);}
if(ch=='b'){player1checkbishop(bor,i,j,isCheckmate);}
if(ch=='q'){player1checkqueen(bor,i,j,isCheckmate);}
if(ch=='r'){player1checkrook(bor,i,j,isCheckmate);}
}
}

if(isCheckmate){return true;}
return false;
}
return isCheckmate;
}
 
int main()
{
char bor[8][8];
int rows=8;
game(bor,8);
printBoard(bor,8);
int  row,col,r,c;
bool flag=true;
      int  turn=0;
while(flag==true){
   turn=turn%2;
if (turn==0){cout<<"player 1 moves:";}
if(turn==1){cout<<"player 2 moves:";}
TakeInput( bor,turn,row,col,r,c);
if (turn%2==0){
if(bor[row][col]=='R'||bor[row][col]=='r')
{
RockMove( bor,turn,row,col,r,c);
}
if(bor[row][col]=='P'||bor[row][col]=='p')
{
poun( bor, turn,row,col,r,c);
}
if(bor[row][col]=='N'||bor[row][col]=='n')
{
Night( bor, turn,row,col,r,c);
}
if(bor[row][col]=='K'||bor[row][col]=='k')
{King( bor, turn,row,col,r,c);}
if(bor[row][col]=='B')
{Bishop( bor, turn,row,col,r,c);}
if(bor[row][col]=='Q')
{QueenMove( bor, turn,row,col,r,c);}
}
if(turn%2==1){
if(bor[row][col]=='R'||bor[row][col]=='r')
{
RockMove( bor,turn,row,col,r,c);
}
if(bor[row][col]=='P'||bor[row][col]=='p')
{
poun2( bor, turn,row,col,r,c);
}
if(bor[row][col]=='N'||bor[row][col]=='n')
{
Night( bor, turn,row,col,r,c);
}
if(bor[row][col]=='K'||bor[row][col]=='k')
{King( bor, turn,row,col,r,c);}
if(bor[row][col]=='b')
{Bishop( bor, turn,row,col,r,c);}
if(bor[row][col]=='q')
{QueenMove( bor, turn,row,col,r,c);}
}
system("cls");
printBoard(bor,8);
turn++;
}
return 0;

Comments

Popular Posts