"Game of Life" - 2D und 3D

Code-Stücke können hier veröffentlicht werden.
Antworten
Benutzeravatar
Craven
User
Beiträge: 223
Registriert: Dienstag 24. Januar 2006, 13:37

Hi!
Mir war mal wieder Langweilig, da dachte ich mir, ich könnte mal ein Game of Life Script schreiben ... Lasst mich dazusagen, dass es ziemlich viel Leistung braucht ... :wink:

2D-Version:

Code: Alles auswählen

import time

class game_of_life:

    def __init__(self, a = 100, b = 100, r = 100):
        self.living_pixel = [[3,3], [3,4], [3,5]]
        self.next_gen = []
        x = 1
        y = 1
        i = 1
        t1 = time.time()
        while i < r:
            while x < a:
                while y < b:
                    self.check_pixel(x, y)
                    y = y + 1
                y = 1
                x = x + 1
            self.living_pixel = self.next_gen
            self.next_gen = []
            x = 1
            i = i + 1
            print self.living_pixel
        t2 = time.time()
        #print round(t2 - t1, 5)
        raw_input()

    def check_pixel(self, x, y):
        if [x, y] in self.living_pixel:
            #print x,y,"is a living pixel"
            self.is_living_pixel(x, y)
        else:
            #print x,y,"is a dead pixel"
            self.is_dead_pixel(x, y)

    def is_living_pixel(self, x, y):
        neighbours = self.count_neighbours(x, y)
        #print x,y,"has",neighbours,"neighbours"
        ##if neighbours != 2 and neighbours != 3:
        ##    #print "--> Pixel dies"
        ##    #self.living_pixel.remove([x, y])
        ##else:
        ##    self.next_gen.append([x, y])
        if neighbours == 2 or neighbours == 3:
            #print "--> Pixel stays alive"
            self.next_gen.append([x, y])

    def is_dead_pixel(self, x, y):
        neighbours = self.count_neighbours(x, y)
        #print x,y,"has",neighbours,"neighbours"
        if neighbours == 3:
            #print "--> Pixel spawns"
            self.next_gen.append([x, y])

    def count_neighbours(self, x, y):
        i = 0
        if [x-1, y-1] in self.living_pixel:
            i = i + 1
        if [x-1, y] in self.living_pixel:
            i = i + 1
        if [x-1, y+1] in self.living_pixel:
            i = i + 1
        if [x, y-1] in self.living_pixel:
            i = i + 1
        ##if [x, y] in self.living_pixel:
        ##    i = i + 1
        if [x, y+1] in self.living_pixel:
            i = i + 1
        if [x+1, y-1] in self.living_pixel:
            i = i + 1
        if [x+1, y] in self.living_pixel:
            i = i + 1
        if [x+1, y+1] in self.living_pixel:
            i = i + 1
        return i

a = game_of_life()
3D-Version:

Code: Alles auswählen

import time

class game_of_life:

    def __init__(self, a = 10, b = 10, c = 10, r = 10):
        self.living_pixel = [[3,3,3], [3,4,3], [3,5,3]]
        self.next_gen = []
        x = 1
        y = 1
        z = 1
        i = 1
        t1 = time.time()
        while i < r:
            while x < a:
                while y < b:
                    while z < c:
                        self.check_pixel(x, y, z)
                        z = z + 1
                    z = 1
                    y = y + 1
                y = 1
                x = x + 1
            self.living_pixel = self.next_gen
            self.next_gen = []
            x = 1
            i = i + 1
            #print self.living_pixel
        t2 = time.time()
        #print round(t2 - t1, 5)
        raw_input()

    def check_pixel(self, x, y, z):
        if [x, y, z] in self.living_pixel:
            #print x,y,z,"is a living pixel"
            self.is_living_pixel(x, y, z)
        else:
            #print x,y,z,"is a dead pixel"
            self.is_dead_pixel(x, y, z)

    def is_living_pixel(self, x, y, z):
        neighbours = self.count_neighbours(x, y, z)
        #print x,y,z,"has",neighbours,"neighbours"
        ##if neighbours != 2 and neighbours != 3:
        ##    #print "--> Pixel dies"
        ##    #self.living_pixel.remove([x, y, z])
        ##else:
        ##    self.next_gen.append([x, y, z])
        if neighbours == 2 or neighbours == 3:
            #print "--> Pixel stays alive"
            self.next_gen.append([x, y, z])

    def is_dead_pixel(self, x, y, z):
        neighbours = self.count_neighbours(x, y, z)
        #print x,y,z,"has",neighbours,"neighbours"
        if neighbours == 3:
            #print "--> Pixel spawns"
            self.next_gen.append([x, y, z])

    def count_neighbours(self, x, y, z):
        i = 0
        if [x-1, y-1, z-1] in self.living_pixel:
            i = i + 1
        if [x-1, y-1, z] in self.living_pixel:
            i = i + 1
        if [x-1, y-1, z+1] in self.living_pixel:
            i = i + 1
        if [x-1, y, z-1] in self.living_pixel:
            i = i + 1
        if [x-1, y, z] in self.living_pixel:
            i = i + 1
        if [x-1, y, z+1] in self.living_pixel:
            i = i + 1
        if [x-1, y+1, z-1] in self.living_pixel:
            i = i + 1
        if [x-1, y+1, z] in self.living_pixel:
            i = i + 1
        if [x-1, y+1, z+1] in self.living_pixel:
            i = i + 1
        if [x, y-1, z-1] in self.living_pixel:
            i = i + 1
        if [x, y-1, z] in self.living_pixel:
            i = i + 1
        if [x, y-1, z+1] in self.living_pixel:
            i = i + 1
        if [x, y, z-1] in self.living_pixel:
            i = i + 1
        ##if [x, y, z] in self.living_pixel:
        ##    i = i + 1
        if [x, y, z+1] in self.living_pixel:
            i = i + 1
        if [x, y+1, z-1] in self.living_pixel:
            i = i + 1
        if [x, y+1, z] in self.living_pixel:
            i = i + 1
        if [x, y+1, z+1] in self.living_pixel:
            i = i + 1
        if [x+1, y-1, z-1] in self.living_pixel:
            i = i + 1
        if [x+1, y-1, z] in self.living_pixel:
            i = i + 1
        if [x+1, y-1, z+1] in self.living_pixel:
            i = i + 1
        if [x+1, y, z-1] in self.living_pixel:
            i = i + 1
        if [x+1, y, z] in self.living_pixel:
            i = i + 1
        if [x+1, y, z+1] in self.living_pixel:
            i = i + 1
        if [x+1, y+1, z-1] in self.living_pixel:
            i = i + 1
        if [x+1, y+1, z] in self.living_pixel:
            i = i + 1
        if [x+1, y+1, z+1] in self.living_pixel:
            i = i + 1
        return i

a = game_of_life()
Und jetzt, stürzt euch mal drauf :wink:
Kann man was verbessern?

MfG,
Craven
Y0Gi
User
Beiträge: 1454
Registriert: Freitag 22. September 2006, 23:05
Wohnort: ja

Du könntest z.B. `x = x + 1` durch die Kurzform `x += 1` ersetzen. Zudem kannst du im Rumpf von count_neighbours() vielleicht insgesamt irgendwie generalisieren und dort auch Tupel statt Listen verwenden. Vermutlich lässt sich auch Geschwindigkeit rausholen, wenn du das array-Objekt oder gar ein Paket wie NumPy verwendest.

Oh, auch interessant: http://en.wikipedia.org/wiki/Hashlife
BlackJack

Ich hatte hier schonmal ein GameOfLife gepostet: http://www.python-forum.de/post-16061.html#16061

Das benutzt ein Hash bzw. `set()`, hat aber trotzdem eine feste Grösse wegen der Ausgabe auf dem Bildschirm.
Nirven
User
Beiträge: 130
Registriert: Mittwoch 10. Mai 2006, 08:18
Wohnort: Bremerhaven

Statt

Code: Alles auswählen

...
    def __init__(self, a = 100, b = 100, r = 100):
        i = 1
        while i < r:
            i = i + 1
            ...
würde ich

Code: Alles auswählen

...
    def __init__(self, a = 100, b = 100, r = 100):
        i = 1
        for i in range(r):
            ...
nehmen. Keine Ahnung ob das bessere oder schlechtere Performance bringt, aber wenn ich nichts übersehen habe tut es dasselbe, und ist leichter lesbar. Und du sparst dir das manuelle hochzählen.
Benutzeravatar
Craven
User
Beiträge: 223
Registriert: Dienstag 24. Januar 2006, 13:37

So ich hab die Klasse mal geupdated:

