AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

Game of Life-Quellcode funzt nicht

Ein Thema von R2D2 · begonnen am 20. Feb 2006 · letzter Beitrag vom 23. Feb 2006
Antwort Antwort
Benutzerbild von R2D2
R2D2

Registriert seit: 20. Jan 2006
Ort: München
253 Beiträge
 
Delphi 2005 Personal
 
#1

Re: Game of Life-Quellcode funzt nicht

  Alt 20. Feb 2006, 14:21
Hier mal die Funktion:
Delphi-Quellcode:
procedure TGOL.Live;
var x,y,i: Integer; s1, s2, s3, sn: String; sl1,sl2: TStringList;
begin
     //Reihen
     for y := 0 to (sl1.count)-1 do
     begin
          s2 := sl1.Strings[y];
          sn := '';
          if (y > 0) then s1 := sl1.Strings[y-1];
          if (y < (sl1.count)-1) then s3 := sl1.strings[y+1];
          //Spalten
          for x := 0 to Length(sl1.strings[y])-1 do
          begin
                    i := 0;
                    //-Oben-
                    if (x > 0) and (y > 0) and (Copy(s1,x-1,1) = '1') then
                    begin
                         inc(i);
                    end;
                    if (y > 0) and (Copy(s1,x,1) = '1') then
                    begin
                         inc(i);
                    end;
                    if (x < (Length(s2))) and (y > 0) and (Copy(s1,x+1,1) = '1') then
                    begin
                         inc(i);
                    end;

                    //-Mitte-
                    if (x > 0) and (Copy(s2,x-1,1) = '1') then
                    begin
                         inc(i);
                    end;
                    if (x < (Length(s2))) and (Copy(s2,x+1,1) = '1') then
                    begin
                         inc(i);
                    end;

                    //-Unten-
                    if (y < ((sl1.count))) and (x > 0) and (Copy(s3,x-1,1) = '1') then
                    begin
                         inc(i);
                    end;
                    if (y < ((sl1.count))) and (Copy(s3,x,1) = '1') then
                    begin
                         inc(i);
                    end;
                    if (y < ((sl1.count))) and (x < (Length(s2))) and (Copy(s3,x+1,1) = '1') then
                    begin
                         inc(i);
                    end;

                    //-Setzen-
                    if (i = 3) then
                    begin
                         sn := sn + '1';
                    end;
                    if (i = 2) and (Copy(s2, x,1) = '1') then
                    begin
                         sn := sn + '1';
                    end;
                    if (i = 2) and (Copy(s2, x,1) = '0') then
                    begin
                         sn := sn + '0';
                    end;
                    if (i <> 3) then
                    begin
                        if (i <> 2) then sn := sn + '0';
                    end;
          end;
          sl2.Strings[y] := sn;
     end;
     sl1 := sl2;
     View(sl1);
end;
  Mit Zitat antworten Zitat
Antwort Antwort


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 13:51 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz