Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {
- **********************************************************************************************************************
- * Juego de Tateti V3.5 *
- * Desarrollado por Damián Cardona <damiancardona@gmail.com> y Sergio Milardovich <deep.milardovich@gmail.com> *
- * 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;
- var
- N1,N2:string;
- u:real;
- rta:char;
- tat: array[1..9]of real;
- g,t,c,b,l,n,i,x,y,color_x,color_o,actual,color_actual:integer;
- begin
- randomize;
- {
- Seleccionar color para las X y las O
- }
- color_x := 12;
- color_o := 13;
- repeat
- u:=Random;
- {
- Elegir qué jugador va a empezar
- }
- if u<0.5
- then
- c:=1
- else
- c:=2;
- until u<>0.5;
- g:=0;
- t:=0;
- 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}
- textcolor(15);
- writeln;
- write ('Ingrese el nombre del jugador Nro 1: ');
- textcolor(color_x); readln(N1); textcolor(15);
- writeln (N1,' jugara con las X');
- write ('Ingrese el nombre del jugador Nro 2: ');
- textcolor(color_o); readln(N2); textcolor(15); writeln (N2,' jugara con las O');
- writeln ('Para comenzar presione enter');
- write ('para ver instrucciones presione i: ');
- clrscr;
- gotoxy(10,5);
- {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(' simplemente el numero de casillero donde se quiera colocar la ficha (del 1 al 9)');
- 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 ('precione enter');
- repeat until keypressed; readln;
- {Terminan INSTRUCCIONES}
- l:=0;
- b:=0;
- 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}
- {EMPIEZA PARTIDA-----------------------------------------------------------}
- i:=37;
- {"Limpiar" el array del Tateti}
- for n:= 1 to 9 do
- tat[l]:=0;
- repeat
- if c=1
- then
- {JUGADOR 1}
- begin
- color_actual := color_x;
- end
- else
- {JUGADOR 2}
- begin
- color_actual := color_o;
- end;
- repeat
- repeat
- gotoxy (5,i);
- write('turno jugador '); textcolor(5);Write(c);
- write(', ingrese ubicacion: ');
- read (l);
- until ((l>=1)and(l<=9));
- textcolor(color_actual);
- until tat[l]=0;
- case l of
- 7:begin y:=7; x:=9 end;
- 8:begin y:=7; x:=29 end;
- 9:begin y:=7; x:=49 end;
- 4:begin y:=17; x:=9 end;
- 5:begin y:=17; x:=29 end;
- 6:begin y:=17; x:=49 end;
- 1:begin y:=27; x:=9 end;
- 2:begin y:=27; x:=29 end;
- 3:begin y:=27; x:=49 end
- end;
- if c = 1 then
- begin
- 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('** **');
- actual := 2;
- end
- else
- begin
- 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(' *** ');
- actual := 1;
- end;
- {Cambiar de jugador}
- tat[l]:= c;
- i:=i+1;
- c := actual;
- {Resetear el color de texto}
- textcolor(15);
- {VERIFICAR FINAL DE PARTIDA}
- if (tat[1]=tat[2])and(tat[1]=tat[3]) and ((tat[1]<>0) and (tat[2]<>0) and (tat[3] <>0))
- then b:=1;
- if (tat[4]=tat[5])and(tat[4]=tat[6]) and ((tat[4]<>0) and (tat[5]<>0) and (tat[6] <>0))
- then b:=1;
- if (tat[7]=tat[8])and(tat[7]=tat[9]) and ((tat[7]<>0) and (tat[8]<>0) and (tat[9] <>0))
- then b:=1;
- if (tat[1]=tat[4])and(tat[1]=tat[7]) and ((tat[1]<>0) and (tat[7]<>0) and (tat[7] <>0))
- then b:=1;
- if (tat[2]=tat[5])and(tat[2]=tat[8]) and ((tat[2]<>0) and (tat[5]<>0) and (tat[8] <>0))
- then b:=1;
- if (tat[3]=tat[6])and(tat[3]=tat[9]) and ((tat[3]<>0) and (tat[6]<>0) and (tat[9] <>0))
- then b:=1;
- if (tat[1]=tat[5])and(tat[1]=tat[9])and ((tat[1]<>0) and (tat[5]<>0) and (tat[9] <>0))
- then b:=1;
- if (tat[7]=tat[5])and(tat[7]=tat[3])and ((tat[7]<>0) and (tat[5]<>0) and (tat[3] <>0))
- then b:=1;
- t:=t+1
- until (b=1) or (t=9);
- {FINAL PARTIDA--------------------------------------------------------------------------}
- clrscr;
- gotoxy(30,15);
- if b=1
- then
- begin
- for i:=1 to 2 do
- begin
- if (tat[1]=i) and (tat[2]=i) and (tat[3]=i)
- then g:=i;
- if (tat[4]=i) and (tat[5]=i) and (tat[6]=i)
- then g:=i;
- if (tat[7]=i) and (tat[8]=i) and (tat[9]=i)
- then g:=i;
- if (tat[1]=i) and (tat[4]=i) and (tat[7]=i)
- then g:=i;
- if (tat[2]=i) and (tat[5]=i) and (tat[8]=i)
- then g:=i;
- if (tat[3]=i) and (tat[6]=i) and (tat[9]=i)
- then g:=i;
- if (tat[1]=i) and (tat[5]=i) and (tat[9]=i)
- then g:=i;
- if (tat[3]=i) and (tat[5]=i) and (tat[7]=i)
- then g:=i;
- end;
- {Mostrar el ganador}
- case g of
- 0: write ('empate');
- 1: begin
- write ('el ganador es ');
- textcolor(color_x); write (n1)
- end;
- 2: begin
- write ('el ganador es ');
- textcolor(color_o); write (n2)
- end
- end
- end
- else
- write ('EMPATE');
- repeat until keypressed;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement