Fixed an issue with the grid taking over the whole screen due to bad logic
This commit is contained in:
1 parent
78493fda53
commit
069686c84d
2 files changed
+7
-9
No files matched your search
Binary file not shown.
+7
-9
@@ -220,24 +220,22 @@ def game():
|
|||||||
neighbors += GRID[ny,nx]
|
neighbors += GRID[ny,nx]
|
||||||
|
|
||||||
#Apply rules
|
#Apply rules
|
||||||
#If nlimit neighbors persist
|
#If nlimit neighbors persist if alive
|
||||||
if neighbors == nlimit - 1:
|
if neighbors == nlimit - 1 and GRID[y,x]:
|
||||||
NEXT[y,x] = True
|
NEXT[y,x] = True
|
||||||
|
|
||||||
#if nlimit neighbors lives if dead (repop)
|
#if nlimit neighbors lives if dead (repop)
|
||||||
if neighbors == nlimit and not GRID[y,x]:
|
if neighbors == nlimit and not GRID[y,x]:
|
||||||
NEXT[y,x] = True
|
NEXT[y,x] = True
|
||||||
|
|
||||||
# Random play around
|
#if nlimit neighbors randomly lives or dies if alive (repop / overpop)
|
||||||
#if nlimit neighbors randomly lives or dies if alive
|
|
||||||
if neighbors == nlimit and GRID[y,x]:
|
if neighbors == nlimit and GRID[y,x]:
|
||||||
rand.seed(rand.random())
|
rx = (x + rand.randint(-1,1)) % GRID_W
|
||||||
rx = rand.randint(-1,1)
|
ry = (y + rand.randint(-1,1)) % GRID_H
|
||||||
ry = rand.randint(-1,1)
|
NEXT[ry,rx] = rand.randint(0, 1)
|
||||||
NEXT[ry,rx] = rand.randint(0,1)
|
|
||||||
|
|
||||||
#if >nlimit dies (overpop)
|
#if >nlimit dies (overpop)
|
||||||
if neighbors > 3:
|
if neighbors > nlimit or neighbors < (nlimit - 1):
|
||||||
NEXT[y,x] = False
|
NEXT[y,x] = False
|
||||||
|
|
||||||
GRID[:] = NEXT
|
GRID[:] = NEXT
|
||||||
|
|||||||
Reference in new issue
Block a user