Tablero de parchis.
C/Visual C
Actualizado el 12 de Agosto del 2020 por Adelino (27 códigos) (Publicado el 3 de Agosto del 2020)
9.061 visualizaciones desde el 3 de Agosto del 2020
Dibujado en pantalla de graficos (Modo 13h).
#include<dos.h>
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
char A[][3][10]={
"0yxwvutsrq","7222222225","5311111111",
"Y0IJKLMNOP","1700050000","2433333333",
"XH0jklmnop","1000050000","1241111111",
"WGg0000000","1001111111","1210000003",
"VFf0100030","1001111111","1210000003",
"UEe0000000","1111166611","1210000003",
"TDd0000000","1001166611","1210000003",
"SCc0000000","1001166611","1210000003",
"RBb0200040","1001111111","1210000003",
"@Aa0000000","5001111111","1212222221"};
char Pieza[][6][13]={
"0000111100000","3222222222222","3222222222223","0000000000003","0000000000000","0000000000003",
"0011111111000","1322222222222","1332222222223","0000000000003","0000000000000","0000000000003",
"0111122211100","1133222222222","1113222222223","0000000000003","0000000000000","0000000000003",
"1111222221110","1111322222222","1111322222223","0000000000003","0000000000000","0000000000003",
"1112222222110","1111132222222","1111133222223","0000000000003","0000000000000","0000000000003",
"1112222222110","1111113322222","1111111322223","0000000000003","0000000000000","0000000000003",
"0111222221100","1111111132222","1111111133223","0000000000003","0000000000000","0000000000003",
"0011122211000","1111111113222","1111111111323","0000000000003","0000000000000","0000000000003",
"0000111100000","1111111111332","1111111111133","0000000000003","0000000000000","0000000000003",
"0000000000000","1111111111113","3333333333333","0000000000003","3333333333333","3333333333333"};
char far*Q[400],l[]={"865320864208620840804"};
char far*q=61106+(char far*)0xA0000000;
int C[20][20],D[2][20][20];
int J[400],K[225],I[2][80],i[2];
int L[6][6],M[4][9],m[6],z[20];
int P[25][10][13],p[10][13];
int B[]={30,43,9,12,2,28,29};
int G[]={0,2,3,4,1,5,6,7};
int H[][3]={1,2,5,3,2,5,3,4,5,1,4,5};
int Z[][2]={0,1,3,2};
int E,a,h,j,n,v,w,x,y;
void Celda(F,F1){
while(F1--)
K[n++]=J[a=h+F++]?J[a]:K[n-68];
}
Figura(char far*F,char F1,char F2){
for(v=i[F1];v--;*(F+I[F1][v])=F2);
}
int main(){
_AX=0x13;
geninterrupt(0x10);
srand(time(NULL));
for(y=6;y--;)
for(x=y+1;x--;L[y][x]=l[a++]-48);
for(y=10;y--;z[y]=1)
for(x=10;x--;)
for(n=3;n--;)
if(a=A[y][n][x]-48)
if(n>1) C[y+10][x+10]=a=4*a,
C[9-y][x+10]=a+1,
C[9-y][9-x]=a+2,
C[y+10][9-x]=a+3;
else D[n][y+10][x+10]=a,
D[n][9-x][y+10]=n?a=G[a]:a+100,
D[n][9-y][9-x]=n?a=G[a]:a+200,
D[n][x+10][9-y]=n?G[a]:a+300;
for(y=0;y<10;y++,h+=307)
for(x=0;x<13;p[y][x++]=h++)
for(n=4,v=6;v--;n+=4)
if(a=Pieza[y][v][x]-48)
if(v) P[n][y][x]=H[0][--a],
P[n+1][9-y][x]=H[1][a],
P[n+2][9-y][12-x]=H[2][a],
P[n+3][y][12-x]=H[3][a];
else while(a--) I[a][i[a]++]=320*y+x;
for(v=20;v--;q-=2940)
for(w=20;w--;){
Q[j]=q-=13;
if(h=C[v][w]) Q[j]+=320*z[v]+z[w];
n=D[1][v][w];
for(y=10;y--;)
for(x=13;x--;)
a=P[h][y][x],
*(q+p[y][x])=a<5?B[n<7?n:a]:8;
if(n==6) n=Z[z[v]][z[w]],
M[n][m[n]++]=j;
J[D[0][v][w]]=j++;
}
for(n=v=0;v<2;K[n++]=K[0],n-=v++)
for(K[0]=h=y=0;++y<5;h+=100)
Celda(16+33*v,17);
for(h=y=0;++y<5;h=100*y)
for(v=2;v--;h=400-100*G[5-y])
Celda(66-32*v,8);
for(h=y=0;++y<5;h+=100)
Celda(1,4);
h=1;
Inicio:
Figura(q=Q[K[h]],0,14);
for(h+=y=x=rand()%6+1;x--;)
Figura(Q[m[x]=M[0][L[y-1][x]]],1,0);
E=getch();
while(h>=n) if(getch()==27) return 0;
for(x=y;x--;)
Figura(Q[m[x]],1,29);
Figura(Q[K[h-y]],0,*q);
goto Inicio;
}
No hay comentarios