custon rules
This commit is contained in:
parent
728f655e11
commit
f54d31a2dc
2 changed files with 23 additions and 31 deletions
7
main.py
7
main.py
|
@ -52,6 +52,7 @@ def finde_nachbarn(x, y):
|
||||||
return [ovl, ov, ovr, r, l, bel, be, ber]
|
return [ovl, ov, ovr, r, l, bel, be, ber]
|
||||||
|
|
||||||
|
|
||||||
|
## Funktion zum Verarbeiten des Feldes
|
||||||
def verarbeite_feld(feld):
|
def verarbeite_feld(feld):
|
||||||
feldx, feldy = len(feld[0]), len(feld) # bekomme feld größe
|
feldx, feldy = len(feld[0]), len(feld) # bekomme feld größe
|
||||||
feld2 = copy.deepcopy(feld) # mache neue kopie
|
feld2 = copy.deepcopy(feld) # mache neue kopie
|
||||||
|
@ -61,14 +62,10 @@ def verarbeite_feld(feld):
|
||||||
for pos in finde_nachbarn(x, y):
|
for pos in finde_nachbarn(x, y):
|
||||||
if feld[pos[0]][pos[1]]:
|
if feld[pos[0]][pos[1]]:
|
||||||
lives += 1
|
lives += 1
|
||||||
new = pixel(feld[y][x], lives)
|
feld2[y][x] = pixel(feld[y][x], str(lives))
|
||||||
feld2[y][x] = new
|
|
||||||
return feld2 # gib kopie zurück
|
return feld2 # gib kopie zurück
|
||||||
|
|
||||||
|
|
||||||
## Funktion zum Verarbeiten des Feldes
|
|
||||||
|
|
||||||
|
|
||||||
def make_feld(size, rand):
|
def make_feld(size, rand):
|
||||||
x = screensize[0] // size
|
x = screensize[0] // size
|
||||||
y = screensize[1] // size
|
y = screensize[1] // size
|
||||||
|
|
47
rules.py
47
rules.py
|
@ -1,32 +1,27 @@
|
||||||
rules =[
|
# rule = "12345/3" # Labyrinth
|
||||||
# 0 1 2 3 4 5 6 7 8
|
# rule = "23/3" # Conway
|
||||||
#[False,False,False,True ,False,False,False,False,False], #geburt
|
# rule = "01234678/0123478" # Anti Conway
|
||||||
#[True ,True ,False,False,True ,True ,True ,True ,True ] #tot
|
rule = "87654/8765" # Wobbl World
|
||||||
# 23/3
|
|
||||||
# bei 2 und 3 überleb
|
|
||||||
# bei 3 geburt
|
# a/b
|
||||||
[False,False,False,True ,False,False,False,False,False], #geburt
|
# a = bei Anzahl von ... Nachbaren bleib lebendig
|
||||||
[False,True ,True ,True ,True ,True ,False,False,False]
|
# b = bei Anzahl von ... Nachbaren werde lebendig
|
||||||
#tot
|
|
||||||
#12345/3
|
|
||||||
]
|
rule = rule.split("/")
|
||||||
#rules = ([1,2,3,4,5],[3])
|
|
||||||
rules = ([2,3],[3])
|
|
||||||
|
|
||||||
def pixel(state, lives):
|
def pixel(state, lives):
|
||||||
if lives in rules[1] and state == True:
|
if state:
|
||||||
|
if lives in rule[0]:
|
||||||
# fals überleben soll
|
# fals überleben soll
|
||||||
return True
|
return True
|
||||||
## .....
|
|
||||||
if lives in rules[1] and state == True:
|
|
||||||
# uberlebe
|
|
||||||
return True
|
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
#return new
|
else:
|
||||||
#if rules[0][lives] == False and rules[1][lives] == True: # soll überhaupt nix geschehen
|
if lives in rule[1]:
|
||||||
# return state
|
# geburt
|
||||||
#if rules[0][lives] == True: # wird geboren
|
return True
|
||||||
# return True
|
else:
|
||||||
#elif rules[1][lives] == True: # soll nix geschehen wen tot
|
return False
|
||||||
# return state
|
|
||||||
|
|
Loading…
Reference in a new issue