Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {
- **********************************************************************************************************************
- * Juego de Tateti V3.5 *
- * Desarrollado por Damián Cardona <[email protected]> y Sergio Milardovich <[email protected]> *
- * Nota: este programa usa caracteres de código ASCII extendidos, por lo que es posible que en algunas computadoras *
- * no se vea correctamente. Para más info vistar: http://es.wikipedia.org/wiki/ASCII_extendido *
- **********************************************************************************************************************
- }
- program tateti (input, output);
- uses
- Crt;
- type
- treg=record nom:string;
- pjug,pgan,pgcon:integer;
- est:boolean; end;
- tarchivo= file of treg;
- var
- N1,N2:string;
- u:real;
- rta:char;
- tat: array[1..3,1..3]of real;
- k1,k2,z,g,t,c,b,l,n,i,x,y,jug,j,f:integer;
- a:tarchivo;
- aux1, aux2:treg;
- procedure inicio;
- begin
- assign (a,'C:\Users\milardo\est.dat');
- {$I-}
- reset(a);
- if ioresult = 2
- then rewrite (a);
- {$I+};
- end;
- procedure busca(var aux1,aux2:treg; n1,n2:string;var k1,k2:integer);
- var
- z:integer;
- begin
- aux1.nom:='';aux2.nom:='';
- z:=0; k1:=0; k2:= 0;
- while (not eof(a)) and ((aux1.nom <> n1) or (aux2.nom <> n2)) do
- begin
- if n1<>aux1.nom
- then
- begin
- seek (a,z);
- read(a,aux1);
- if aux1.nom=n1
- then k1:=filepos(a)-1;
- end;
- if n2<>aux2.nom
- then
- begin
- seek (a,z);
- read (a,aux2);
- if aux2.nom=n2
- then k2:=filepos(a)-1
- end;
- z:=z+1;
- end;
- if k1=0
- then begin
- aux1.nom:=n1;
- aux1.pjug:=0;
- aux1.pgan:=0;
- aux1.est:=false;
- seek(a,filesize(a));
- write(a,aux1)
- end;
- if k2=0
- then begin
- aux2.nom:=n2;
- aux2.pjug:=0;
- aux2.pgan:=0;
- aux2.est:=false;
- seek(a,filesize(a));
- write(a,aux2)
- end;
- end;
- begin
- rta:='n';
- repeat
- inicio;
- clrscr;
- randomize;
- repeat
- u:=Random;
- if u<0.5
- then
- jug:=1
- else
- if u>0.5
- then jug:=2;
- until u<>0.5;
- Textcolor(11);
- {empieza el titulo}
- gotoxy(15,4);
- write (chr(218),chr(196),chr(196),chr(196),chr(196),chr(196),chr(196),chr(196),chr(191));
- write (chr(218),chr(196),chr(196),chr(196),chr(196),chr(196),chr(196),chr(191));
- write (' ',chr(218),chr(196),chr(196),chr(196),chr(196),chr(196),chr(196),chr(196),chr(191));
- write (chr(218),chr(196),chr(196),chr(196),chr(196),chr(196),chr(191));
- write (' ',chr(218),chr(196),chr(196),chr(196),chr(196),chr(196),chr(196),chr(196),chr(191));
- writeln (chr(218),chr(196),chr(191));
- gotoxy(15,5);
- write (chr(192),chr(196),chr(196),chr(191),' ',chr(218),chr(196),chr(196),chr(217));
- write (chr(179),' ',chr(218),chr(196),chr(196),chr(191),' ',chr(179));
- write (' ',chr(192),chr(196),chr(196),chr(191),' ',chr(218),chr(196),chr(196),chr(217));
- write (chr(179),' ',chr(218),chr(196),chr(196),chr(196),chr(217),' ');
- write (chr(192),chr(196),chr(196),chr(191),' ',chr(218),chr(196),chr(196),chr(217));
- writeln (chr(192),chr(196),chr(217));
- gotoxy(15,6);
- write (' ',chr(179),' ',chr(179),' ');
- write (chr(179),' ',chr(192),chr(196),chr(196),chr(217),' ',chr(179));
- write (chr(218),chr(196),chr(196),chr(191),chr(179),' ',chr(179),' ');
- write (chr(179),' ',chr(192),chr(196),chr(191),' ');
- write (chr(218),chr(196),chr(196),chr(191),chr(179),' ',chr(179),' ');
- writeln (chr(218),chr(196),chr(191));
- gotoxy(15,7);
- write (' ',chr(179),' ',chr(179),' ');
- write (chr(179),' ',chr(218),chr(196),chr(196),chr(191),' ',chr(179));
- write (chr(192),chr(196),chr(196),chr(217),chr(179),' ',chr(179),' ');
- write (chr(179),' ',chr(218),chr(196),chr(217),' ');
- write (chr(192),chr(196),chr(196),chr(217),chr(179),' ',chr(179),' ');
- writeln (chr(179),' ',chr(179));
- gotoxy(15,8);
- write (' ',chr(179),' ',chr(179),' ');
- write (chr(179),' ',chr(179),' ',chr(179),' ',chr(179));
- write (' ',chr(179),' ',chr(179),' ');
- write (chr(179),' ',chr(192),chr(196),chr(196),chr(196),chr(191));
- write (' ',chr(179),' ',chr(179),' ');
- writeln (chr(179),' ',chr(179));
- gotoxy(15,9);
- write (' ',chr(192),chr(196),chr(217),' ');
- write (chr(192),chr(196),chr(217),' ',chr(192),chr(196),chr(217));
- write (' ',chr(192),chr(196),chr(217),' ');
- write (chr(192),chr(196),chr(196),chr(196),chr(196),chr(196),chr(217));
- write (' ',chr(192),chr(196),chr(217),' ');
- writeln (chr(192),chr(196),chr(217));
- {termina el titulo}
- if rta='n'
- then begin
- textcolor(15);
- writeln;
- write ('Ingrese el nombre del jugador Nro 1: ');
- textcolor(5); readln(N1);
- writeln (N1,' jugara con las X'); textcolor(15);
- write ('Ingrese el nombre del jugador Nro 2: ');
- textcolor(2); readln(N2);writeln (N2,' jugara con las O'); textcolor(15);
- delay(1500);
- clrscr;
- gotoxy(10,5);
- busca(aux1,aux2,n1,n2,k1,k2);
- delay(0);
- {empiezan INSTRUCCIONES}
- writeln('INSTRUCCIONES');
- writeln('el juego se juega por turnos');
- writeln(' empieza un jugador seleccionado al azar por el ordenador');
- writeln('para seleccionar donde colocar la ficha, ingresar:');
- writeln(' el numero de la casilla');
- writeln('el ojetivo del juego es lograr colocar 3 fichas en linea');
- writeln('ya sea vertical, horizontal o diagonal)');
- writeln('gana el jugador que coloque 3 fichas en linea');
- writeln('QUE SE DIVIERTAN');writeln;
- write ('presione enter');
- repeat until keypressed; readln;
- end
- else begin
- textcolor(5); writeln (N1,' jugara con las X');
- textcolor(2) ;writeln (N2,' jugara con las O'); textcolor(15);
- repeat until keypressed; readln;
- end;
- {Terminan INSTRUCCIONES}
- ClrScr;
- {Empieza GRILLA TATETI}
- for i:=6 to 36 do
- begin
- Gotoxy(3,i);
- write(chr(179));
- gotoxy (23,i);
- write (chr(179));
- gotoxy (43,i);
- write (chr(179));
- Gotoxy(64,i);
- write(chr(179));
- end;
- GotoXY(3,5);
- write(chr(218));
- for i:=1 to 60 do
- write(chr(196));
- write(chr(191));
- gotoxy (3,16);
- for i:= 1 to 61 do
- write (chr(196));
- write(chr(180));
- gotoxy (3,26);
- for i:= 1 to 61 do
- write (chr(196));
- write (chr(180));
- GotoXY(3,36);
- write(chr(192));
- for i:=1 to 60 do
- write(chr(196));
- {Empieza numeración de la grilla}
- write(chr(217));
- gotoxy(23,5); write (chr(194));
- gotoxy(43,5); write (chr(194));
- gotoxy(3,16); write (chr(195));
- gotoxy(3,26); write (chr(195));
- gotoxy(23,16); write (chr(197));
- gotoxy(23,26); write (chr(197));
- gotoxy(43,16); write (chr(197));
- gotoxy(43,26); write (chr(197));
- gotoxy(23,36); write (chr(193));
- gotoxy(43,36); write (chr(193));
- gotoxy(13,11);writeln(7);
- gotoxy(33,11);writeln(8);
- gotoxy(53,11);writeln(9);
- gotoxy(13,21);writeln(4);
- gotoxy(33,21);writeln(5);
- gotoxy(53,21);writeln(6);
- gotoxy(13,31);writeln(1);
- gotoxy(33,31);writeln(2);
- gotoxy(53,31);writeln(3);
- {termina la numeración de la grilla}
- {Termina GRILLA TATETI}
- {EMPIEZA PARTIDA-----------------------------------------------------------}
- g:=0;
- t:=0;
- l:=0;
- b:=0;
- t:=37;
- for n:= 1 to 3 do
- for j:=1 to 3 do
- tat[n,j]:=0;
- j:=0;
- repeat
- if jug=1
- then
- {JUGADOR 1------------------------------------------------}
- begin
- repeat
- repeat
- gotoxy (5,t);
- write('turno jugador '); textcolor(5);Write(aux1.nom);
- textcolor(15); write(', ingrese ubicacion: ');
- read (l);
- until ((l>=1)and(l<=9));
- case l of
- 7:begin y:=7; x:=9; f:=1; c:=1 end;
- 8:begin y:=7; x:=29; f:=1; c:=2 end;
- 9:begin y:=7; x:=49; f:=1; c:=3 end;
- 4:begin y:=17; x:=9; f:=2; c:=1 end;
- 5:begin y:=17; x:=29; f:=2; c:=2 end;
- 6:begin y:=17; x:=49; f:=2; c:=3 end;
- 1:begin y:=27; x:=9; f:=3; c:=1 end;
- 2:begin y:=27; x:=29; f:=3; c:=2 end;
- 3:begin y:=27; x:=49; f:=3; c:=3 end
- end;
- until tat[f,c]=0;
- textcolor(5);
- gotoxy(x,y);writeln('** **');y:=y+1;
- gotoxy(x,y);writeln(' ** ** ');y:=y+1;
- gotoxy(x,y);writeln(' **** ');y:=y+1;
- gotoxy(x,y);writeln(' ** ');y:=y+1;
- gotoxy(x,y);writeln(' **** ');y:=y+1;
- gotoxy(x,y);writeln(' ** ** ');y:=y+1;
- gotoxy(x,y);writeln('** **');
- tat[f,c]:=1;
- textcolor(15);
- j:=j+1; jug:=2; t:=t+1
- end
- else
- {JUGADOR 2--------------------------------------------------}
- begin
- repeat
- repeat
- gotoxy (5,t);
- write('turno jugador '); textcolor(2);Write(aux2.nom);
- textcolor(15); write(', ingrese ubicacion: ');
- read (l);
- until ((l>=1)and(l<=9));
- case l of
- 7:begin y:=8; x:=9; f:=1; c:=1 end;
- 8:begin y:=8; x:=29; f:=1; c:=2 end;
- 9:begin y:=8; x:=49; f:=1; c:=3 end;
- 4:begin y:=18; x:=9; f:=2; c:=1 end;
- 5:begin y:=18; x:=29; f:=2; c:=2 end;
- 6:begin y:=18; x:=49; f:=2; c:=3 end;
- 1:begin y:=28; x:=9; f:=3; c:=1 end;
- 2:begin y:=28; x:=29; f:=3; c:=2 end;
- 3:begin y:=28; x:=49; f:=3; c:=3 end
- end;
- until tat[f,c]=0;
- textcolor(2);
- gotoxy(x,y); writeln(' *** '); y:=y+1;
- gotoxy(x,y); writeln(' ** ** '); y:=y+1;
- gotoxy(x,y); writeln('** **'); y:=y+1;
- gotoxy(x,y); writeln('** **'); y:=y+1;
- gotoxy(x,y); writeln(' ** ** '); y:=y+1;
- gotoxy(x,y); writeln(' *** ');
- tat[f,c]:=2;
- textcolor(15);
- j:=j+1;jug:=1 ; t:=t+1
- end;
- {VERIFICAR FINAL DE JPARTIDA-------------------------------------------------------}
- for g:=1to 2 do
- begin
- for i:= 1 to 3 do
- begin
- if ((tat[i,1]=tat[i,2])and(tat[i,1]=tat[i,3])and (tat[i,1]=g))
- then b:= g;
- if ((tat[1,i]=tat[2,i])and(tat[1,i]=tat[3,i])and (tat[1,i]=g))
- then b:= g
- end;
- if ((tat[1,1]=tat[2,2])and(tat[1,1]=tat[3,3])and (tat[1,1]=g))
- then b:= g;
- if ((tat[3,1]=tat[2,2])and(tat[3,1]=tat[1,3])and (tat[3,1]=g))
- then b:= g
- end;
- until (b<>0)or(j=9);
- clrscr;
- gotoxy (30,15);
- case b of
- 0: begin
- writeln ('EMPATE');
- aux1.pjug:=aux1.pjug+1;
- aux1.pgcon:=0;
- aux2.pjug:=aux2.pjug+1;
- aux2.pgcon:=0
- end;
- 1: begin
- write ('el ganador es ');
- textcolor(5); writeln (aux1.nom);
- aux1.pjug:=aux1.pjug+1;
- aux1.pgcon:=aux1.pgcon+1;
- aux2.pjug:=aux2.pjug+1;
- aux2.pgcon:=0
- end;
- 2: begin
- write ('el ganador es ');
- textcolor(2); writeln (n2);
- aux1.pjug:=aux1.pjug+1;
- aux1.pgcon:=0;
- aux2.pjug:=aux2.pjug+1;
- aux2.pgcon:=aux2.pgcon+1
- end
- end;
- seek(a,k1); write(a,aux1);
- seek(a,k2); write(a,aux2);
- textcolor(15); writeln; writeln; writeln;
- repeat write ('Desea jugar otra vez? S/N: '); readln; readln(rta);
- until (rta='n') or (rta='N')or (rta='s') or (rta='S');
- close(a);
- until (rta='n') or (rta='N');
- reset(a);
- writeln('NOMBRE':10,'PJUG':7,'PGAN':7,'PROM':7,'V SEG':7);
- z:=1;
- while (not eof (a)) do
- begin
- read (a,aux1);
- write (z:2, aux1.nom, aux1.pjug, aux1.pgan, (aux1.pgan/aux1.pjug)*100:5:2,'p',aux1.pgcon);
- z:=z+1
- end;
- readln;
- close(a);
- end.
Advertisement
Add Comment
Please, Sign In to add comment