**C_Projects Source Codes List | Source Code Home**

Program : Chess Game Developed in C .

/*

Language: C\C++

Category: Games

Description: It is chess. Two players can play it. \

To simplify the code i have not intriduced the mouse.\

We can play it using Keyboard.I have made this using \

general rules.

*/

#include graphics.h

Program : Chess Game Developed in C .

/*

Language: C\C++

Category: Games

Description: It is chess. Two players can play it. \

To simplify the code i have not intriduced the mouse.\

We can play it using Keyboard.I have made this using \

general rules.

*/

#include graphics.h

#include stdlib.h

#include stdio.h

#include iostream.h

#include conio.h

#include ctype.h //For toupper

#include dos.h //For Delay

int board[8][8],turn=0,count1=0,count2=0;

#include stdlib.h

#include stdio.h

#include iostream.h

#include conio.h

#include ctype.h //For toupper

#include dos.h //For Delay

int board[8][8],turn=0,count1=0,count2=0;

int gameover();

char strFileName[15];

void printboard();

void wrongStart();

void initialize();

void cleartext();

void check();

//Prototypes

int gameover();

char strFileName[15];

void printboard();

void wrongStart();

void initialize();

void cleartext();

void check();

//Prototypes

int pawn(int x,int y,int x1,int y1);

int horse(int x,int y,int x1,int y1);

int rook(int x,int y,int x1,int y1);

int bishop(int x,int y,int x1,int y1);

int queen(int x,int y,int x1,int y1);

int king(int x,int y,int x1,int y1);

void main()

int pawn(int x,int y,int x1,int y1);

int horse(int x,int y,int x1,int y1);

int rook(int x,int y,int x1,int y1);

int bishop(int x,int y,int x1,int y1);

int queen(int x,int y,int x1,int y1);

int king(int x,int y,int x1,int y1);

void main()

{

//Graphics Initialization

{

//Graphics Initialization

int gdriver = DETECT;

int gmode;

initgraph(&gdriver,&gmode,"e:\\borlandc\\bgi");

//Loading Intro

int gdriver = DETECT;

int gmode;

initgraph(&gdriver,&gmode,"e:\\borlandc\\bgi");

//Loading Intro

for(float i=0; i<=6;i=i+0.1)

{

setcolor(12);

settextstyle(4,HORIZ_DIR,i);

outtextxy(50,120,"WELCOME TO THE CHESS");

delay(30);

cleardevice();

}

outtextxy(50,120,"WELCOME TO THE CHESS");

settextstyle(1,HORIZ_DIR,3);

getch();

cleardevice();

//Displaying Group Members

for(float i=0; i<=6;i=i+0.1)

{

setcolor(12);

settextstyle(4,HORIZ_DIR,i);

outtextxy(50,120,"WELCOME TO THE CHESS");

delay(30);

cleardevice();

}

outtextxy(50,120,"WELCOME TO THE CHESS");

settextstyle(1,HORIZ_DIR,3);

getch();

cleardevice();

//Displaying Group Members

setcolor(CYAN);

outtextxy(50,220,"Designed by:");

setcolor(6);

outtextxy(50,250,"Atif Zia Khan");

//Displaying Roll Numbers

setcolor(CYAN);

outtextxy(50,220,"Designed by:");

setcolor(6);

outtextxy(50,250,"Atif Zia Khan");

//Displaying Roll Numbers

outtextxy(350,250,"L1F01BSCS0144");

getch();

cleardevice();

cleardevice();

settextstyle(1,HORIZ_DIR,2);

outtextxy(350,250,"L1F01BSCS0144");

getch();

cleardevice();

cleardevice();

settextstyle(1,HORIZ_DIR,2);

setcolor(12);

outtextxy(50,10,"During the game Press:\n");

outtextxy(50,10,"______________________\n");

setcolor(6);

setcolor(12);

outtextxy(50,10,"During the game Press:\n");

outtextxy(50,10,"______________________\n");

setcolor(6);

settextstyle(1,HORIZ_DIR,1.5);

outtextxy(50,60,"F2 to save file\n");

outtextxy(50,80,"F3 to load file\n");

outtextxy(50,100,"ESC to exit game\n");

outtextxy(50,120,"U to undo selection\n");

outtextxy(50,200,"\nPress any key to play ");

getch();

cleardevice();

cleartext();

settextstyle(1,HORIZ_DIR,1.5);

outtextxy(50,60,"F2 to save file\n");

outtextxy(50,80,"F3 to load file\n");

outtextxy(50,100,"ESC to exit game\n");

outtextxy(50,120,"U to undo selection\n");

outtextxy(50,200,"\nPress any key to play ");

getch();

cleardevice();

cleartext();

initialize();

char ch;

int x=-1,y=-1,x1=-1,y1=-1;

setcolor(9);

outtextxy(10,400,"Player 1");

for(;;)

{

int game;

game=gameover();

if(game==0)

{

break;

}

FILE *fp;

ch=getch();

if(ch==0){

ch=getch();

if(ch=='<'){

initialize();

char ch;

int x=-1,y=-1,x1=-1,y1=-1;

setcolor(9);

outtextxy(10,400,"Player 1");

for(;;)

{

int game;

game=gameover();

if(game==0)

{

break;

}

FILE *fp;

ch=getch();

if(ch==0){

ch=getch();

if(ch=='<'){

**//////SAVE/////**

**for(;;)**

{

cout<<"\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\

\b\b\bEnter File name to save \n";

cin>>strFileName; //Enter File Name

fp=fopen(strFileName,"r+");

if(fp!=NULL)

{

cout<<"File already exist\n";

}

else

{

fp=fopen(strFileName,"w+");

if(fp==NULL)

{

cout<<"Invalid File Name\n";

}

else

break;

}

}//end for

fprintf(fp,"%d\n",turn);

for(int i=0;i<8;i++)

{

for(int j=0;j<8;j++)

{

fprintf(fp,"%d\n",board[i][j]);

}

}

fclose(fp);

cleartext();

x=-1;

y=-1;

x1=-1;

y1=-1;

continue;

}

if(ch=='=')

{

cout<<"\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\

\b\b\bEnter File name to save \n";

cin>>strFileName; //Enter File Name

fp=fopen(strFileName,"r+");

if(fp!=NULL)

{

cout<<"File already exist\n";

}

else

{

fp=fopen(strFileName,"w+");

if(fp==NULL)

{

cout<<"Invalid File Name\n";

}

else

break;

}

}//end for

fprintf(fp,"%d\n",turn);

for(int i=0;i<8;i++)

{

for(int j=0;j<8;j++)

{

fprintf(fp,"%d\n",board[i][j]);

}

}

fclose(fp);

cleartext();

x=-1;

y=-1;

x1=-1;

y1=-1;

continue;

}

if(ch=='=')

{

////Load/////

for(;;)

{

////Load/////

for(;;)

{

cout<<"\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\

\b\b\b\b\bEnter File name to Load \n";

cin>>strFileName;

fp=fopen(strFileName,"r+");

if(fp==NULL)

{

cout<<"File does not exist\n";

}

else

{

break;

}

}//end for

fscanf(fp,"%d",&turn);

for(int i=0;i<8;i++){

for(int j=0;j<8;j++){

fscanf(fp,"%d",&board[i][j]);

}

}

fclose(fp);

printboard();

cleartext();

x=-1;

y=-1;

x1=-1;

y1=-1;

setcolor(0);

outtextxy(10,400,"Player Û");

if(turn!=0){

check();

setcolor(2);

outtextxy(10,400,"Player 2");

}

else{

check();

setcolor(9);

outtextxy(10,400,"Player 1");

}

continue;

}

}

if(ch==27){

{

cout<<"\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\

\b\b\b\b\bEnter File name to Load \n";

cin>>strFileName;

fp=fopen(strFileName,"r+");

if(fp==NULL)

{

cout<<"File does not exist\n";

}

else

{

break;

}

}//end for

fscanf(fp,"%d",&turn);

for(int i=0;i<8;i++){

for(int j=0;j<8;j++){

fscanf(fp,"%d",&board[i][j]);

}

}

fclose(fp);

printboard();

cleartext();

x=-1;

y=-1;

x1=-1;

y1=-1;

setcolor(0);

outtextxy(10,400,"Player Û");

if(turn!=0){

check();

setcolor(2);

outtextxy(10,400,"Player 2");

}

else{

check();

setcolor(9);

outtextxy(10,400,"Player 1");

}

continue;

}

}

if(ch==27){

break;

}

else if(ch=='u'||ch=='U'){

x=-1;

x1=-1;

y1=-1;

y=-1;

cleartext();

continue;

}

if(x==-1){

ch=toupper(ch);

if(ch>=65 && ch<=72){

cout<

x=ch-65;

}

}

else if(y==-1)

{

if(ch>='1' && ch<='8')

{

cout<

y=ch-'1';

if(board[y][x]==0){

wrongStart();

x=-1;

y=-1;

}

else

{

if(turn==0)

{

if(board[y][x]<0)

//if Player 1 has selected a piece of Player 2

{

wrongStart();

x=-1;

y=-1;

}

}

else if(turn!=0)

{

if(board[y][x]>0)

{

wrongStart();

x=-1;

y=-1;

}

}

}

}

if(x!=-1 && y!=-1)

cout<<"\nenter final position ¯ ";

}

else if(x1==-1)

{ //Converting lower to upper case

ch=toupper(ch);

break;

}

else if(ch=='u'||ch=='U'){

x=-1;

x1=-1;

y1=-1;

y=-1;

cleartext();

continue;

}

if(x==-1){

ch=toupper(ch);

if(ch>=65 && ch<=72){

cout<

x=ch-65;

}

}

else if(y==-1)

{

if(ch>='1' && ch<='8')

{

cout<

y=ch-'1';

if(board[y][x]==0){

wrongStart();

x=-1;

y=-1;

}

else

{

if(turn==0)

{

if(board[y][x]<0)

//if Player 1 has selected a piece of Player 2

{

wrongStart();

x=-1;

y=-1;

}

}

else if(turn!=0)

{

if(board[y][x]>0)

{

wrongStart();

x=-1;

y=-1;

}

}

}

}

if(x!=-1 && y!=-1)

cout<<"\nenter final position ¯ ";

}

else if(x1==-1)

{ //Converting lower to upper case

ch=toupper(ch);

if(ch>=65 && ch<=72)

{

cout<

x1=ch-65;

}

}

else if(y1==-1)

{

if(ch>='1' && ch<='8')

{

cout<

y1=ch-'1';

}

int b=0,killed=0;

/////pawn/////

if(ch>=65 && ch<=72)

{

cout<

x1=ch-65;

}

}

else if(y1==-1)

{

if(ch>='1' && ch<='8')

{

cout<

y1=ch-'1';

}

int b=0,killed=0;

/////pawn/////

**if(abs(board[y][x])>=9 &&**

abs(board[y][x])<=16){ //if piece selscted has value greater than 8

and less than 17

b = pawn(x,y,x1,y1);

}//end pawn

//////horse//////

abs(board[y][x])<=16){ //if piece selscted has value greater than 8

and less than 17

b = pawn(x,y,x1,y1);

}//end pawn

//////horse//////

**else if(abs(board[y][x])==2 ||**

abs(board[y][x])==7){ //if piece selscted has value 2 and 7

b = horse(x,y,x1,y1);

}//end horse

////queen///

abs(board[y][x])==7){ //if piece selscted has value 2 and 7

b = horse(x,y,x1,y1);

}//end horse

////queen///

**else if(abs(board[y][x])==4){ ////if piece**

selscted has value 4

b = queen(x,y,x1,y1);

}//end queen

///king///

selscted has value 4

b = queen(x,y,x1,y1);

}//end queen

///king///

**else if(abs(board[y][x])==5){ //if piece**

selscted has value 5

b = king(x,y,x1,y1);

}//end king

///rook///

selscted has value 5

b = king(x,y,x1,y1);

}//end king

///rook///

**else if(abs(board[y][x])==1 ||**

abs(board[y][x])==8){ //if piece selscted has value 1 and 8

b = rook(x,y,x1,y1);

}//end rook

///bishop///

abs(board[y][x])==8){ //if piece selscted has value 1 and 8

b = rook(x,y,x1,y1);

}//end rook

///bishop///

**else if(abs(board[y][x])==3 ||**

abs(board[y][x])==6){ //if piece selscted has value 3 and 6

b = bishop(x,y,x1,y1);

}//end bishop

if(b==2){

abs(board[y][x])==6){ //if piece selscted has value 3 and 6

b = bishop(x,y,x1,y1);

}//end bishop

if(b==2){

if(abs(board[y][x])>=9 && abs(board[y][x])<=16){

char pp;

cout<<"\n\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\

\bwhich piece Q,R,H,B";

pp=getch();

if(turn==0){

if(pp=='r')

board[y1][x1]=1;

else if(pp=='h')

board[y1][x1]=2;

else if(pp=='b')

board[y1][x1]=3;

else if(pp=='q')

board[y1][x1]=4;

}

else{

if(pp=='r')

board[y1][x1]=-1;

else if(pp=='h')

board[y1][x1]=-2;

else if(pp=='r')

board[y1][x1]=-3;

else if(pp=='q')

board[y1][x1]=-4;

}

if(abs(board[y][x])>=9 && abs(board[y][x])<=16){

char pp;

cout<<"\n\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\

\bwhich piece Q,R,H,B";

pp=getch();

if(turn==0){

if(pp=='r')

board[y1][x1]=1;

else if(pp=='h')

board[y1][x1]=2;

else if(pp=='b')

board[y1][x1]=3;

else if(pp=='q')

board[y1][x1]=4;

}

else{

if(pp=='r')

board[y1][x1]=-1;

else if(pp=='h')

board[y1][x1]=-2;

else if(pp=='r')

board[y1][x1]=-3;

else if(pp=='q')

board[y1][x1]=-4;

}

**board[y][x]=0;**

killed =1;

}

else if(abs(board[y][x])==5){

if(board[y][x]==5){

if(count1==1);

wrongStart();}

else if(board[y][x]==-5){

if(count1==1);

wrongStart();}

else{

board[y][x+1]=board[y1][x1];

board[y][x+2]=board[y][x];

board[y1][x1]=0;

board[y][x]=0;

killed=1;

}

}

printboard();

}

else if(b==1)

{

if(turn==0)

{

if(board[y1][x1]<0)

{

board[y1][x1]=board[y][x];

board[y][x] = 0;

killed=1;

}

}

if(turn!=0)

{

if(board[y1][x1]>0)

{

board[y1][x1]=board[y][x];

board[y][x] = 0;

killed=1;

}

}

if(board[y1][x1]==0)

{

int temp=board[y][x];

board[y][x]=board[y1][x1];

board[y1][x1]=temp;

killed=1;

}

printboard();

}

x=-1;

y=-1;

x1=-1;

y1=-1;

setcolor(0);

outtextxy(30,340,"Check");

if(killed==0){

wrongStart();

continue;

}

cleartext();

setcolor(0);

outtextxy(10,400,"Player Û");

if(turn==0){

check();

turn=1;

setcolor(2);

outtextxy(10,400,"Player 2");

}

else{

check();

turn=0;

setcolor(9);

outtextxy(10,400,"Player 1");

}

}//end legal move

}//end for

}//end main

void printboard(){

killed =1;

}

else if(abs(board[y][x])==5){

if(board[y][x]==5){

if(count1==1);

wrongStart();}

else if(board[y][x]==-5){

if(count1==1);

wrongStart();}

else{

board[y][x+1]=board[y1][x1];

board[y][x+2]=board[y][x];

board[y1][x1]=0;

board[y][x]=0;

killed=1;

}

}

printboard();

}

else if(b==1)

{

if(turn==0)

{

if(board[y1][x1]<0)

{

board[y1][x1]=board[y][x];

board[y][x] = 0;

killed=1;

}

}

if(turn!=0)

{

if(board[y1][x1]>0)

{

board[y1][x1]=board[y][x];

board[y][x] = 0;

killed=1;

}

}

if(board[y1][x1]==0)

{

int temp=board[y][x];

board[y][x]=board[y1][x1];

board[y1][x1]=temp;

killed=1;

}

printboard();

}

x=-1;

y=-1;

x1=-1;

y1=-1;

setcolor(0);

outtextxy(30,340,"Check");

if(killed==0){

wrongStart();

continue;

}

cleartext();

setcolor(0);

outtextxy(10,400,"Player Û");

if(turn==0){

check();

turn=1;

setcolor(2);

outtextxy(10,400,"Player 2");

}

else{

check();

turn=0;

setcolor(9);

outtextxy(10,400,"Player 1");

}

}//end legal move

}//end for

}//end main

void printboard(){

for(int i=0;i<8;i++){

for(int j=0;j<8;j++){

if((i+j)%2==0)

setcolor(WHITE);

else

setcolor(BLACK);

outtextxy(270+(j*45),105+(i*45),"ÛÛ");

for(int i=0;i<8;i++){

for(int j=0;j<8;j++){

if((i+j)%2==0)

setcolor(WHITE);

else

setcolor(BLACK);

outtextxy(270+(j*45),105+(i*45),"ÛÛ");

if(board[i][j]<0)

if(board[i][j]<0)

setcolor(GREEN);

else if(board[i][j]>0)

setcolor(9);

if(abs(board[i][j])>=9 && abs(board[i][j])<=16){

setcolor(GREEN);

else if(board[i][j]>0)

setcolor(9);

if(abs(board[i][j])>=9 && abs(board[i][j])<=16){

outtextxy(270+(j*45),105+(i*45),"P");}

else if(abs(board[i][j])==1 || abs(board[i][j])==8){

outtextxy(270+(j*45),105+(i*45),"P");}

else if(abs(board[i][j])==1 || abs(board[i][j])==8){

outtextxy(270+(j*45),105+(i*45),"R");}

else if(abs(board[i][j])==2 || abs(board[i][j])==7){

outtextxy(270+(j*45),105+(i*45),"R");}

else if(abs(board[i][j])==2 || abs(board[i][j])==7){

outtextxy(270+(j*45),105+(i*45),"H");

}

else if(abs(board[i][j])==3 || abs(board[i][j])==6){

outtextxy(270+(j*45),105+(i*45),"B");

}

else if(abs(board[i][j])==4){

outtextxy(270+(j*45),105+(i*45),"Q");

}

else if(abs(board[i][j])==5){

outtextxy(270+(j*45),105+(i*45),"K");

}

}

}

}

void wrongStart()

{

cout<<"\nWrong Input\nPress any key to continue...";

char ch=getch();

if(ch==0){

getch();

}

for(int i=1;i<=30;i++)

for(int j=1;j<=4;j++)

{

gotoxy(i,j);

cout<<" ";

}

gotoxy(1,1);

cout<<"enter initial position ¯ ";

}

/////ClearText////void cleartext(){

outtextxy(270+(j*45),105+(i*45),"H");

}

else if(abs(board[i][j])==3 || abs(board[i][j])==6){

outtextxy(270+(j*45),105+(i*45),"B");

}

else if(abs(board[i][j])==4){

outtextxy(270+(j*45),105+(i*45),"Q");

}

else if(abs(board[i][j])==5){

outtextxy(270+(j*45),105+(i*45),"K");

}

}

}

}

void wrongStart()

{

cout<<"\nWrong Input\nPress any key to continue...";

char ch=getch();

if(ch==0){

getch();

}

for(int i=1;i<=30;i++)

for(int j=1;j<=4;j++)

{

gotoxy(i,j);

cout<<" ";

}

gotoxy(1,1);

cout<<"enter initial position ¯ ";

}

/////ClearText////void cleartext(){

for(int i=1;i<=27;i++)

for(int j=1;j<=8;j++){

gotoxy(i,j);

cout<<" ";

}

gotoxy(1,1);

cout<<"enter initial position ¯ ";

}

/////Initialize////

for(int i=1;i<=27;i++)

for(int j=1;j<=8;j++){

gotoxy(i,j);

cout<<" ";

}

gotoxy(1,1);

cout<<"enter initial position ¯ ";

}

/////Initialize////

void initialize(){

void initialize(){

setcolor(WHITE);

rectangle(250,90,610,450);

setcolor(WHITE);

rectangle(250,90,610,450);

**// Board Printing**

for (int i=250;i<560;i+=90)

for (int j=90;j<450;j+=90)

{

bar(i,j,i+45,j+45);

bar(i+45,j+45,i+90,j+90);

}

for (int i=250;i<560;i+=90)

for (int j=90;j<450;j+=90)

{

bar(i,j,i+45,j+45);

bar(i+45,j+45,i+90,j+90);

}

**//Asigning the Values in the empty spaces**

for(i=2;i<=5;i++)

for(int j=0;j<=7;j++)

board[i][j] = 0;

for(int j=0;j<=7;j++)

for(i=2;i<=5;i++)

for(int j=0;j<=7;j++)

board[i][j] = 0;

for(int j=0;j<=7;j++)

{

board[0][j] = j+1;

board[1][j] = j+9; //Pawns for player 1

board[7][j] = 0-(j+1);

board[6][j] = 0-(j+9); //Pawns for player 2

}

printboard();

setcolor(YELLOW);

{

board[0][j] = j+1;

board[1][j] = j+9; //Pawns for player 1

board[7][j] = 0-(j+1);

board[6][j] = 0-(j+9); //Pawns for player 2

}

printboard();

setcolor(YELLOW);

**outtextxy(265,55,"A");**

outtextxy(310,55,"B");

outtextxy(355,55,"C");

outtextxy(400,55,"D");

outtextxy(445,55,"E");

outtextxy(490,55,"F");

outtextxy(535,55,"G");

outtextxy(580,55,"H");

outtextxy(310,55,"B");

outtextxy(355,55,"C");

outtextxy(400,55,"D");

outtextxy(445,55,"E");

outtextxy(490,55,"F");

outtextxy(535,55,"G");

outtextxy(580,55,"H");

**outtextxy(220,105,"1");**

outtextxy(220,150,"2");

outtextxy(220,195,"3");

outtextxy(220,240,"4");

outtextxy(220,285,"5");

outtextxy(220,330,"6");

outtextxy(220,375,"7");

outtextxy(220,420,"8");

}

////HORSE//////

outtextxy(220,150,"2");

outtextxy(220,195,"3");

outtextxy(220,240,"4");

outtextxy(220,285,"5");

outtextxy(220,330,"6");

outtextxy(220,375,"7");

outtextxy(220,420,"8");

}

////HORSE//////

int horse(int x,int y,int x1,int y1)

int horse(int x,int y,int x1,int y1)

{

int a=0;

if((y1==y+2 && x1==x+1)||(y1==y+2 && x1==x-1)||(y1==y+1 &&

x1==x+2)||(y1==y+1 && x1==x-2)||(y1==y-1 && x1==x+2)||(y1==y-1 &&

x1==x-2)||(y1==y-2 && x1==x+1)||(y1==y-2 && x1==x-1)){

a = 1;

}

return a;

}

/////KING////

{

int a=0;

if((y1==y+2 && x1==x+1)||(y1==y+2 && x1==x-1)||(y1==y+1 &&

x1==x+2)||(y1==y+1 && x1==x-2)||(y1==y-1 && x1==x+2)||(y1==y-1 &&

x1==x-2)||(y1==y-2 && x1==x+1)||(y1==y-2 && x1==x-1)){

a = 1;

}

return a;

}

/////KING////

int king(int x,int y,int x1,int y1)

int king(int x,int y,int x1,int y1)

{

int a = 0;

if((y1==y+1 && x1==x)||(y1==y-1 && x1==x)||(y1==y+1 &&

x1==x+1)||(y1==y+1 && x1==x-1)||(y1==y-1 && x1==x+1)||(y1==y-1 &&

x1==x-1)||(y1==y && x1==x+1)||(y1==y && x1==x-1)){

a = 1;

}

/////CASTLING//////

{

int a = 0;

if((y1==y+1 && x1==x)||(y1==y-1 && x1==x)||(y1==y+1 &&

x1==x+1)||(y1==y+1 && x1==x-1)||(y1==y-1 && x1==x+1)||(y1==y-1 &&

x1==x-1)||(y1==y && x1==x+1)||(y1==y && x1==x-1)){

a = 1;

}

/////CASTLING//////

**else**

if(board[y][x+1]==0&&board[y][x+2]==0&&(abs(board[y1][x1])

==abs(board[y][x+3])==1||abs(board[y1][x1])==

abs(board[y][x+3])==8)){

if(board[y][x+1]==0&&board[y][x+2]==0&&(abs(board[y1][x1])

==abs(board[y][x+3])==1||abs(board[y1][x1])==

abs(board[y][x+3])==8)){

**return 2;**

}

if(a==1)

{

if(board[y][x]==5)

count1=1;

if(board[y][x]==-5)

count2=1;

}

return a;

}

//////BISHOP/////

}

if(a==1)

{

if(board[y][x]==5)

count1=1;

if(board[y][x]==-5)

count2=1;

}

return a;

}

//////BISHOP/////

int bishop(int x,int y,int x1,int y1)

int bishop(int x,int y,int x1,int y1)

{

int a=1,i;

if(abs(x1-x)!=abs(y1-y))

{

a=0;

}

if((x

{

int a=1,i;

if(abs(x1-x)!=abs(y1-y))

{

a=0;

}

if((x

{

for(i=1;(i+x)

{

if(board[y+i][x+i]!=0)

a=0;

}

}

{

for(i=1;(i+x)

{

if(board[y+i][x+i]!=0)

a=0;

}

}

**else if((x>x1)&&(y>y1)){**

for(i=1;(x-i)>x1;i++){

if(board[y-i][x-i]!=0)

a=0;

}

}

else if((x>x1)&&(y

for(i=1;(x-i)>x1;i++){

if(board[y+i][x-i]!=0)

a=0;

}

}

else if((xy1)){

for(i=1;(y-i)>y1;i++){

if(board[y-i][x+i]!=0)

a=0;

}

}

return a;

}

////////QUEEN///////

for(i=1;(x-i)>x1;i++){

if(board[y-i][x-i]!=0)

a=0;

}

}

else if((x>x1)&&(y

for(i=1;(x-i)>x1;i++){

if(board[y+i][x-i]!=0)

a=0;

}

}

else if((xy1)){

for(i=1;(y-i)>y1;i++){

if(board[y-i][x+i]!=0)

a=0;

}

}

return a;

}

////////QUEEN///////

int queen(int x,int y,int x1,int y1){

if(x==x1||y==y1){

//if queen moves in + direction

return rook(x,y,x1,y1);

}

else if(abs(x1-x)==abs(y-y1)){

//if queen moves in diagnol

direction

return bishop(x,y,x1,y1);

}

else

return 0;

}

///ROOK////

int queen(int x,int y,int x1,int y1){

if(x==x1||y==y1){

//if queen moves in + direction

return rook(x,y,x1,y1);

}

else if(abs(x1-x)==abs(y-y1)){

//if queen moves in diagnol

direction

return bishop(x,y,x1,y1);

}

else

return 0;

}

///ROOK////

int rook(int x,int y,int x1,int y1){

int a=1;

if(y1==y)

{

for(int i=x+1;i

{

if(board[y1][i]!=0)

{

a = 0;

break;

}

}

for(i=x-1;i>x1;i--)

{

if(board[y1][i]!=0)

{

a = 0;

break;

}

}

}

else if(x1==x)

{

for(int i=y+1;i

{

if(board[i][x1]!=0)

{

a = 0;

break;

}

}

for(i=y-1;i>y1;i--)

{

if(board[i][x1]!=0)

{

a = 0;

break;

}

}

}

else

{

a=0;

}

return a;

}

///PAWN/////

int rook(int x,int y,int x1,int y1){

int a=1;

if(y1==y)

{

for(int i=x+1;i

{

if(board[y1][i]!=0)

{

a = 0;

break;

}

}

for(i=x-1;i>x1;i--)

{

if(board[y1][i]!=0)

{

a = 0;

break;

}

}

}

else if(x1==x)

{

for(int i=y+1;i

{

if(board[i][x1]!=0)

{

a = 0;

break;

}

}

for(i=y-1;i>y1;i--)

{

if(board[i][x1]!=0)

{

a = 0;

break;

}

}

}

else

{

a=0;

}

return a;

}

///PAWN/////

int pawn(int x,int y,int x1,int y1){

int a=0;

if(turn==0){

if(y==1){

if(y1==(y+2) && x1==x){

if(board[y1][x1]==0&&board[y+1][x]==0){

a = 1;

}

}

}

if(y1==y+1 && x1==x){

if(board[y1][x1]==0){

a = 1;

}

}

else if(y1==(y+1) && (x1==(x+1)||x1==(x-1))){

if(board[y1][x1]<0){

a = 1;

}

}

}

else if(turn==1){

if(y==6){

if( y1==(y-2) && x1==x){

if(board[y1][x1]==0&&board[y-1][x]==0){

a = 1;

}

}

}

if( y1==(y-1) && x1==x){

if(board[y1][x1]==0){

a = 1;

}

}

else if(y1==(y-1) && (x1==(x-1)||x1==(x+1))){

if(board[y1][x1]>0){

a = 1;

}

}

}

if(a==1)

{

if(turn==0)

{

if(y1==7)

return 2;

}

else

{

if(y1==0)

return 2;

}

}

return a;

}

////////Check////////

int pawn(int x,int y,int x1,int y1){

int a=0;

if(turn==0){

if(y==1){

if(y1==(y+2) && x1==x){

if(board[y1][x1]==0&&board[y+1][x]==0){

a = 1;

}

}

}

if(y1==y+1 && x1==x){

if(board[y1][x1]==0){

a = 1;

}

}

else if(y1==(y+1) && (x1==(x+1)||x1==(x-1))){

if(board[y1][x1]<0){

a = 1;

}

}

}

else if(turn==1){

if(y==6){

if( y1==(y-2) && x1==x){

if(board[y1][x1]==0&&board[y-1][x]==0){

a = 1;

}

}

}

if( y1==(y-1) && x1==x){

if(board[y1][x1]==0){

a = 1;

}

}

else if(y1==(y-1) && (x1==(x-1)||x1==(x+1))){

if(board[y1][x1]>0){

a = 1;

}

}

}

if(a==1)

{

if(turn==0)

{

if(y1==7)

return 2;

}

else

{

if(y1==0)

return 2;

}

}

return a;

}

////////Check////////

void check()

void check()

{

int t=0,i,j,x1,y1;

if(turn==0){

for(i=0;i<=7;i++)

{

for(j=0;j<=7;j++)

{

if(board[i][j]==-5)

{

y1=i; x1=j;

break;

}

}

}

for(j=0;j<=7;j++){

for(i=0;i<=7;i++){

if (t==1){

setcolor(9);

rectangle(20,335,100,365);

outtextxy(30,340,"Check");

break;

}

if(board[j][i]>=9 && board[j][i]<=16)

{

int t=0,i,j,x1,y1;

if(turn==0){

for(i=0;i<=7;i++)

{

for(j=0;j<=7;j++)

{

if(board[i][j]==-5)

{

y1=i; x1=j;

break;

}

}

}

for(j=0;j<=7;j++){

for(i=0;i<=7;i++){

if (t==1){

setcolor(9);

rectangle(20,335,100,365);

outtextxy(30,340,"Check");

break;

}

if(board[j][i]>=9 && board[j][i]<=16)

t = pawn(i,j,x1,y1);

else if(board[j][i]==2 || board[j][i]==7)

t = horse(i,j,x1,y1);

else if(board[j][i]==4)

t = queen(i,j,x1,y1);

else if(board[j][i]==1 || board[j][i]==8)

t = rook(i,j,x1,y1);

else if(board[j][i]==3 || board[j][i]==6)

t = bishop(i,j,x1,y1);

}// for

t = pawn(i,j,x1,y1);

else if(board[j][i]==2 || board[j][i]==7)

t = horse(i,j,x1,y1);

else if(board[j][i]==4)

t = queen(i,j,x1,y1);

else if(board[j][i]==1 || board[j][i]==8)

t = rook(i,j,x1,y1);

else if(board[j][i]==3 || board[j][i]==6)

t = bishop(i,j,x1,y1);

}// for

}// for

}//endif turn

else {

for(i=0;i<=7;i++){

for(j=0;j<=7;j++){

if(board[i][j]==5){

y1=i; x1=j;

break;

}

}

}

for(j=0;j<=7;j++){

for(i=0;i<=7;i++){

if (t==1){

setcolor(GREEN);

rectangle(20,335,100,365);

outtextxy(30,340,"Check");

break;

}

if(board[j][i]>=(-9) && board[j][i]<=(-16))

}// for

}//endif turn

else {

for(i=0;i<=7;i++){

for(j=0;j<=7;j++){

if(board[i][j]==5){

y1=i; x1=j;

break;

}

}

}

for(j=0;j<=7;j++){

for(i=0;i<=7;i++){

if (t==1){

setcolor(GREEN);

rectangle(20,335,100,365);

outtextxy(30,340,"Check");

break;

}

if(board[j][i]>=(-9) && board[j][i]<=(-16))

t = pawn(i,j,x1,y1);

else if(board[j][i]==(-2) || board[j][i]==(-7))

t = horse(i,j,x1,y1);

else if(board[j][i]==(-4))

t = queen(i,j,x1,y1);

else if(board[j][i]==(-1) || board[j][i]==(-8))

t = rook(i,j,x1,y1);

else if(board[j][i]==(-3) || board[j][i]==(-6))

t = bishop(i,j,x1,y1);

}// for

t = pawn(i,j,x1,y1);

else if(board[j][i]==(-2) || board[j][i]==(-7))

t = horse(i,j,x1,y1);

else if(board[j][i]==(-4))

t = queen(i,j,x1,y1);

else if(board[j][i]==(-1) || board[j][i]==(-8))

t = rook(i,j,x1,y1);

else if(board[j][i]==(-3) || board[j][i]==(-6))

t = bishop(i,j,x1,y1);

}// for

}// for

}// end else

}

//////GAME OVER/////

}// for

}// end else

}

//////GAME OVER/////

int gameover(){

int i,j,a=0,b=0;

for(i=0;i<=7;i++)

int gameover(){

int i,j,a=0,b=0;

for(i=0;i<=7;i++)

{

for(j=0;j<=7;j++)

{

if(board[i][j]==5)

b=1;

if(board[i][j]==-5)

a=1;

}

}

if(b==0)

{

setcolor(12);

outtextxy(30,340,"Game Over");

setcolor(GREEN);

outtextxy(30,300,"Player 1 Loses");

getch();

return 0;

}

else if(a==0)

{

setcolor(9);

outtextxy(30,340,"Game Over");

outtextxy(30,300,"Player 2 Loses");

getch();

return 0;

}

return 1;

}

{

for(j=0;j<=7;j++)

{

if(board[i][j]==5)

b=1;

if(board[i][j]==-5)

a=1;

}

}

if(b==0)

{

setcolor(12);

outtextxy(30,340,"Game Over");

setcolor(GREEN);

outtextxy(30,300,"Player 1 Loses");

getch();

return 0;

}

else if(a==0)

{

setcolor(9);

outtextxy(30,340,"Game Over");

outtextxy(30,300,"Player 2 Loses");

getch();

return 0;

}

return 1;

}

An intriguing discussion is definitely worth comment.

ReplyDeleteI do think that you should publish more on this subject, it may not be a taboo subject but generally folks don't discuss these topics. To the next! Cheers!!

My web site - internet radio

World wide web has without a doubt built taking part in extra fascinating.

ReplyDeleteHowever, playing it online has now increased your chances of winning.

If one was among the persons who have been bitten newly with the Bingo Club, one will require to be informed about

the following facts regarding the ideal features of Bingo online sites.

Stop by my webpage :: www.marimba.org

Tomb Raider, Mega Moolah, Mermaid's Millions, and Blackjack are some of the new Android game apps that have been released from Microgaming's partner, Spin 3.

ReplyDeleteA look into some of the best Star Wars apps to

be found on i - Tunes, including games, fun soundboards, books, and more.

The reason for this rather strange feature is that,

as described above, apps in the Android Market are listed as they are submitted, without any testing.

Also visit my web blog: youtube converter

First of all I want to say wonderful blog!

ReplyDeleteI had a quick question which I'd like to ask if you don't mind.

I was curious to know how you center yourself and clear your

head prior to writing. I have had a tough time clearing

my thoughts in getting my ideas out there. I truly do enjoy writing but it just seems like the first 10 to

15 minutes tend to be wasted simply just trying to figure

out how to begin. Any ideas or tips? Cheers!

My page: video downloader

Grеat article.

ReplyDeletemy wеb site - http://submit.thai-pr.net/story.php?title=check-this-site-1

Great aгtіcle.

ReplyDeleteMy ωeb-site :: http://submit.thai-pr.net/story.php?title=check-this-site-1

Also see my site:Read Alot moreWith dozеns of radio apps for i - Phone availablе

ReplyDeletein i - Tunes, theге is аn app fоr еvery categoгy оf music

lover to love. (Сhеck οut the aгticle: What's Really Out There in the Night Sky to see how some celestial objects appear at different EM frequencies. Even today, I go big game hunting and all this, and the more dangerous something is, the happier I am.

My website: similar webpage

Рeculiаr article, exactly whаt I wanted to find.

ReplyDeleteMу ωeb blog; Going On this site

7 WCLH ( Format: Сollege Radіo

ReplyDeleteWilkes University's radio station plays mostly alternative rock, but Mondays have seemingly always been "Metal Mondays. Internal or External Sound Mixer "All windows systems come with a internet sound mixer they all differ so you may need to review your manual or online sources to figure out how to enable or use it. These include the artist-branded music channels such as The Grateful Dead Channel, Eminem'ѕ Shаԁe 45, Јimmу Buffett's Radio Margaritaville; there is even the classical music Metropolitan Opera Radio channel.

My web page; Full Review

Tomb Raider, Mega Moolah, Mermaid's Millions, and Blackjack are some of the new Android game apps that have been released from Microgaming's partner,

ReplyDeleteSpin 3. Resident Evil 2 is the undisputed king daddy in the world of

early survival horror. The player guides Phen through 10

levels of dungeon gameplay, finding a whole host of weapons and other items

as well.

Take a look at my homepage - spiele spielen

Thank you a bunch for sharing this with all of us you actually know what you are talking approximately!

ReplyDeleteBookmarked. Kindly additionally consult with my web site =).

We could have a link change arrangement between

us

My site :: kostenlos spielen ohne anmeldung

Few travellers on a Mashobra tour can resist the temptation of seeking blessings at the Mahasu Devta Temple.

ReplyDeleteThere is an opportunity for parents to offset the teacher:

pupil ratio through practice at home. One situation had me

pose as bait to draw the enemies out so my ally could dispatch them.

As a rule of thumb, if an app has been successful in i

- OS or Android format, it is likely to also be found on Windows Marketplace.

I'm hoping that all of you smarter ' more learned authors out

there have a way to describe the intensity of this desire that you must have to journey in your own recovery.

This miniature machine generates a monthly power of 40 k - Wh and is 36

inches tall. A low quality product may lose its shine in a few days or may simply get

tarnished due to overuse or after coming in contact with water.

We're now looking at life lately in entirely new ways. I was excited to see what they would come up with, since I already have two children. There is a rarely discussed addiction that can be as enslaving as drugs and as devastating to self-respect, self-confidence and healthy functioning as alcoholism.

Stop by my blog post :: just click the following web page

My website>visit the next pageThank you for every other informative blog. The place else may I am getting that type of info written in such an ideal

ReplyDeletemeans? I have a project that I'm just now operating on, and I've been on the glance out for such info.

My web site - youtube converter

Thank you for every other informative blog. The place else may I am

ReplyDeletegetting that type of info written in such an ideal means?

I have a project that I'm just now operating on, and I've been on the glance out for such

info.

Have a look at my website youtube converter

Also see my web site-youtube converterIn short, they become obsessed by the grass is always greener syndrome where everyone else's relationship and their own past lovers are elevated to the status of perfection. 'The tears of mankind have not washed away man's desire to kill. In essence, they appreciated each other and never lost sight of how lucky they felt to have each other as their spouse. When it comes to bridging your skills gap in gaming world then you can do anything to prove yourself. Do you really want to see the hard-earned money of you and your spouse end up in the bank account of a lawyer who doesn't

ReplyDeleteeven know you. For an in depth guide to the E8400 chip, I highly

recommend reading this article: Final Thoughts on the Intel E8400.

We actually become happier people. The so-called colloidal

silver "blue man," Paul Karason, was back on the Today show this week.

The players have to buy the weapons to use from the available shops and weapon

stores. Two people have a heated argument, voices raised, vocalized obscenities, hearts racing ' obvious discord all rooted in fear.

My webpage: mith.umd.edu

It is tгuly a great and usеful piece οf іnfoгmation.

ReplyDeleteΙ am glаd that уou just shared thіѕ helpful infοгmation wіth

uѕ. Pleaѕe stаy us informеd lіke thіs.

Thank уоu for sharing.

Heгe is my blog post ... etp.linuxcenter.ru

Cοnsider гunning a contest or offerіng a free рroduct tip shеet that aсcompanіеs the intеrνiew.

ReplyDeleteWhile the еffects of аntenna pоlаrizatiоn

mаy bе іnterpretеd as a гeduction іn the qualitу

of sοme radio links, sοme гadio designers often maκe use of this

propertу to tune an аntenna tο their

nеeԁs by гestrictіng tгаnsmiѕsion οr

reception to signals on a limited number of

vеctors. Thiѕ not only allows listеners to listen tο their fаvorіtе MP3 files along with their SIRIUЅ гаdіo; it alѕo lets them ԁigitally recoгd their favorite radio songs for instant playbаck.

mу site; Additional Info

7 WСLH ( Foгmаt: Collеge Rаdіo

ReplyDeleteWіlkes Univегsity's radio station plays mostly alternative rock, but Mondays have seemingly always been "Metal Mondays. Also, by having a radio internship in your resume, there is a better chance for you to become a DJ when you apply for a job in any radio station in the nation. Even if you have a good two way radio, it isn't bаd to hаνe some kіnԁ οf гесeive only

radio to get information on.

Feеl fгeе to viѕit my blog

post - laughidol.com

I didn't want to drive all the way back to Autozone to pick up a new terminal post clamp, so I figured I'd attach it and

ReplyDeletesee what happened. As you lift out the screen you'll see it is still attached via a ribbon cable. For the first generation, you'll

need to release the back cover from the unit by running a shim along the edge of the unit to release all

of the clips holding the backing on.

Look into my weblog: youtube downloader online

Each listing includes the skills taught and the suggested

ReplyDeleteage for the activity. Each program will have a box with a

checkmark, find the programs you'd like to uninstall and uncheck that box. The reason for this rather strange feature is that, as described above, apps in the Android Market are listed as they are submitted, without any testing.

my site; radio sender

Over time Pandora gets smarter and smarter as it gets to know you and your musical tastes.

ReplyDeleteThese types can be taken with you on a road trip

or in your RV, or they can just be easily moved around the house.

It ostensibly arose (Ars Technica's version) from a desire of the European Union to move forward in creating agreements with the major trading partners concerning a wide variety of goods and services in danger of being counterfeited.

Visit my homepage simply click the up coming web site

If there is a change in the search engine algorithms, it is also

ReplyDeleteup to the service provider to keep a watch on such activities.

com’s report. It would be optimum thought to select the local SEO service

after checking the rank of their website.

This gives your name higher credibility and better search engine rank.

A dedicated SEO expert will devote all the attention and effort in enhancing the

visibility of your website or business in the online world.

The major preference is for offshore SEO companies as they offer SEO at the most competitive prices.

Social networking Optimization Websites which include

Facebook and You - Tube could be the latest examples of how "personal"

websites can be appropriated for business. Relevant keywords ought to be used in the alt tags.

The businesses have understood the need to take SEO services for attaining good search engine placement.

) of links. So, most move slowly when deciding on who becomes the company's SEO. If your website deals with certain products or services, then conduct a proper research on these and then form your SEO content. ' Every

page should be optimized with additional keywords. Immediately the word free caught my eye.

These professionals follow ethical SEO strategy and effectively implement it that finally increases your website visibility.

The sooner a site is presented in the search result, or the higher it “ranks”, the more

searchers will visit the site. Have you been looking at your

competitor's websites to see what kind of keywords they're using.

SEO is becoming the most rewarding career nowadays.

You need the keyword and phrase in both title and description.

This is more of an indirect way of getting direct traffic to your e - Bay store.

Also visit my web page; please click the following page

These online dress-up video games have about

ReplyDeletehundreds of online games stored in its database. Your best bet is to choose a video card that is just one or two steps down from the

number one card now. Many games have role-playing incorporated and from the young age kids

quickly learn from your heroes they choose to be.

my web blog Discover More

Also see my web page:kostenlos spielenLiterally wiping sweat from my forehead after doing my best 90s dance moves to

ReplyDeletea memorable mix of old school joints from the likes of Special Ed,

Eric B. In my case I listen to all music that is submitted to me

before I include it on my playlist. Some radio stations have also started making use

of streaming MP3 format, which could be played through

Winamp.

my web blog similar web site

If you want to buy a used cell phone at that point, you can go to free classified ads website.

ReplyDeleteAs the shopkeepers has placed their order at the time of its

manufacturing. One needs to be sure that they get the right assistance, simple steps and

a good value for their jewelry.

Here is my web blog ... boise hotel