summaryrefslogtreecommitdiff
path: root/2d_automata.py
diff options
context:
space:
mode:
Diffstat (limited to '2d_automata.py')
-rw-r--r--2d_automata.py13
1 files changed, 9 insertions, 4 deletions
diff --git a/2d_automata.py b/2d_automata.py
index d27b536..0ef55c2 100644
--- a/2d_automata.py
+++ b/2d_automata.py
@@ -8,17 +8,22 @@ import time
screen_width = 1000
screen_height = 1000
-pr.init_window(screen_width, screen_height, "Hello")
+sleep_time = .5
+
+pr.init_window(screen_width, screen_height, "Game of Life")
cols = 20
rows = 20
grid = np.random.randint(2, size=(rows, cols))
+
+# Single glider grid
# grid = np.zeros((100, 100))
# grid[0][1] = 1
# grid[1][2] = 1
# grid[2][0] = 1
# grid[2][1] = 1
# grid[2][2] = 1
+
# grid = np.array([[1, 0, 0, 1], [1, 0, 1, 1], [1, 0, 0, 1], [0, 0, 1, 1]])
@@ -31,9 +36,9 @@ def draw_game(grid):
x = 0
for j in i:
if j == 1:
- pr.draw_rectangle(x, y, col_space, row_space, pr.BLACK)
+ pr.draw_rectangle(x, y, col_space, row_space, pr.DARKGRAY)
else:
- pr.draw_rectangle(x, y, col_space, row_space, pr.WHITE)
+ pr.draw_rectangle(x, y, col_space, row_space, pr.LIGHTGRAY)
x += col_space
y += row_space
@@ -114,6 +119,6 @@ while not pr.window_should_close():
draw_game(grid)
pr.end_drawing()
- time.sleep(.5)
+ time.sleep(sleep_time)
first_iter = False
pr.close_window()