Code: Alles auswählen

import time

class game_of_life:

    def __init__(self, pixel = [], a = 100, b = 100, r = 100):
        self.living_pixel = pixel
        self.next_gen = []

        t1 = time.time()
        for i in range(r):
            for x in range(a):
                for y in range(b):
                    self.check_pixel(x, y)
                y = 1
            self.living_pixel = self.next_gen
            self.next_gen = []
            x = 1
            print self.living_pixel
        t2 = time.time()
        #print round(t2 - t1, 5)
        #raw_input()

    def check_pixel(self, x, y):
        if [x, y] in self.living_pixel:
            #print x,y,"is a living pixel"
            self.is_living_pixel(x, y)
        else:
            #print x,y,"is a dead pixel"
            self.is_dead_pixel(x, y)

    def is_living_pixel(self, x, y):
        neighbours = self.count_neighbours(x, y, 1)
        #print x,y,"has",neighbours,"neighbours"
        ##if neighbours != 2 and neighbours != 3:
        ##    #print "--> Pixel dies"
        ##    #self.living_pixel.remove([x, y])
        ##else:
        ##    self.next_gen.append([x, y])
        if neighbours == 2 or neighbours == 3:
            #print "--> Pixel stays alive"
            self.next_gen.append([x, y])

    def is_dead_pixel(self, x, y):
        neighbours = self.count_neighbours(x, y, 0)
        #print x,y,"has",neighbours,"neighbours"
        if neighbours == 3:
            #print "--> Pixel spawns"
            self.next_gen.append([x, y])

    def count_neighbours(self, x, y, living):
        k = 0
        for i in range(-1, 2):
            for j in range (-1, 2):
                if [x+i, y+j] in self.living_pixel:
                    k += 1
        if living:
            k -= 1
        return k

a = game_of_life([[5,4], [5,5], [5,6]], 10, 10, 10)
Y0Gi hat geschrieben:Zudem kannst du im Rumpf von count_neighbours() vielleicht insgesamt irgendwie generalisieren
Hast du mit generalisieren gemeint, das ich das mit Schleifen mache, so wie es jetzt ist ?

Das Ziel von der Klasse ist es, alles möglichst einfach zu machen. Natürlich könnte ich noch viele Sachen ändern, damit es schneller wird. (zB. Prüf ich ja jetzt, ob JEDER Pixel vl Nachbarn hat, obwohl ich ja eigentlich nur Pixel im Umfeld von schon "lebenden" Pixeln prüfen müsste.) Aber alles sollte möglichst einfach bleiben. Trotzdem vielen Dank für die Tipps.
Benutzeravatar
Craven
User
Beiträge: 223
Registriert: Dienstag 24. Januar 2006, 13:37

Vielleicht hat ja einer von euch Lust/Zeit eine GUI dafür zu machen? Ich kenn mich mit den Grafiksachen nicht aus, aber es wär interessant zu sehen, wie das ausschaut. :wink:
[code]q = 'q = %s; print q %% repr(q)'; print q % repr(q) [/code]
schlangenbeschwörer
User
Beiträge: 419
Registriert: Sonntag 3. September 2006, 15:11
Wohnort: in den weiten von NRW
Kontaktdaten:

Craven hat geschrieben:Vielleicht hat ja einer von euch Lust/Zeit eine GUI dafür zu machen? Ich kenn mich mit den Grafiksachen nicht aus, aber es wär interessant zu sehen, wie das ausschaut. :wink:
Hi Carven!
Ich hatte grad auch was Langeweile, da hab ich mal schnell was zusammengehackt. Ist also nur die Grundaustattung.

Code: Alles auswählen

import time 
import Tkinter as tk

### Optionen vor dem Starten: Pixelfarbe, Feldgröße, Startfigur, Printmodus
BG="green"
Q=30
STARTLIFE=[[9, 10], [16, 9], [16, 8], [17, 7], [18, 7], [19, 8], [20, 9], [19, 10],
           [18, 10], [16, 10], [17, 10], [17, 9], [9, 9], [9, 8], [8, 10], [7, 10], [8, 9],
           [8, 7], [7, 7], [6, 8], [5, 9], [6, 10], [11, 13], [14, 13], [11, 14], [10, 14],
           [10, 13], [14, 14], [15, 14], [15, 13], [8, 18], [9, 19], [10, 20], [12, 20],
           [11, 20], [7, 16], [7, 17], [13, 20], [14, 20], [15, 20], [16, 19], [17, 18],
           [18, 17], [18, 16]]

PRINT="off"

######

class GoLgui:
    def __init__(self,pixel,q):
        self.master=tk.Tk()
        self.master.title("Game of Live")
        
        self.canvas=tk.Canvas(bg="white",height=q*10,width=q*10)
        self.canvas.pack()

        
        for i in range(0,q):
            self.canvas.create_line(0,i,q,i,fill="gray")
            self.canvas.create_line(i,0,i,q,fill="gray")
        self.q=q

        self.canvas.bind("<Any-Button>",self.clicked)
        self.f=tk.Frame()
        self.f.pack()
        self.e=tk.Entry(self.f,width=3)
        self.e.pack(side="left",padx=5)
        self.b=tk.Button(self.f,text="start",command=lambda:self.start(self.e.get()))
        self.b.pack(side="left",padx=5)
        self.gol=game_of_life(pixel,q,q)
        self.printgol()
            
    def start(self,r):
        try:
            r=int(r)
            for i in range(r):
                self.gol.gol_round()
                self.printgol()
        except ValueError:
            print "ERROR: Bitte geben Sie eine grade Zahl ein!"
            
    def printgol(self):
        self.reset()
        for pixel in self.gol.living_pixel:
            x,y=pixel[0], pixel[1]
            self.canvas.create_rectangle(x*10,y*10,x*10+10,y*10+10,fill=BG)
        self.canvas.update()
        if PRINT == "on":
            print self.gol.living_pixel
        
    def reset(self):
        for tk_id in self.canvas.find_all():
            self.canvas.delete(tk_id)
        for i in range(0,self.q):
            self.canvas.create_line(0,i*10,self.q*10,i*10,fill="gray")
            self.canvas.create_line(i*10,0,i*10,self.q*10,fill="gray")

    def clicked(self,event):
        pixel=[int(round (event.x-5, -1))/10,int(round (event.y-5, -1))/10]
        if pixel in self.gol.living_pixel:
            del self.gol.living_pixel[self.gol.living_pixel.index(pixel)]
        else:
            self.gol.living_pixel.append(pixel)
        self.printgol()
    
class game_of_life: 
    def __init__(self, pixel = [], a = 100, b = 100): 
        self.living_pixel = pixel 
        self.next_gen = []
        self.a,self.b=a,b

    def gol_round (self):
        for x in range(self.a):
            for y in range(self.b):
                self.check_pixel(x, y)
                y = 1
        self.living_pixel = self.next_gen
        self.next_gen = []
        x = 1

    def check_pixel(self, x, y): 
        if [x, y] in self.living_pixel: 
            #print x,y,"is a living pixel" 
            self.is_living_pixel(x, y) 
        else: 
            #print x,y,"is a dead pixel" 
            self.is_dead_pixel(x, y) 

    def is_living_pixel(self, x, y): 
        neighbours = self.count_neighbours(x, y, 1) 
        #print x,y,"has",neighbours,"neighbours" 
        ##if neighbours != 2 and neighbours != 3: 
        ##    #print "--> Pixel dies" 
        ##    #self.living_pixel.remove([x, y]) 
        ##else: 
        ##    self.next_gen.append([x, y]) 
        if neighbours == 2 or neighbours == 3: 
            #print "--> Pixel stays alive" 
            self.next_gen.append([x, y]) 

    def is_dead_pixel(self, x, y): 
        neighbours = self.count_neighbours(x, y, 0) 
        #print x,y,"has",neighbours,"neighbours" 
        if neighbours == 3: 
            #print "--> Pixel spawns" 
            self.next_gen.append([x, y]) 

    def count_neighbours(self, x, y, living): 
        k = 0 
        for i in range(-1, 2): 
            for j in range (-1, 2): 
                if [x+i, y+j] in self.living_pixel: 
                    k += 1 
        if living: 
            k -= 1 
        return k 

myGOL=GoLgui(STARTLIFE, Q)
myGOL.master.mainloop()
Und stimmt, sieht lustig aus 8)

Gruß, jj

edit: Hier noch ein schöner Link zum Thema.
Benutzeravatar
Craven
User
Beiträge: 223
Registriert: Dienstag 24. Januar 2006, 13:37

Hi Schlangenbeschwörer,

