summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNiclas Dobbertin <niclas.dobbertin@mailbox.org>2026-07-14 23:24:29 +0200
committerNiclas Dobbertin <niclas.dobbertin@mailbox.org>2026-07-14 23:24:29 +0200
commitc22fb4b41fc3de41f27b0f66431127dab74e0624 (patch)
treee3647b28a40ca2470a01d550e0cbd7c2a7bd051f
parent0d707d4ffb2727584791260cf0ad0cdc36b3ee03 (diff)
bit prettierHEADmaster
-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()