Club Delphi  
    Paypal   FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > Varios
Registrarse FAQ Miembros Calendario Guía de estilo Buscar Temas de Hoy Marcar Foros Como Leídos

Coloboración Paypal con ClubDelphi

Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 27-03-2013
cloayza cloayza is offline
Miembro
 
Registrado: may 2003
Ubicación: San Pedro de la Paz, Chile
Posts: 947
Poder: 25
cloayza Tiene un aura espectacularcloayza Tiene un aura espectacular
Creo que aquí hay un problema...

Código Delphi [-]
if (aux mod 2 <> 0) then
     begin
       (sender as timage).picture:= form2.image1.Picture;
       (sender as timage).enabled:= false;
       if tag = 1 then
         matriz[1,1]:= 1
       else
         if tag = 1  then
           matriz[1,2]:=1
         else

Saludos cordiales...
Responder Con Cita
  #2  
Antiguo 27-03-2013
cloayza cloayza is offline
Miembro
 
Registrado: may 2003
Ubicación: San Pedro de la Paz, Chile
Posts: 947
Poder: 25
cloayza Tiene un aura espectacularcloayza Tiene un aura espectacular
Amigo te propongo esta modificación a tu algoritmo...

Código Delphi [-]
{
APos[Tag].X  =>Indice de la matriz
APos[Tag].Y  =>Indice de la matriz

Tag  Posicion Matriz
--------------------
1  =>matriz [1,1]
2  =>matriz [1,2]
3  =>matriz [1,3]
4  =>matriz [2,1]
5  =>matriz [2,2]
6  =>matriz [2,3]
7  =>matriz [3,1]
8  =>matriz [3,2]
9  =>matriz [3,3]

matriz [ APos[Tag].X, APos[Tag].Y ]
}

Const
    APos:Array[1..9] Of TPoint=((X:1; Y:1),(X:1;Y:2),(X:1;Y:3),(X:2;Y:1),(X:2;Y:2),(X:2;Y:3),(X:3;Y:1),(X:3;Y:2),(X:3;Y:3));
    {APos Vector con las coordenadas de x e y de la matriz...}

var i, aux:Integer;
    matriz:array[1..3,1..3] of Integer;
begin
   aux:= aux+1;

   if (aux mod 2 <> 0) then
     begin
       (sender as timage).picture:= form2.image1.Picture;
       (sender as timage).enabled:= false;

       Matriz[ APos[Tag].X, APos[Tag].Y]:= 1;

{       if tag = 1 then
         matriz[1,1]:= 1
       else
         if tag = 1  then
           matriz[1,2]:=1
         else
           if tag =3 then
             matriz[1,3]:=1
           else
             if tag = 4 then
               matriz[2,1]:=1
             else
               if tag = 5 then
                 matriz[2,2]:=1
               else
                 if tag = 6 then
                   matriz[2,3]:=1
                 else
                   if tag = 7 then
                     matriz[3,1]:= 1
                   else
                     if tag = 8 then
                       matriz[3,2]:=1
                     else
                       matriz[3,3]:=1;
}
       for i:=8 to  248 do
         begin
           sleep(1);
           refresh;
           shape1.top:=i;
         end;
     end
   else
     begin
       (sender as timage).picture:= form2.image2.Picture;
       (sender as timage).enabled:= false;

       Matriz[ APos[Tag].X, APos[Tag].Y]:= 1;

       {if tag = 1 then
         showmessage('Hola')
       else
         if tag = 2 then
           matriz[1,2]:=2
         else
           if tag =3 then
             matriz[1,3]:=2
           else
             if tag = 4 then
               matriz[2,1]:=2
             else
               if tag = 5 then
                 matriz[2,2]:=2
               else
                 if tag = 6 then
                   matriz[2,3]:=2
                 else
                   if tag = 7 then
                     matriz[3,1]:= 2
                   else
                     if tag = 8 then
                       matriz[3,2]:=2
                     else
                       matriz[3,3]:=2;
       }
       for i := 248 downto 8 do
         begin
           sleep(1);
           refresh;
           shape1.Top:=i;
         end;
     end;

Saludos cordiales
Responder Con Cita
  #3  
Antiguo 28-03-2013
Neg90 Neg90 is offline
Miembro
NULL
 
Registrado: mar 2013
Posts: 29
Poder: 0
Neg90 Va por buen camino
A mira esta buena esa, ahora que la veo capas que me sirve mas que la que implemente yo, por que me quedo medio feo (o del todo :P) el tema de ver quien gana o si empatan

