Está en la página 1de 19

int fichax=12;// SIRVE PARA DETERMINAR CUANDO SE GANA O PIERDE UN JUEGO

int terminar=1;
int contador_fichas_x= 7;//CONTADOR POR DEFAULT SI NO SE CAMBIA OPCIONE EN MO
DO ESPECIAL
int contador_fichas_o= 7;
int x,y ;// PARA MOVER FICHAS
void presentacion()
{
for(int i=0;i<8;i++)
{
printf("\n");
contador--;
printf("\t\t\t ") ;
for(int j=0;j<8;j++)
{
contador++;
if(contador%2!=0)
{
printf("%c%c%c%c", blanco, blanco, blanco,blanco);
}
if(contador%2==0)
{
printf("%c%c%c%c", negro, negro, negro,negro);
}
}
}
}//FIN VOID PRESENTACION
void rellenar()//***************************************************************
**********************************************************
{
for(i=0;i<T;i++)
{
for(j=0;j<T;j++)
{
if(i<=2&&((j+i)%2==0))
{
tablero[i][j] = 'O' ;
} // ESTE IF PONE FICHAS CONTRARIAS CUANDO ARREGLO VALGA
0
else if (i>=5&&((j+i)%2==0) )
{
tablero[i][j] = 'X' ;
}//
else
{
tablero[i][j] = ' ' ;
}
}/*FIN FOR J */ //SALTO DE LINEA
}//FIN FOR I
}// FIN DEL VOID RELLENAR E IMPRIMIR
void mover1()//*****************************************************************
********************************
{
do
{
do
{
do
{
do
{
printf("COMIENZA TURNO DE JUGADOR 2 FICHAS O. \n")
;
printf("INGRESE CORDENADA VERTICAL. \n");
scanf("%i", &x);
printf("INGRESE COORDENADA HORIZONTAL \n");
scanf("%i", &y);
if (tablero[x][y]!='O'&&tablero[x][y]!='C')
{
printf("ERROR, VUELVA A TIRAR NO HAY FICHA E
N LA CASILLA int x - inty. \n");
}
}
while (tablero[x][y]!='O'&&tablero[x][y]!='C');//VALIDAC
ION PARA EL TIRO DE MOVIMIENTO
system("CLS");
do
{
if (tablero[x][y] == 'O')
{
printf("SELECCIONE LA NUEVA POSICION DE LA F
ICHA [1]IZQUIERDA-ABAJO [2] DERECHA-ABAJO. \n");
scanf("%i",&direccion) ;
error=0;
if(direccion>2||direccion<1)
{
printf("ERROR, SELECCIONA UNA OPCION V
ALIDA EN DIRECCION. \n");
}
if((y==0&&direccion==1)||(y==7&&direccion==2
))
{
printf("ERROR, LA PIEZA SALE DEL AREA
DE JUEGO. \n");
}
}//FIN IF DE MOVIMIENTO
if (tablero[x][y]=='C')
{
printf("SELECCIONE [1]IZQ-ABAJO [2]DER-ABAJO
[3]IZQ-ARRIBA [4]DER-ARRIBA. \n");
scanf("%i", &direccion) ;
error=0;
if(direccion>4||direccion<1)
{
printf("ERROR, SELECCIONA UNA OPCION V
ALIDA EN DIRECCION. \n");
}
if((y==7&&direccion==2)||(y==0&&direccion==1
)||(y==7&&direccion==4)||(y==0&&direccion==3)||(x==0&&direccion==4)||(x==0&&dire
ccion==3)||(x==7&&direccion==1)||(x==7&&direccion==2))
{
printf("ERROR, LO SENTIMOS NO PUEDES S
ALIRTE DEL TABLERO. \n");
}
}//FIN IF DE MOVIMIENTO
}
while (direccion>4||direccion<1);
}
while ((y==7&&direccion==2)||(y==0&&direccion==1)||(y==7&&dire
ccion==4)||(y==0&&direccion==3)||(x==0&&direccion==4)||(x==0&&direccion==3)||(x=
=7&&direccion==1)||(x==7&&direccion==2));
if (direccion == 1 &&( tablero[x+1][y-1]== 'O'||tablero[x+1][y
-1]== 'C') )
{
printf("ERROR, LA CASILLA YA ESTA OCUPADA POR UNA FICHA
AMIGA. \n");
}
if (direccion == 2 && (tablero[x+1][y+1]== 'O' || tablero[x+1]
[y+1]== 'C') )
{
printf("ERROR, LA CASILLA YA ESTA OCUPADA POR UNA FICHA
AMIGA. \n");
}
if (direccion == 3 && (tablero[x-1][y-1]== 'O' || tablero[x-1]
[y-1]== 'C') )
{
printf("ERROR, LA CASILLA YA ESTA OCUPADA POR UNA FICHA
AMIGA. \n");
}
if (direccion == 4 && (tablero[x-1][y+1]== 'O' || tablero[x-1]
[y+1]== 'C') )
{
printf("ERROR, LA CASILLA YA ESTA OCUPADA POR UNA FICHA
AMIGA. \n");
}
}
while((direccion == 1 &&( tablero[x+1][y-1]== 'O'||tablero[x+1][y-1]
== 'C') )||(direccion == 2 && (tablero[x+1][y+1]== 'O' || tablero[x+1][y+1]== 'C
') )|| (direccion == 3 && (tablero[x-1][y-1]== 'O' || tablero[x-1][y-1]== 'C') )
||(direccion == 4 && (tablero[x-1][y+1]== 'O' || tablero[x-1][y+1]== 'C') ));//V
ALIDACION PARA CASILLA OCUPADA POR UNA AMIGA
if (direccion==1 &&( tablero[x+1][y-1] == 'X' || tablero[x+1][y-1] =
= 'D') )
{
if(y==1)
{
printf("ERROR, TE SALES DEL TABLERO(AREA DE JUEGO). \n")
;
error=1;
}
if(x==6)
{
printf("ERROR TE SALES DEL TABLERO. \n");
error=1;
}
if(tablero[x+2][y-2] == 'X')
{
printf("ERROR NO SE PUEDE COMER UNA FICHA YA QUE LA POSI
CION ESTA OCUPADA int x+2 - int y-2. \n");
error=1;
}
if(tablero[x+2][y-2] == 'O')
{
printf("ERROR NO SE PUEDE COMER UNA FICHA YA QUE LA POSI
CION ESTA OCUPADA int x+2 - int y-2. \n");
error=1;
}
if(tablero[x+2][y-2] == 'C')
{
printf("ERROR NO SE PUEDE COMER UNA FICHA YA QUE LA POSI
CION ESTA OCUPADA int x+2 - int y-2. \n");
error=1;
}
if(tablero[x+2][y-2] == 'D')
{
printf("ERROR NO SE PUEDE COMER UNA FICHA YA QUE LA POSI
CION ESTA OCUPADA int x+2 - int y-2. \n");
error=1;
}
}
if (direccion==2 && (tablero[x+1][y+1] == 'X'||tablero[x+1][y+1] ==
'D'))
{
if(y==6)
{
printf("ERROR TE SALES DEL TABLERO. \n");
error=1;
}
if(x==6)
{
printf("ERROR TE SALES DEL TABLERO. \n");
error=1;
}
if(tablero[x+2][y+2] == 'X')
{
printf("NO SE PUEDE COMER LA FICHA YA QUE HAY OTRA FICHA
EN LA CASILLA int x+2 - int y+2. \n");
error=1;
}
if( tablero[x+2][y+2] == 'O')
{
printf("NO SE PUEDE COMER LA FICHA YA QUE HAY OTRA FICHA
EN LA CASILLA int x+2 - int y+2. \n");
error=1;
}
if( tablero[x+2][y+2] == 'C')
{
printf("NO SE PUEDE COMER LA FICHA YA QUE HAY OTRA FICHA
EN LA CASILLA int x+2 - int y+2. \n");
error=1;
}
if( tablero[x+2][y+2] == 'D')
{
printf("NO SE PUEDE COMER LA FICHA YA QUE HAY OTRA FICHA
EN LA CASILLA int x+2 - int y+2. \n");
error=1;
}
}
if (direccion==3 && (tablero[x-1][y-1] == 'X'||tablero[x-1][y-1] ==
'D'))
{
if(y==1)
{
printf("ERROR TE SALES DEL TABLERO. \n");
error=1;
}
if(x==1)
{
printf("ERROR TE SALES DEL TABLERO. \n");
error=1;
}
if(tablero[x-2][y-2] == 'X')
{
printf("NO SE PUEDE COMER LA FICHA YA QUE HAY OTRA FICHA
EN LA CASILLA int x+2 - int y+2. \n");
error=1;
}
if( tablero[x-2][y-2] == 'O')
{
printf("NO SE PUEDE COMER LA FICHA YA QUE HAY OTRA FICHA
EN LA CASILLA int x+2 - int y+2. \n");
error=1;
}
if( tablero[x-2][y-2] == 'C')
{
printf("NO SE PUEDE COMER LA FICHA YA QUE HAY OTRA FICHA
EN LA CASILLA int x+2 - int y+2. \n");
error=1;
}
if( tablero[x-2][y-2] == 'D')
{
printf("NO SE PUEDE COMER LA FICHA YA QUE HAY OTRA FICHA
EN LA CASILLA int x+2 - int y+2. \n");
error=1;
}
}
if (direccion==4 && (tablero[x-1][y+1] == 'X'||tablero[x-1][y+1] ==
'D'))
{
if(y==6)
{
printf("ERROR TE SALES DEL TABLERO. \n");
error=1;
}
if(x==1)
{
printf("ERROR TE SALES DEL TABLERO. \n");
error=1;
}
if(tablero[x-2][y+2] == 'X')
{
printf("NO SE PUEDE COMER LA FICHA YA QUE HAY OTRA FICHA
EN LA CASILLA int x+2- int y+2. \n");
error=1;
}
if( tablero[x-2][y+2] == 'O')
{
printf("NO SE PUEDE COMER LA FICHA YA QUE HAY OTRA FICHA
EN LA CASILLA int x+2- int y+2. \n");
error=1;
}
if( tablero[x-2][y+2] == 'D')
{
printf("NO SE PUEDE COMER LA FICHA YA QUE HAY OTRA FICHA
EN LA CASILLA int x+2- int y+2. \n");
error=1;
}
if( tablero[x-2][y+2] == 'C')
{
printf("NO SE PUEDE COMER LA FICHA YA QUE HAY OTRA FICHA
EN LA CASILLA int x+2- int y+2. \n");
error=1;
}
}
}
while(error==1);
//VALIDACION DE MOVIMIENTO PARA ESPACION OCUPADOS
if (tablero[x][y]=='C' && direccion == 1 && tablero[x+1][y-1]== ' ' )
{
tablero[x][y]=' ' ;
tablero[x+1][y-1] = 'C' ;
}
else if (tablero[x][y]=='C' && direccion == 2 && tablero[x+1][y+1]== ' '
)
{
tablero[x][y]=' ' ;
tablero[x+1][y+1] = 'C' ;
}
else if (tablero[x][y]=='C' && direccion == 3 && tablero[x-1][y-1]== ' '
)
{
tablero[x][y]=' ' ;
tablero[x-1][y-1] = 'C' ;
}
else if (tablero[x][y]=='C' && direccion == 4 && tablero[x-1][y+1]== ' '
)
{
tablero[x][y]=' ' ;
tablero[x-1][y+1] = 'C' ;
}
else if(tablero[x][y]=='C' && direccion== 1 && (tablero [x+1][y-1] == 'X'|
|tablero [x+1][y-1] == 'D'))
{
tablero[x][y]=' ' ;
tablero[x+1][y-1]=' ' ;
tablero[x+2][y-2]= 'C' ;
printf("\a");
printf("HAS COMIDO A LA FICHA CONTRARIA 'X' EN LA CASILLA int x+1 -
int y-1. \n");
fichax=fichax-1;
contador_fichas_o= contador_fichas_o+3;
getche ();
}
else if(tablero[x][y]=='C' && direccion== 2 && (tablero [x+1][y+1] == 'X'|
|tablero [x+1][y+1] == 'D'))
{
tablero[x][y]=' ' ;
tablero[x+1][y+1]=' ' ;
tablero[x+2][y+2]= 'C' ;
printf("\a");
printf("HAS COMIDO A LA FICHA CONTRARIA 'X' EN LA CASILLA int x+1 -
int y+1. \n");
fichax=fichax-1;
contador_fichas_o= contador_fichas_o+3;
getche ();
}
else if(tablero[x][y]=='C' && direccion== 3 && (tablero [x-1][y-1] == 'X'|
|tablero [x-1][y-1] == 'D'))
{
tablero[x][y]=' ' ;
tablero[x-1][y-1]=' ' ;
tablero[x-2][y-2]= 'C' ;
printf("\a");
printf("HAS COMIDO A LA FICHA CONTRARIA 'X' EN LA CASILLA int x-1 -
int y-1. \n");
fichax=fichax-1;
contador_fichas_o= contador_fichas_o+3;
getche ();
}
else if(tablero[x][y]=='C' && direccion== 4 && (tablero [x-1][y+1] == 'X'|
|tablero [x-1][y+1] == 'D'))
{
tablero[x][y]=' ' ;
tablero[x-1][y+1]=' ' ;
tablero[x-2][y+2]= 'C' ;
printf("\a");
printf("HAS COMIDO A LA FICHA CONTRARIA 'X' EN LA CASILLA int x-1 -
int y+1. \n");
fichax=fichax-1;
contador_fichas_o= contador_fichas_o+3;
getche ();
}
else if (tablero[x][y]=='O' && direccion == 1 && tablero[x+1][y-1]== ' ' )
{
tablero[x][y]=' ' ;
tablero[x+1][y-1] = 'O' ;
}
if (tablero[x][y]=='O' && direccion == 2 && tablero[x+1][y+1]== ' ' )
{
tablero[x][y]=' ' ;
tablero[x+1][y+1] = 'O' ;
}
else if(tablero[x][y]=='O'&& direccion== 1 && (tablero [x+1][y-1] == 'X'||
tablero [x+1][y-1] == 'D'))
{
tablero[x][y]=' ' ;
tablero [x+1][y-1]= ' ' ;
tablero[x+2][y-2]= 'O' ;
printf("\a");
printf("HAS COMIDO A LA FICHA CONTRARIA 'X' EN LA CASILLA int x+1 -
int y-1. \n");
fichax=fichax-1;
contador_fichas_o= contador_fichas_o+3;
getche ();
}
else if(tablero[x][y]=='O'&& direccion== 2 && ( tablero [x+1][y+1] == 'X'|
| tablero [x+1][y+1] == 'D'))
{
tablero[x][y]=' ' ;
tablero[x+1][y+1]=' ' ;
tablero[x+2][y+2]= 'O' ;
printf("\a");
printf("HAS COMIDO A LA FICHA CONTRARIA 'X' EN LA CASILLA int x+1 -
int y+1. \n");
fichax=fichax-1;
contador_fichas_o= contador_fichas_o+3;
getche ();
}
turno = 1 ;
}// FIN VOID MOVER *******************************************************
**********************************************************
void mover2()
{
do
{
do
{
do
{
do
{
printf("TURNO JUGADOR 1 FICHAS X. \n");
if(turno==1 )
{
printf("INGRESE CORDENADA VERTICAL. \n");
scanf("%i", &x);
printf("INGRESE COORDENADA HORIZONTAL. \n");
scanf("%i", &y);
}//FIN IF TURNO =1
if(tablero[x][y]!='X'&&tablero[x][y]!='D')
{
printf("ERROR VUELVA A TIRAR NO HAY FICHA EN
LA CASILLA int x - int y. \n");
}
}
while (tablero[x][y]!='X'&&tablero[x][y]!='D');//VALIDAC
ION PARA EL TIRO DE MOVIMIENTO
do
{
if (tablero[x][y] == 'X')
{
printf("SELECCIONE LA NUEVA POSICION DE LA F
ICHA [1]IZQUIERDA-ARRIBA [2] DERECHA-ARRIBA. \n");
scanf("%i", &direccion);
error=0;
if(direccion>2||direccion<1)
{
printf("ERROR ESCOGA UNA OPCION VALIDA
EN DIRECCION. \n");
}
if((y==7&&direccion==2)||(y==0&&direccion==1
))
{
printf("ERROR NO PUEDES SALIRTE DEL TA
BLERO. \n");
}
}//FIN IF DE MOVIMIENTO
if (tablero[x][y]=='D')
{
printf("SELECCIONE [1]IZQ-ARRIBA [2]DER-ARRI
BA [3]IZQ-ABAJO [4] DER-ABAJO. \n");
scanf("%i", &direccion);
error=0;
if(direccion>4||direccion<1)
{
printf("ERROR ESCOGA UNA OPCION VALIDA
EN DIRECCION. \n");
}
if((y==7&&direccion==2)||(y==0&&direccion==1
)||(y==7&&direccion==4)||(y==0&&direccion==3)||(x==0&&direccion==1)||(x==0&&dire
ccion==2)||(x==7&&direccion==3)||(x==7&&direccion==4))
{
printf("ERROR NO PUEDES SALIRTE DEL TA
BLERO. \n");
}
}// fin if
}
while (direccion>4||direccion<1);//VALIDACION DE MOVIMIE
TNO PARA DIRECCION
}
while((y==7&&direccion==2)||(y==0&&direccion==1)||(y==7&&direc
cion==4)||(y==0&&direccion==3)||(x==0&&direccion==1)||(x==0&&direccion==2)||(x==
7&&direccion==3)||(x==7&&direccion==4));//Vlidacion para no salirte del tablero
system("CLS");
if (direccion == 1 && ( tablero[x-1][y-1]== 'X'||tablero[x-1][
y-1]== 'D') )
{
printf("ERROR LA CASILLA ESTA OCUPADA POR UNA FICHA AMIG
A. \n");
}
else if (direccion == 2 && (tablero[x-1][y+1]== 'X'||tablero[x
-1][y+1]== 'D') )
{
printf("ERROR LA CASILLA ESTA OCUPADA POR UNA FICHA AMIG
A. \n");
}
else if (direccion == 3 && (tablero[x+1][y-1]== 'X'||tablero[x
+1][y-1]== 'D') )
{
printf("ERROR LA CASILLA ESTA OCUPADA POR UNA FICHA AMIG
A. \n");
}
else if (direccion == 4 && (tablero[x+1][y+1]== 'X'||tablero[x
+1][y+1]== 'D') )
{
printf("ERROR LA CASILLA ESTA OCUPADA POR UNA FICHA AMIG
A. \n");
}
}
while((direccion==1&&(tablero[x-1][y-1]== 'X'||tablero[x-1][y-1]== '
D'))||(direccion==2&&(tablero[x-1][y+1]== 'X'||tablero[x-1][y+1]== 'D') )||(dire
ccion == 3 && (tablero[x+1][y-1]== 'X'||tablero[x-1][y+1]== 'D') )||(direccion =
= 4 && (tablero[x+1][y+1]== 'X'||tablero[x+1][y+1]== 'D') ));//VALIDACION DE MOV
IMIENTO PARA ESPACION OCUPADO POR
//CASILLA AMIGA
if (direccion==1 && (tablero[x-1][y-1] == 'O'||tablero[x-1][y-1] ==
'C') )
{
if(y==1)
{
printf("ERROR TE SALES DEL TABLERO. \n");
error=1;
}
if(x==1)
{
printf("ERROR TE SALES DEL TABLERO. \n");
error=1;
}
if(tablero[x-2][y-2] == 'X')
{
printf("NO SE PUEDE COMER LA FICHA YA QUE HAY OTRA FICHA
EN LA CASILLA int x-2 - int y-2. \n");
error=1;
}
if(tablero[x-2][y-2] == 'O' )
{
printf("NO SE PUEDE COMER LA FICHA YA QUE HAY OTRA FICHA
EN LA CASILLA int x-2 - int y-2. \n");
error=1;
}
if(tablero[x-2][y-2] == 'D' )
{
printf("NO SE PUEDE COMER LA FICHA YA QUE HAY OTRA FICHA
EN LA CASILLA int x-2 - int y-2. \n");
error=1;}
if(tablero[x-2][y-2] == 'C' )
{
printf("NO SE PUEDE COMER LA FICHA YA QUE HAY OTRA FICHA
EN LA CASILLA int x-2 - int y-2. \n");
error=1;
}
}
else if (direccion==2 && (tablero[x-1][y+1] == 'O'||tablero[x-1][y+1
] == 'C'))
{
if(y==6)
{
printf("ERROR TE SALES DEL TABLERO. \n");
error=1;
}
if(x==1)
{
printf("ERROR TE SALES DEL TABLERO. \n");
error=1;
}
if(tablero[x-2][y+2] == 'X')
{
printf("ERROR NO SE PUEDE COMER UNA FICHA YA QUE LA POSI
CION ESTA OCUPADA. \n");
error=1;
}
if (tablero[x-2][y+2] == 'O')
{
printf("ERROR NO SE PUEDE COMER UNA FICHA YA QUE LA POSI
CION ESTA OCUPADA. \n");
error=1;
}
if (tablero[x-2][y+2] == 'D')
{
printf("ERROR NO SE PUEDE COMER UNA FICHA YA QUE LA POSI
CION ESTA OCUPADA. \n");
error=1;
}
if (tablero[x-2][y+2] == 'C')
{
printf("ERROR NO SE PUEDE COMER UNA FICHA YA QUE LA POSI
CION ESTA OCUPADA. \n");
error=1;
}
}
else if (direccion==3 && (tablero[x+1][y-1] == 'O'||tablero[x+1][y-1
] == 'C'))
{
if(y==1)
{
printf("ERROR TE SALES DEL TABLERO. \n");
if(y==1)
{
printf("ERROR TE SALES DEL TABLERO. \n");
error=1;
}
error=1;
}
if(x==6)
{
printf("ERROR TE SALES DEL TABLERO. \n");
error=1;
}
if(tablero[x+2][y-2] == 'X')
{
printf("ERROR NO SE PUEDE COMER UNA FICHA YA QUE LA POSI
CION ESTA OCUPADA. \n");
error=1;
}
if (tablero[x+2][y-2] == 'O')
{
printf("ERROR NO SE PUEDE COMER UNA FICHA YA QUE LA POSI
CION ESTA OCUPADA. \n");
error=1;
}
if (tablero[x-2][y+2] == 'C')
{
printf("ERROR NO SE PUEDE COMER UNA FICHA YA QUE LA POSI
CION ESTA OCUPADA. \n");
error=1;
}
if (tablero[x-2][y+2] == 'D')
{
printf("ERROR NO SE PUEDE COMER UNA FICHA YA QUE LA POSI
CION ESTA OCUPADA. \n");
error=1;
}
}
else if (direccion==4 && (tablero[x+1][y+1] == 'O'||tablero[x+1][y+1
] == 'C'))
{
if(y==6)
{
printf("ERROR TE SALES DEL TABLERO. \n");
error=1;
}
if(x==6)
{
printf("ERROR TE SALES DEL TABLERO. \n");
error=1;
}
if(tablero[x+2][y+2] == 'X')
{
printf("ERROR NO SE PUEDE COMER UNA FICHA YA QUE LA POSI
CION ESTA OCUPADA. \n");
error=1;
}
if (tablero[x+2][y+2] == 'O')
{
printf("ERROR NO SE PUEDE COMER UNA FICHA YA QUE LA POSI
CION ESTA OCUPADA. \n");
error=1;
}
if (tablero[x+2][y+2] == 'D')
{
printf("ERROR NO SE PUEDE COMER UNA FICHA YA QUE LA POSI
CION ESTA OCUPADA. \n");
error=1;
}
if (tablero[x+2][y+2] == 'C')
{
printf("ERROR NO SE PUEDE COMER UNA FICHA YA QUE LA POSI
CION ESTA OCUPADA. \n");
error=1;
}
}
}
while(error==1);
//VALIDACION DE MOVIMIENTO PARA ESPACION OCUPADOS CUANDO SE VA A COMER
if(tablero[x][y]== 'D' && direccion==1 && tablero[x-1][y-1]== ' ' )
{
tablero[x][y]= ' ';
tablero[x-1][y-1]= 'D';
}
else if (tablero[x][y]=='D'&& direccion == 2 && tablero[x-1][y+1]== ' ' )
{
tablero[x][y]=' ' ;
tablero[x-1][y+1] = 'D' ;
}
else if (tablero[x][y]=='D'&& direccion == 3 && tablero[x+1][y-1]== ' ' )
{
tablero[x][y]=' ' ;
tablero[x+1][y-1] = 'D' ;
}
else if (tablero[x][y]=='D'&& direccion == 4 && tablero[x+1][y+1]== ' ' )
{
tablero[x][y]=' ' ;
tablero[x+1][y+1] = 'D' ;
}
else if(tablero[x][y]=='D'&& direccion== 1 &&( tablero [x-1][y-1] == 'O' |
| tablero [x-1][y-1] == 'C'))
{
tablero[x][y]=' ' ;
tablero[x-1][y-1]=' ' ;
tablero[x-2][y-2]= 'D' ;
printf("\a");
printf("HAS COMIDO A LA FICHA CONTRARIA 'O' EN LA CASILLA x-1 - int
y-1. \n");
fichao=fichao-1;
contador_fichas_x= contador_fichas_x+3;
getche ();
}
else if(tablero[x][y]=='D'&& direccion==2 && (tablero [x-1][y+1] == 'O'||t
ablero [x-1][y+1] == 'C'))
{
tablero[x][y]=' ' ;
tablero[x-1][y+1]=' ' ;
tablero[x-2][y+2]= 'D' ;
printf("\a");
printf("HAS COMIDO A LA FICHA CONTRARIA 'O' EN LA CASILLA int x-1 -
int y+1. \n");
fichao=fichao-1;
contador_fichas_x= contador_fichas_x+3;
getche ();
}
else if(tablero[x][y]=='D'&& direccion== 3 && (tablero [x+1][y-1] == 'O'||
tablero [x+1][y-1] == 'C'))
{
tablero[x][y]=' ' ;
tablero[x+1][y-1]=' ' ;
tablero[x+2][y-2]= 'D' ;
printf("\a");
printf("HAS COMIDO A LA FICHA CONTRARIA 'O' EN LA CASILLA int x+1 -
int y-1. \n");
fichao=fichao-1;
contador_fichas_x= contador_fichas_x+3;
getche ();
}
else if(tablero[x][y]=='D'&& direccion== 4 && (tablero [x+1][y+1] == 'O'||
tablero [x+1][y-1] == 'C'))
{
tablero[x][y]=' ' ;
tablero[x+1][y+1]=' ' ;
tablero[x+2][y+2]= 'D' ;
printf("\a");
printf("HAS COMIDO A LA FICHA CONTRARIA 'O' EN LA CASILLA int x+1 -
int y+1. \n");
fichao=fichao-1;
contador_fichas_x= contador_fichas_x+3;
getche ();
}
else if(tablero[x][y]== 'X' && direccion== 1 && tablero [x-1][y-1] == ' ')
{
tablero[x][y]=' ' ;
tablero [x-1][y-1]= 'X' ;
}//FIN DE ELSE IF
else if(tablero[x][y]=='X'&& direccion== 1 && (tablero [x-1][y-1] == 'O'||
tablero [x-1][y-1] == 'C'))
{
tablero[x][y]=' ' ;
tablero[x-1][y-1]=' ' ;
tablero[x-2][y-2]= 'X' ;
printf("\a");
printf("HAS COMIDO A LA FICHA CONTRARIA 'O' EN LA CASILLA int x-1 -
int y-1. \n");
fichao=fichao-1;
contador_fichas_x= contador_fichas_x+3;
getche ();
}
else if(tablero[x][y]== 'X' && direccion== 2 && tablero [x-1][y+1] == ' ')
{
tablero[x][y]=' ' ;
tablero [x-1][y+1]= 'X' ;
}//FIN DE ELSE IF
else if(tablero[x][y]== 'X' && direccion== 2 && (tablero [x-1][y+1] == 'O'
||tablero [x-1][y+1] == 'C'))
{
tablero[x][y]=' ' ;
tablero [x-1][y+1]= ' ' ;
tablero[x-2][y+2]= 'X' ;
printf("\a");
printf("HAS COMIDO A LA FICHA CONTRARIA 'O' EN LA CASILLA int x-1 -
int y+1. \n");
fichao=fichao-1;
contador_fichas_x= contador_fichas_x+3;
getche();
}//FIN DE ELSE IF
turno = 0 ;
}//FIN VOI MOVER 2 *****************************************************
************************************************************+
void imprimir()
{
for(z=0;z<T;z++)
{//INICIO DEL FOR Z QUE SIRVE PARA INDICAR LAS CORDENADAS HORIZONTALES
cout<<z<<" ";
}//FIN DEL FOR Z ----------------------------***********************
************************
cout<<endl;//-------------------------------------------------************
********************************
for(i=0;i<T;i++)
{
printf("\t\t ");
cout<<i;//ESTA I SIRVE PARA INDICAR COORDENADAS VERTICALES *********
*******************************
for(j=0;j<T;j++)
{
if((tablero[i][j]=='X'||tablero[i][j]=='O'||tablero[i][j]=='C'
||tablero[i][j]=='D')&&((j+i)%2==0))
{
printf("%c%c%c%c%c", blanco, blanco, tablero[i][j], blan
co, blanco);
}
else if (tablero[i][j]==' ' && (j+i)%2!=0)
{
printf("%c%c%c%c%c", negro, negro, negro, negro, negro);
}
else if (tablero[i][j]==' ' &&(j+i)%2==0)
{
printf("%c%c%c%c%c", blanco, blanco, blanco, blanco, bla
nco);
}
}/*FIN FOR J */
cout<<endl; //SALTO DE LINEA
}//FIN FOR I
}// FIN VOID RE IMPRIMIR *************************************************
****************************************************************
int main( )
{
int seleccion ;//REPRESENTA LA SELECCION DEL MENU
system("color B");
printf("\n\n\n\n");
printf("\t ---------BIENVENIDO AL JUEGO DE DAMAS INGLESAS----------\n\
n\n");
printf("\n * * * * * * * * PRESIONA START(ENTER) * * * * *
* * *\n");
presentacion() ;
printf("\n\n\n\n");
printf("\t\t 2014 copyright \251AsA Todos los Derechos Reservados. \n\t He
cho por Misael Martinez Sanjuanero 1am2 y Rodrigo Lpoez 1am1.");
getche();
system ("cls");
do
{
system("color 7");
printf("\t*************BIENVENIDO AL JUEGO DE DAMAS EN C************
**\n\n\n");
printf("\t\t MODO NORMAL DE JUEGO 2-JUGADORES [1]. \n");
printf("\t\t LEER INSTRUCTIVO [2]. \n");
printf("\t\t SALIR [3]. \n");
scanf("%i", &seleccion);
system("CLS");
switch (seleccion)
{
case 1://*****************************************************
*****************************************************************************
{
printf("\t\t ");
system("color B") ;
rellenar();
imprimir();
do
{
for(i=0;i<T;i++)
{
for(j=0;j<T;j++)
{
if (tablero[i][j]=='D' && tablero
[i+2][j+2]==' ' && (tablero[i+1][j+1]=='O'||tablero[i+1][j+1]=='C') && j!= 6)
{
printf("TU OPONENTE TE OBLI
GO A COMER AUTOMATICAMENTE LA FICHA EN int i+1 - int j+1. \n");
tablero[i][j]=' ';
tablero[i+1][j+1]= ' ';
tablero[i+2][j+2]='D' ;
getche();
fichao=fichao-1;
turno=0;
}
else if (tablero[i][j]=='D' && ta
blero[i+2][j-2]==' ' && (tablero[i+1][j-1]=='O'||tablero[i+1][j-1]=='C') && j!=
1)
{
printf("TU OPONENTE TE OBLI
GO A COMER AUTOMATICAMENTE LA FICHA EN int i+1 - int j-1. \n");
tablero[i][j]=' ';
tablero[i+1][j-1]= ' ';
tablero[i+2][j-2]='D' ;
getche();
fichao=fichao-1;
turno=0;
}
else if (tablero[i][j]=='D' && ta
blero[i-2][j+2]==' ' && (tablero[i-1][j+1]=='O'||tablero[i-1][j+1]=='C') && j!=
6)
{
printf("TU OPONENTE TE OBLI
GO A COMER AUTOMATICAMENTE LA FICHA EN int i-1 - int j+1. \n");
tablero[i][j]=' ';
tablero[i-1][j+1]= ' ';
tablero[i-2][j+2]='D' ;
getche();
fichao=fichao-1;
turno=0;
}
else if(tablero[i][j]=='D'&& tabl
ero[i-2][j-2]==' ' && (tablero[i-1][j-1]=='O'||tablero[i-1][j-1]=='C') && j!= 1
)
{
printf("TU OPONENTE TE OBLI
GO A COMER AUTOMATICAMENTE LA FICHA EN int i-1 - int j-1. \n");
tablero[i][j]=' ';
tablero[i-1][j-1]= ' ';
tablero[i-2][j-2]='D' ;
getche();
fichao=fichao-1;
turno=0;
}
else if(tablero[i][j]=='X'&& tabl
ero[i-2][j-2]==' ' && (tablero[i-1][j-1]=='O'||tablero[i-1][j-1]=='C') && j!= 1
)
{
printf("TU OPONENTE TE OBLI
GO A COMER AUTOMATICAMENTE LA FICHA EN int i-1 - int j-1. \n");
tablero[i][j]=' ';
tablero[i-1][j-1]= ' ';
tablero[i-2][j-2]='X' ;
getche();
fichao=fichao-1;
turno=0;
}
else if (tablero[i][j]=='X' && ta
blero[i-2][j+2]==' ' && (tablero[i-1][j+1]=='O'||tablero[i-1][j+1]=='C') && j!=
6 )
{
printf("TU OPONENTE TE OBLI
GO A COMER AUTOMATICAMENTE LA FICHA EN int i-1 - j+1. \n");
tablero[i][j]=' ';
tablero[i-1][j+1]= ' ';
tablero[i-2][j+2]='X' ;
getche();
fichao=fichao-1;
turno=0;
}
}
}
if(turno==1)
{
mover2();
}
for (x=0;x<T;x++)// PARA IDENTIFICAR UNA DAMA
{
if(tablero[0][x]== 'X' )
{
tablero[0][x]='D';
printf("TU FICHA SE A CONVERTIDO
EN DAMA SE USARA LA LETRA -D- PARA REPRESENTARLA. \n");
getche();
}
}// FIN DE DAMAS
system("CLS");
printf("\t\t ");
imprimir() ;
if (fichao==0)
{
printf("JUEGO TERMINADO, JUGADOR UNO A
GANADO ESTA PARTIDA. \n");
terminar=2;
break;
}
for(i=0;i<T;i++)
{
for(j=0;j<T;j++)
{
if(tablero[i][j]=='C'&& tablero[i
+2][j+2]==' ' && (tablero[i+1 ][j+1]=='X'||tablero[i+1 ][j+1]=='D') && j!=1)
{
printf("SE COMIO AUTOMATICA
MENTE LA FICHA EN int i+1 - int j+1. \n");
tablero[i][j]=' ';
tablero[i+1][j+1]= ' ';
tablero[i+2][j+2]='C' ;
getche();
fichax=fichax-1;
turno=1;
}
if (tablero[i][j]=='C' && tablero
[i-2 ][j-2]==' ' && ( tablero[i-1][j-1]=='X'||tablero[i-1][j-1]=='D') && j!=1)
{
printf("SE COMIO AUTOMATICA
MENTE LA FICHA EN int i-1 - int j-1. \n");
tablero[i][j]=' ';
tablero[i-1][j-1]= ' ';
tablero[i-2][j-2]='C' ;
getche();
fichax=fichax-1;
turno=1;
}
else if (tablero[i][j]=='C' && ta
blero[i-2][j+2]==' ' && (tablero[i-1][j+1]=='X'||tablero[i-1][j+1]=='D') && j!=6
)
{
printf("SE COMIO AUTOMATICA
MENTE LA FICHA EN int i-1 - int j+1. \n");
tablero[i][j]=' ';
tablero[i-1][j+1]= ' ';
tablero[i-2][j+2]='C' ;
getche();
fichax=fichao-1;
turno=1;
}
else if (tablero[i][j]=='C' && ta
blero[i+2][j-2]==' ' && (tablero[i+1][j-1]=='X'||tablero[i+1][j-1]=='D') && j!=6
)
{
printf("SE COMIO AUTOMATICA
MENTE LA FICHA EN int i+1 - int j-1. \n");
tablero[i][j]=' ';
tablero[i+1][j-1]= ' ';
tablero[i+2][j-2]='C' ;
getche();
fichax=fichax-1;
turno=1;
}
else if(tablero[i][j]=='O'&& tabl
ero[i+2][j+2]==' ' &&( tablero[i+1][j+1]=='X'||tablero[i+1][j+1]=='D') && j!=6)
{
printf("SE COMIO AUTOMATICA
MENTE LA FICHA EN int i+1 - int j+1. \n");
tablero[i][j]=' ';
tablero[i+1][j+1]= ' ';
tablero[i+2][j+2]='O' ;
getche();
fichax=fichax-1;
turno=1;
}
else if (tablero[i][j]=='O' && ta
blero[i+2 ][j-2 ]==' ' && (tablero[i+1][j-1]=='X' ||tablero[i+1][j-1]=='D' ) &&
j!=1)
{
printf("SE COMIO AUTOMATICA
MENTE LA FICHA EN int i+1 - int j-1. \n");
tablero[i][j]=' ';
tablero[i+1][j-1]= ' ';
tablero[i+2][j-2]='O' ;
getche();
fichax=fichax-1;
turno=1;}
}
}
if(turno==0)
{
mover1();
}
for (x=0;x<T;x++)// PARA IDENTIFICAR UN
A DAMA
{
if(tablero[7][x]== 'O' )
{
tablero[7][x]='C';
printf("TU FICHA SE A CONVE
RTIDO EN DAMA SE USARA LA LETRA -C- PARA REPRESENTARLA. \n");
getche();
}
}// FIN DE DAMAS
system("CLS");
printf("\t\t ");
for (x=0;x<T;x++)// PARA IDENTIFICAR UN
A DAMA
{
if(tablero[7][x]== 'O' )
{
tablero[7][x]='C';
}
}// FIN DE DAMAS
imprimir() ;
if(fichax==0)
{
printf("JUEGO TERMINADO, JUGADOR
DOS A GANADO ESTA PARTIDA. \n");
terminar=2;
break;
}
}
while(terminar==1);
break;
}//COMENZAR JUEGO****************************
********************************************************************************
**************
case 2:
{
printf("\t********************MODO DE JUEGO N
ORMAL********************** ");
printf("\n");
printf("INSTRUCCIONES PARA JUGAR A DAMAS EN C
++ LA PARTIDA COMENZARA CON LAS FICHAS 'X'");
printf("PARA HACER UN MOVIMIENTO DEBE SELECCI
ONAR PRIMERO LA COORDENADA VERTICAL, Y ");
printf("DESPUES LA COORDENADA HORIZONTAL, CAS
O DE NO HABER FICHA SE TE VOLVERA A PEDIR");
printf("QUE VUELVAS A TIRAR PARA SELECCIONAR
EL MOVIMIENTO DE LA FICHA PERSIONA [1]");
printf("PARA MOVERLA DIAGONALMENTE IZQUIERDA
O [2] PARA DIAGONAL DERECHA");
printf("EL JUEGO TERMINA CUANDO YA NO HAIGA F
ICHAS CONTRARIAS QUE COMER.");
printf("\n");
getche();
system("CLS");
}
break;
}//FIN DE SWITCH
}
while (seleccion<=3&&seleccion>=1);
system("pause");
}

También podría gustarte