From c22fb4b41fc3de41f27b0f66431127dab74e0624 Mon Sep 17 00:00:00 2001 From: Niclas Dobbertin Date: Tue, 14 Jul 2026 23:24:29 +0200 Subject: bit prettier --- 2d_automata.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to '2d_automata.py') 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() -- cgit v1.2.3