WIP
This commit is contained in:
parent
fdb3c60f1e
commit
43981fc3af
|
@ -0,0 +1,45 @@
|
|||
from casioplot import *
|
||||
from random import randint
|
||||
|
||||
C_BLACK = (0, 0, 0)
|
||||
def draw_mat(mat):
|
||||
clear_screen()
|
||||
x = 0
|
||||
y = 0
|
||||
for line in mat:
|
||||
for cell in line:
|
||||
if cell:
|
||||
set_pixel(x, y, C_BLACK)
|
||||
x += 1
|
||||
x = 0
|
||||
y += 1
|
||||
show_screen()
|
||||
|
||||
|
||||
mat_height = 64
|
||||
mat_width = 128
|
||||
mat = [[0 for _ in range(mat_width)] for _ in range(mat_height)]
|
||||
mat[0][0] = 1
|
||||
mat[0][1] = 1
|
||||
mat[0][2] = 1
|
||||
mat[0][3] = 1
|
||||
while True:
|
||||
draw_mat(mat)
|
||||
mat_rem = mat
|
||||
for y in range(mat_height):
|
||||
for x in range(mat_width):
|
||||
state = mat_rem[y][x]
|
||||
count = -state
|
||||
for i in range(-1, 2):
|
||||
for j in range(-1, 2):
|
||||
p_x, p_y = x + i, y + j
|
||||
if p_x == mat_width:
|
||||
p_x = 0
|
||||
if p_y == mat_height:
|
||||
p_y = 0
|
||||
count += mat_rem[p_y][p_x]
|
||||
if (state and count in (2, 3)) or ((not state) and count == 3):
|
||||
state = 1
|
||||
else:
|
||||
state = 0
|
||||
mat[y][x] = state
|
Loading…
Reference in New Issue