Código Delphi [-]
if (((matriz[1,1] <>0) and (matriz[1,2] <>0)) and ((matriz[1,3] <> 0)) and
      ((matriz[2,1] <>0) and (matriz[2,2] <>0)) and ((matriz[2,3] <> 0)) and
      ((matriz[3,1] <>0) and (matriz[3,2] <>0)) and ((matriz[3,3] <> 0))
      and (no2 =true ) and (no1 = true)) then
            showmessage('Emptaron');
   no1:=true;
   no2:=true;
   aux:= aux+1;
   if (aux mod 2 <> 0) then
     begin
       (sender as timage).picture:= form2.image1.picture;
       (sender as timage).enabled:= false;
       case (sender as timage).Tag of
         1:matriz[1,1]:=1;
         2:matriz[1,2]:=1;
         3:matriz[1,3]:=1;
         4:matriz[2,1]:=1;
         5:matriz[2,2]:=1;
         6:matriz[2,3]:=1;
         7:matriz[3,1]:=1;
         8:matriz[3,2]:=1;
         9:matriz[3,3]:=1;
       end;
       for i:=8 to  248 do
         begin
           sleep(1);
           refresh;
           shape1.top:=i;
         end;
         if ((matriz[1,1] =1) and (matriz[1,2] =1)) and ((matriz[1,3] = 1)) or
            ((matriz[2,1] =1) and (matriz[2,2] =1)) and ((matriz[2,3] = 1)) or
            ((matriz[3,1] =1) and (matriz[3,2] =1)) and ((matriz[3,3] = 1)) or
            ((matriz[1,1] =1) and (matriz[2,1] =1)) and ((matriz[3,1] = 1)) or
            ((matriz[1,2] =1) and (matriz[2,2] =1)) and ((matriz[3,2] = 1)) or
            ((matriz[1,3] =1) and (matriz[2,3] =1)) and ((matriz[3,3] = 1)) or
            ((matriz[1,1] =1) and (matriz[2,2] =1)) and ((matriz[3,3] = 1)) or
            ((matriz[3,1] =1) and (matriz[2,2] =1)) and ((matriz[1,3] = 1)) then
              begin
               showmessage('Gana '+ label1.Caption);
               no1:=true;
              end;
     end
   else
     begin
       (sender as timage).picture:= form2.image2.Picture;
       (sender as timage).enabled:= false;
       case (sender as timage).Tag of
         1:matriz[1,1]:=2;
         2:matriz[1,2]:=2;
         3:matriz[1,3]:=2;
         4:matriz[2,1]:=2;
         5:matriz[2,2]:=2;
         6:matriz[2,3]:=2;
         7:matriz[3,1]:=2;
         8:matriz[3,2]:=2;
         9:matriz[3,3]:=2;
       end;
       for i := 248 downto 8 do
         begin
           sleep(1);
           refresh;
           shape1.Top:=i;
         end;
       if ((matriz[1,1] =2) and (matriz[1,2] =2)) and ((matriz[1,3] = 2)) or
         ((matriz[2,1] =2) and (matriz[2,2] =2)) and ((matriz[2,3] = 2)) or
         ((matriz[3,1] =2) and (matriz[3,2] =2)) and ((matriz[3,3] = 2)) or
         ((matriz[1,1] =2) and (matriz[2,1] =2)) and ((matriz[3,1] = 2)) or
         ((matriz[1,2] =2) and (matriz[2,2] =2)) and ((matriz[3,2] = 2)) or
         ((matriz[1,3] =2) and (matriz[2,3] =2)) and ((matriz[3,3] = 2)) or
         ((matriz[1,1] =2) and (matriz[2,2] =2)) and ((matriz[3,3] = 2)) or
         ((matriz[3,1] =2) and (matriz[2,2] =2)) and ((matriz[1,3] = 2)) then
           begin
             showmessage('Gana ' + label2.Caption);
             no2:=true;
           end;
     end;

Voy a ver que hago si encuentro una forma mas practica de encontrar ganador/empate en mi algoritmo o implemento el que vos decís y pruebo. escucho cualquier sugerencia estoy complicado con el tema, hace poco arranque a estudiar delphi así que todo me sirve. Les agradezco por ayudarme desde ya.
Responder Con Cita
  #4  
Antiguo 28-03-2013
cloayza cloayza is offline
Miembro
 
Registrado: may 2003
Ubicación: San Pedro de la Paz, Chile
Posts: 947
Poder: 25
cloayza Tiene un aura espectacularcloayza Tiene un aura espectacular
Te propongo este código...espero te sirva...

Código Delphi [-]
{
APos[Tag].X  =>Indice de la matriz
APos[Tag].Y  =>Indice de la matriz

Tag  Posicion Matriz
--------------------
1  =>matriz [1,1]
2  =>matriz [1,2]
3  =>matriz [1,3]
4  =>matriz [2,1]
5  =>matriz [2,2]
6  =>matriz [2,3]
7  =>matriz [3,1]
8  =>matriz [3,2]
9  =>matriz [3,3]

matriz [ APos[Tag].X, APos[Tag].Y ]
}

Const
    APos:Array[1..9] Of TPoint=((X:1; Y:1),(X:1;Y:2),(X:1;Y:3),(X:2;Y:1),(X:2;Y:2),(X:2;Y:3),(X:3;Y:1),(X:3;Y:2),(X:3;Y:3));
    {APos Vector con las coordenadas de x e y de la matriz...}
    Size_Matriz=3;
type
    TMatriz=array[1..Size_Matriz,1..Size_Matriz] of Integer;

var i, aux:Integer;
    matriz:TMatriz;
    no1, no2:Boolean;
    Key:Integer;

    function CheckHorizontal(Values:TMatriz; Key:Integer):Boolean;
    var
       i,j, Count:Integer;
    begin
         Result:=False;
         for i := 1 to Size_Matriz do
         begin
              Count:=0;
              for j:=1 to Size_Matriz do
              begin
                   If Values[i,j]=Key then
                      Inc(Count);
              end;

              Result:=Count=Size_Matriz;

              if Result then
                 Break;
         end;
    end;

    function CheckVertical(Values:TMatriz; Key:Integer):Boolean;
    var
       i,j, Count:Integer;
    begin
         Result:=False;
         for j := 1 to Size_Matriz do
         begin
              Count:=0;
              for i:=1 to Size_Matriz do
              begin
                   If Values[i,j]=Key then
                      Inc(Count);
              end;

              Result:=(Count=Size_Matriz);

              if Result then
                 Break;
         end;
    end;

    function CheckDiagonalPrincipal(Values:TMatriz; Key:Integer):Boolean;
    var
       i,j, Count:Integer;
    begin
         Result:=False;
         Count :=0;
         for i := 1 to Size_Matriz do
         begin
               { i,i coordenadas de la diagonal principal 1,1   2,2   3,3 }
               If Values[i,i]=Key then
                  Inc(Count);
         end;

         Result:=(Count=Size_Matriz);
    end;

    function CheckDiagonalSecundaria(Values:TMatriz; Key:Integer):Boolean;
    var
       i,j, Count:Integer;
    begin
         Result:=False;
         Count :=0;
         j:=1;
         for i := Size_Matriz downto 1 do
         begin
               { i,j coordenadas de la diagonal secundaria 3,1   2,2   1,3 }
               If Values[i,j]=Key then
                  Inc(Count);
               Inc(j);
         end;

         Result:=(Count=Size_Matriz);
    end;
begin
     aux:= aux+1;

     if (aux mod 2 <> 0) then
     begin
         (Sender as TImage).Picture:= Self.Image1.Picture;
         (Sender as TImage).Enabled:= False;

         Key:=1;
     end
     else
     begin
         (Sender as TImage).picture:= Self.Image2.Picture;
         (Sender as TImage).enabled:= False;

         Key:=2;
     end;

     //Asignas el valor 1 o 2 que esta en la Variable KEY (Integer)...
     Matriz[ APos[Tag].X, APos[Tag].Y]:= Key;

     For i := 248 downto 8 do
     begin
          sleep(1);
          refresh;
          shape1.Top:=i;
     end;

     //Check el valor de la matriz de acuerdo a el valor de Key
     if CheckHorizontal(matriz, Key) or
        CheckVertical(Matriz, Key) or
        CheckDiagonalPrincipal(Matriz, Key) Or
        CheckDiagonalSecundaria(Matriz, Key) then
     begin
           showmessage('Gana ' + label2.Caption);

           no1:=Key=1;
           no2:=Key=2;
     end;

Saludos cordiales
Responder Con Cita
  #5  
Antiguo 29-03-2013
Neg90 Neg90 is offline
Miembro
NULL
 
Registrado: mar 2013
Posts: 29
Poder: 0
Neg90 Va por buen camino
Muchas gracias por tu ayuda, ya esta andando perfecto el tateti, gracias por la explicación!
Responder Con Cita
Respuesta


Herramientas Buscar en Tema
Buscar en Tema:

Búsqueda Avanzada
Desplegado

Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro


La franja horaria es GMT +2. Ahora son las 00:05:59.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi