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