Danke, für die Arbeit :wink:
Das sieht echt gut aus. Jetzt interessiert mich noch die 3D Version :lol:
Aber das dürfte um einiges komplizierter werden :wink:

Mit was könnte man das realisieren? Irgendwelche Ideen?

MfG,
Craven
[code]q = 'q = %s; print q %% repr(q)'; print q % repr(q) [/code]
schlangenbeschwörer
User
Beiträge: 419
Registriert: Sonntag 3. September 2006, 15:11
Wohnort: in den weiten von NRW
Kontaktdaten:

Hi Carven!
Über eine 3D Version hab ich auch schon nachgedacht, das Problem ist nur, das man das, selbst wenn man es in 3D programmiert, was jedoch schwierig genug werden dürfte, wird man es optisch nicht wahrnehmen können, oder nur sehr schwer/wenig. Stell dir einen 3D Würfel vor, wo ständig irgendwelche Punkte erscheinen und verschwinden.
Aber ich hab da grad sonne Idee....
Ich probier mal was aus. Vlt. gibts ja doch was. :wink:
Gruß, jj
schlangenbeschwörer
User
Beiträge: 419
Registriert: Sonntag 3. September 2006, 15:11
Wohnort: in den weiten von NRW
Kontaktdaten:

So, hab mal die beiden Scripte zusammengeprügelt.
Carven hat geschrieben:Lasst mich dazusagen, dass es ziemlich viel Leistung braucht ...
...Und das hier erst...

Ich hatte keine Lust, den Urcode zu verbessern, also hab ich meinen Stil angepasst... :wink:

Code: Alles auswählen

import time 
import Tkinter as tk 

### Optionen vor dem Starten: Pixelfarbe, Feldgroesse, Startfigur, Printmodus 
BG="green" 
Q=10
STARTLIFE=[[3,3,3], [3,4,3], [3,5,3]] 

PRINT="off" 

###### 

class GoLgui3D: 
    def __init__(self,q=Q): 
        self.master=tk.Tk() 
        self.master.title("Game of Live") 
        self.canvases=[]
        self.c1=tk.Canvas(bg="white",height=q*10,width=q*10) 
        self.c1.pack()
        self.c2=tk.Canvas(bg="white",height=q*10,width=q*10) 
        self.c2.pack()
        self.c3=tk.Canvas(bg="white",height=q*10,width=q*10) 
        self.c3.pack()        

        
        for c in (self.c1,self.c2,self.c3):
            for i in range(0,q):
                c.create_line(0,i*10,q*10,i*10,fill="gray")
                c.create_line(i*10,0,i*10,q*10,fill="gray") 
        self.q=q 

        self.f=tk.Frame() 
        self.f.pack() 
        self.e=tk.Entry(self.f,width=3) 
        self.e.pack(side="left",padx=5) 
        self.b=tk.Button(self.f,text="start",command=lambda:self.start(self.e.get())) 
        self.b.pack(side="left",padx=5) 
        self.gol=game_of_life(q,q,q) 
        self.printgol() 
            
    def start(self,r): 
        try: 
            r=int(r) 
            for i in range(r): 
                self.gol.gol_round() 
                self.printgol() 
        except ValueError: 
            print "ERROR: Bitte geben Sie eine grade Zahl ein!" 
            
    def printgol(self): 
        self.reset() 
        for pixel in self.gol.living_pixel: 
            x,y,z=pixel[0], pixel[1], pixel[2]
            self.c1.create_rectangle(x*10,y*10,x*10+10,y*10+10,fill=BG)
            self.c2.create_rectangle(y*10,z*10,y*10+10,z*10+10,fill=BG)
            self.c3.create_rectangle(z*10,x*10,z*10+10,x*10+10,fill=BG)             
        for c in (self.c1,self.c2,self.c3):
            c.update() 
        if PRINT == "on": 
            print self.gol.living_pixel 
        
    def reset(self):
        for c in (self.c1,self.c2,self.c3):
            for tk_id in c.find_all():
                c.delete(tk_id) 
            for i in range(0,Q):
                c.create_line(0,i*10,Q*10,i*10,fill="gray")
                c.create_line(i*10,0,i*10,Q*10,fill="gray") 

class game_of_life: 

    def __init__(self, a = 10, b = 10, c = 10): 
        self.living_pixel = STARTLIFE
        self.next_gen = []
        self.a,self.b,self.c=a,b,c

    def gol_round(self):
        x = 1 
        y = 1 
        z = 1 
        while x < self.a: 
                while y < self.b: 
                    while z < self.c: 
                        self.check_pixel(x, y, z) 
                        z = z + 1 
                    z = 1 
                    y = y + 1 
                y = 1 
                x = x + 1 
        self.living_pixel = self.next_gen 
        self.next_gen = [] 
        x = 1 
            #print self.living_pixel 
        #print round(t2 - t1, 5) 

    def check_pixel(self, x, y, z): 
        if [x, y, z] in self.living_pixel: 
            #print x,y,z,"is a living pixel" 
            self.is_living_pixel(x, y, z) 
        else: 
            #print x,y,z,"is a dead pixel" 
            self.is_dead_pixel(x, y, z) 

    def is_living_pixel(self, x, y, z): 
        neighbours = self.count_neighbours(x, y, z) 
        #print x,y,z,"has",neighbours,"neighbours" 
        ##if neighbours != 2 and neighbours != 3: 
        ##    #print "--> Pixel dies" 
        ##    #self.living_pixel.remove([x, y, z]) 
        ##else: 
        ##    self.next_gen.append([x, y, z]) 
        if neighbours == 2 or neighbours == 3: 
            #print "--> Pixel stays alive" 
            self.next_gen.append([x, y, z]) 

    def is_dead_pixel(self, x, y, z): 
        neighbours = self.count_neighbours(x, y, z) 
        #print x,y,z,"has",neighbours,"neighbours" 
        if neighbours == 3: 
            #print "--> Pixel spawns" 
            self.next_gen.append([x, y, z]) 

    def count_neighbours(self, x, y, z): 
        i = 0 
        if [x-1, y-1, z-1] in self.living_pixel: 
            i = i + 1 
        if [x-1, y-1, z] in self.living_pixel: 
            i = i + 1 
        if [x-1, y-1, z+1] in self.living_pixel: 
            i = i + 1 
        if [x-1, y, z-1] in self.living_pixel: 
            i = i + 1 
        if [x-1, y, z] in self.living_pixel: 
            i = i + 1 
        if [x-1, y, z+1] in self.living_pixel: 
            i = i + 1 
        if [x-1, y+1, z-1] in self.living_pixel: 
            i = i + 1 
        if [x-1, y+1, z] in self.living_pixel: 
            i = i + 1 
        if [x-1, y+1, z+1] in self.living_pixel: 
            i = i + 1 
        if [x, y-1, z-1] in self.living_pixel: 
            i = i + 1 
        if [x, y-1, z] in self.living_pixel: 
            i = i + 1 
        if [x, y-1, z+1] in self.living_pixel: 
            i = i + 1 
        if [x, y, z-1] in self.living_pixel: 
            i = i + 1 
        ##if [x, y, z] in self.living_pixel: 
        ##    i = i + 1 
        if [x, y, z+1] in self.living_pixel: 
            i = i + 1 
        if [x, y+1, z-1] in self.living_pixel: 
            i = i + 1 
        if [x, y+1, z] in self.living_pixel: 
            i = i + 1 
        if [x, y+1, z+1] in self.living_pixel: 
            i = i + 1 
        if [x+1, y-1, z-1] in self.living_pixel: 
            i = i + 1 
        if [x+1, y-1, z] in self.living_pixel: 
            i = i + 1 
        if [x+1, y-1, z+1] in self.living_pixel: 
            i = i + 1 
        if [x+1, y, z-1] in self.living_pixel: 
            i = i + 1 
        if [x+1, y, z] in self.living_pixel: 
            i = i + 1 
        if [x+1, y, z+1] in self.living_pixel: 
            i = i + 1 
        if [x+1, y+1, z-1] in self.living_pixel: 
            i = i + 1 
        if [x+1, y+1, z] in self.living_pixel: 
            i = i + 1 
        if [x+1, y+1, z+1] in self.living_pixel: 
            i = i + 1 
        return i 


GoLgui3D().master.mainloop()
So, das sind die 3 Dimensionen, sich die zusammenzudenken ist jetzt die Aufgbe des kreativen Betrachters. Es sieht zwar auch funny aus, aber die 2D Version mit q=100 find ich schöner, zumal bei der 3D Version keine Eingabe über das Canvas, sondern nur noch über den Code möglich ist.

Gruß, jj
Antworten