GoL/rules.py

28 lines
589 B
Python
Raw Permalink Normal View History

2024-02-29 14:47:37 +01:00
# 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("/")
2024-02-28 21:39:47 +01:00
2024-02-28 19:47:39 +01:00
def pixel(state, lives):
2024-02-29 14:47:37 +01:00
if state:
if lives in rule[0]:
2024-02-28 21:39:47 +01:00
# fals überleben soll
return True
2024-02-29 14:47:37 +01:00
else:
return False
else:
if lives in rule[1]:
# geburt
2024-02-28 21:39:47 +01:00
return True
2024-02-28 19:47:39 +01:00
else:
2024-02-28 21:39:47 +01:00
return False