Advertisement
milardovich

Tateti V3.5

Aug 4th, 2011
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 10.52 KB | None | 0 0
  1. {
  2.  **********************************************************************************************************************
  3.  * Juego de Tateti V3.5                                                                                                       *
  4.  * Desarrollado por Damián Cardona <damiancardona@gmail.com> y Sergio Milardovich <deep.milardovich@gmail.com>       *
  5.  * Nota: este programa usa caracteres de código ASCII extendidos, por lo que es posible que en algunas computadoras      *
  6.  * no se vea correctamente. Para más info vistar: http://es.wikipedia.org/wiki/ASCII_extendido                       *
  7.  **********************************************************************************************************************
  8. }
  9. program tateti (input, output);
  10. uses
  11.     Crt;
  12. var
  13.    N1,N2:string;
  14.    u:real;
  15.    rta:char;
  16.    tat: array[1..9]of real;
  17.    g,t,c,b,l,n,i,x,y,color_x,color_o,actual,color_actual:integer;
  18. begin
  19.     randomize;
  20.     {
  21.      Seleccionar color para las X y las O
  22.     }
  23.     color_x := 12;
  24.     color_o := 13;
  25.     repeat
  26.         u:=Random;
  27.         {
  28.          Elegir qué jugador va a empezar
  29.         }
  30.         if u<0.5
  31.         then
  32.             c:=1
  33.         else
  34.             c:=2;
  35.     until u<>0.5;
  36.     g:=0;
  37.     t:=0;
  38.     Textcolor(11);
  39. {empieza el titulo}
  40.      gotoxy(15,4);
  41.      write (chr(218),chr(196),chr(196),chr(196),chr(196),chr(196),chr(196),chr(196),chr(191));
  42.      write (chr(218),chr(196),chr(196),chr(196),chr(196),chr(196),chr(196),chr(191));
  43.      write (' ',chr(218),chr(196),chr(196),chr(196),chr(196),chr(196),chr(196),chr(196),chr(191));
  44.      write (chr(218),chr(196),chr(196),chr(196),chr(196),chr(196),chr(191));
  45.      write (' ',chr(218),chr(196),chr(196),chr(196),chr(196),chr(196),chr(196),chr(196),chr(191));
  46.      writeln (chr(218),chr(196),chr(191));
  47.      gotoxy(15,5);
  48.      write (chr(192),chr(196),chr(196),chr(191),' ',chr(218),chr(196),chr(196),chr(217));
  49.      write (chr(179),' ',chr(218),chr(196),chr(196),chr(191),' ',chr(179));
  50.      write (' ',chr(192),chr(196),chr(196),chr(191),' ',chr(218),chr(196),chr(196),chr(217));
  51.      write (chr(179),' ',chr(218),chr(196),chr(196),chr(196),chr(217),' ');
  52.      write (chr(192),chr(196),chr(196),chr(191),' ',chr(218),chr(196),chr(196),chr(217));
  53.      writeln (chr(192),chr(196),chr(217));
  54.      gotoxy(15,6);
  55.      write ('   ',chr(179),' ',chr(179),'   ');
  56.      write (chr(179),' ',chr(192),chr(196),chr(196),chr(217),' ',chr(179));
  57.      write (chr(218),chr(196),chr(196),chr(191),chr(179),' ',chr(179),'   ');
  58.      write (chr(179),' ',chr(192),chr(196),chr(191),'  ');
  59.      write (chr(218),chr(196),chr(196),chr(191),chr(179),' ',chr(179),'   ');
  60.      writeln (chr(218),chr(196),chr(191));
  61.      gotoxy(15,7);
  62.      write ('   ',chr(179),' ',chr(179),'   ');
  63.      write (chr(179),' ',chr(218),chr(196),chr(196),chr(191),' ',chr(179));
  64.      write (chr(192),chr(196),chr(196),chr(217),chr(179),' ',chr(179),'   ');
  65.      write (chr(179),' ',chr(218),chr(196),chr(217),'  ');
  66.      write (chr(192),chr(196),chr(196),chr(217),chr(179),' ',chr(179),'   ');
  67.      writeln (chr(179),' ',chr(179));
  68.      gotoxy(15,8);
  69.      write ('   ',chr(179),' ',chr(179),'   ');
  70.      write (chr(179),' ',chr(179),'  ',chr(179),' ',chr(179));
  71.      write ('    ',chr(179),' ',chr(179),'   ');
  72.      write (chr(179),' ',chr(192),chr(196),chr(196),chr(196),chr(191));
  73.      write ('    ',chr(179),' ',chr(179),'   ');
  74.      writeln (chr(179),' ',chr(179));
  75.      gotoxy(15,9);
  76.      write ('   ',chr(192),chr(196),chr(217),'   ');
  77.      write (chr(192),chr(196),chr(217),'  ',chr(192),chr(196),chr(217));
  78.      write ('    ',chr(192),chr(196),chr(217),'   ');
  79.      write (chr(192),chr(196),chr(196),chr(196),chr(196),chr(196),chr(217));
  80.      write ('    ',chr(192),chr(196),chr(217),'   ');
  81.      writeln (chr(192),chr(196),chr(217));
  82. {termina el titulo}
  83.      textcolor(15);
  84.      writeln;
  85.      write ('Ingrese el nombre del jugador Nro 1: ');
  86.      textcolor(color_x); readln(N1); textcolor(15);
  87.      writeln (N1,' jugara con las X');
  88.      write ('Ingrese el nombre del jugador Nro 2: ');
  89.      textcolor(color_o); readln(N2); textcolor(15); writeln (N2,' jugara con las O');
  90.      writeln ('Para comenzar presione enter');
  91.      write ('para ver instrucciones presione i: ');
  92.      clrscr;
  93.      gotoxy(10,5);
  94. {empiezan INSTRUCCIONES}
  95.      writeln('INSTRUCCIONES');
  96.      writeln('el juego se juega por turnos');
  97.      writeln(' empieza un jugador seleccionado al azar por el ordenador');
  98.      writeln('para seleccionar donde colocar la ficha, ingresar');
  99.      writeln(' simplemente el numero de casillero donde se quiera colocar la ficha (del 1 al 9)');
  100.      writeln('el ojetivo del juego es lograr colocar 3 fichas en linea');
  101.      writeln('ya sea vertical, horizontal o diagonal)');
  102.      writeln('gana el jugador que coloque 3 fichas en linea');
  103.      writeln('QUE SE DIVIERTAN');writeln;
  104.      write ('precione enter');
  105.      repeat until keypressed; readln;
  106. {Terminan INSTRUCCIONES}
  107.      l:=0;
  108.      b:=0;
  109.      ClrScr;
  110. {Empieza GRILLA TATETI}
  111.      for i:=6 to 36 do
  112.          begin
  113.                Gotoxy(3,i);
  114.                write(chr(179));
  115.                gotoxy (23,i);
  116.                write (chr(179));
  117.                gotoxy (43,i);
  118.                write (chr(179));
  119.                Gotoxy(64,i);
  120.                write(chr(179));
  121.          end;
  122.      GotoXY(3,5);
  123.      write(chr(218));
  124.      for i:=1 to 60 do
  125.          write(chr(196));
  126.      write(chr(191));
  127.      gotoxy (3,16);
  128.      for i:= 1 to 61 do
  129.          write (chr(196));
  130.      write(chr(180));
  131.      gotoxy (3,26);
  132.      for i:= 1 to 61 do
  133.          write (chr(196));
  134.      write (chr(180));
  135.      GotoXY(3,36);
  136.      write(chr(192));
  137.      for i:=1 to 60 do
  138.          write(chr(196));
  139. {Empieza numeración de la grilla}
  140.      write(chr(217));
  141.      gotoxy(23,5); write (chr(194));
  142.      gotoxy(43,5); write (chr(194));
  143.      gotoxy(3,16); write (chr(195));
  144.      gotoxy(3,26); write (chr(195));
  145.      gotoxy(23,16); write (chr(197));
  146.      gotoxy(23,26); write (chr(197));
  147.      gotoxy(43,16); write (chr(197));
  148.      gotoxy(43,26); write (chr(197));
  149.      gotoxy(23,36); write (chr(193));
  150.      gotoxy(43,36); write (chr(193));
  151.      gotoxy(13,11);writeln(7);
  152.      gotoxy(33,11);writeln(8);
  153.      gotoxy(53,11);writeln(9);
  154.      gotoxy(13,21);writeln(4);
  155.      gotoxy(33,21);writeln(5);
  156.      gotoxy(53,21);writeln(6);
  157.      gotoxy(13,31);writeln(1);
  158.      gotoxy(33,31);writeln(2);
  159.      gotoxy(53,31);writeln(3);
  160. {termina la numeración de la grilla}
  161. {EMPIEZA PARTIDA-----------------------------------------------------------}
  162.      i:=37;
  163.      {"Limpiar" el array del Tateti}
  164.      for n:= 1 to 9 do
  165.          tat[l]:=0;
  166.      repeat
  167.      if c=1
  168.         then
  169.         {JUGADOR 1}
  170.         begin
  171.             color_actual := color_x;
  172.         end
  173.         else
  174.         {JUGADOR 2}
  175.         begin
  176.             color_actual := color_o;
  177.         end;
  178.         repeat
  179.             repeat
  180.                 gotoxy (5,i);
  181.                 write('turno jugador '); textcolor(5);Write(c);
  182.                 write(', ingrese ubicacion: ');
  183.                 read (l);
  184.             until ((l>=1)and(l<=9));
  185.             textcolor(color_actual);
  186.         until tat[l]=0;
  187.         case l of
  188.              7:begin y:=7; x:=9 end;
  189.              8:begin y:=7; x:=29 end;
  190.              9:begin y:=7; x:=49 end;
  191.              4:begin y:=17; x:=9 end;
  192.              5:begin y:=17; x:=29 end;
  193.              6:begin y:=17; x:=49 end;
  194.              1:begin y:=27; x:=9 end;
  195.              2:begin y:=27; x:=29 end;
  196.              3:begin y:=27; x:=49 end
  197.         end;
  198.         if c = 1 then
  199.         begin
  200.             gotoxy(x,y);writeln('**    **');y:=y+1;
  201.             gotoxy(x,y);writeln(' **  ** ');y:=y+1;
  202.             gotoxy(x,y);writeln('  ****  ');y:=y+1;
  203.             gotoxy(x,y);writeln('   **   ');y:=y+1;
  204.             gotoxy(x,y);writeln('  ****  ');y:=y+1;
  205.             gotoxy(x,y);writeln(' **  ** ');y:=y+1;
  206.             gotoxy(x,y);writeln('**    **');
  207.             actual := 2;
  208.         end
  209.         else
  210.         begin
  211.             gotoxy(x,y); writeln('   ***   '); y:=y+1;
  212.             gotoxy(x,y); writeln(' **   ** '); y:=y+1;
  213.             gotoxy(x,y); writeln('**     **'); y:=y+1;
  214.             gotoxy(x,y); writeln('**     **'); y:=y+1;
  215.             gotoxy(x,y); writeln(' **   ** '); y:=y+1;
  216.             gotoxy(x,y); writeln('   ***  ');
  217.             actual := 1;
  218.         end;
  219.         {Cambiar de jugador}
  220.         tat[l]:= c;
  221.         i:=i+1;
  222.         c := actual;
  223.         {Resetear el color de texto}
  224.         textcolor(15);
  225. {VERIFICAR FINAL DE PARTIDA}
  226.      if (tat[1]=tat[2])and(tat[1]=tat[3]) and ((tat[1]<>0) and (tat[2]<>0) and (tat[3] <>0))
  227.         then b:=1;
  228.      if (tat[4]=tat[5])and(tat[4]=tat[6]) and ((tat[4]<>0) and (tat[5]<>0) and (tat[6] <>0))
  229.         then b:=1;
  230.      if (tat[7]=tat[8])and(tat[7]=tat[9]) and ((tat[7]<>0) and (tat[8]<>0) and (tat[9] <>0))
  231.         then b:=1;
  232.      if (tat[1]=tat[4])and(tat[1]=tat[7]) and ((tat[1]<>0) and (tat[7]<>0) and (tat[7] <>0))
  233.         then b:=1;
  234.      if (tat[2]=tat[5])and(tat[2]=tat[8]) and ((tat[2]<>0) and (tat[5]<>0) and (tat[8] <>0))
  235.         then b:=1;
  236.      if (tat[3]=tat[6])and(tat[3]=tat[9]) and ((tat[3]<>0) and (tat[6]<>0) and (tat[9] <>0))
  237.         then b:=1;
  238.      if (tat[1]=tat[5])and(tat[1]=tat[9])and ((tat[1]<>0) and (tat[5]<>0) and (tat[9] <>0))
  239.         then b:=1;
  240.      if (tat[7]=tat[5])and(tat[7]=tat[3])and ((tat[7]<>0) and (tat[5]<>0) and (tat[3] <>0))
  241.         then b:=1;
  242.      t:=t+1
  243.      until (b=1) or (t=9);
  244.  {FINAL PARTIDA--------------------------------------------------------------------------}
  245.      clrscr;
  246.      gotoxy(30,15);
  247.      if b=1
  248.         then
  249.             begin
  250.                 for i:=1 to 2 do
  251.                 begin
  252.                  if (tat[1]=i) and (tat[2]=i) and (tat[3]=i)
  253.                        then g:=i;
  254.                  if (tat[4]=i) and (tat[5]=i) and (tat[6]=i)
  255.                        then g:=i;
  256.                  if (tat[7]=i) and (tat[8]=i) and (tat[9]=i)
  257.                        then g:=i;
  258.                  if (tat[1]=i) and (tat[4]=i) and (tat[7]=i)
  259.                        then g:=i;
  260.                  if (tat[2]=i) and (tat[5]=i) and (tat[8]=i)
  261.                        then g:=i;
  262.                  if (tat[3]=i) and (tat[6]=i) and (tat[9]=i)
  263.                        then g:=i;
  264.                  if (tat[1]=i) and (tat[5]=i) and (tat[9]=i)
  265.                        then g:=i;
  266.                  if (tat[3]=i) and (tat[5]=i) and (tat[7]=i)
  267.                        then g:=i;
  268.                 end;
  269.                 {Mostrar el ganador}
  270.                 case g of
  271.                 0: write ('empate');
  272.                 1: begin
  273.                         write ('el ganador es ');
  274.                         textcolor(color_x); write (n1)
  275.                    end;
  276.                 2: begin
  277.                         write ('el ganador es ');
  278.                         textcolor(color_o); write (n2)
  279.                    end
  280.                 end
  281.             end
  282.         else
  283.             write ('EMPATE');
  284. repeat until keypressed;
  285. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement