7 ms·
I have a minimalistic one (7 lines in Python) using convolutions: https://c0stya.github.io/articles/game_of_life.html https://c0stya.github.io/articles/game_of
by c0nstantine 2y ago
I have a minimalistic one (7 lines in Python) using convolutions:
https://c0stya.github.io/articles/game_of_life.html https://c0stya.github.io/articles/game_of_life.html
### The code ###
import numpy as np
from scipy.signal import convolve2d
field = np.random.randint(0, 2, size=(100, 100)) # 100x100 field size
kernel = np.ones((3, 3))
for i in range(1000): # 1000 steps
new_field = convolve2d(field, kernel, mode="same")
field = (new_field == 3) + (new_field == 4) * field
- jononor 2y agoThat is fabulous! As a DSP/ML guy, this is a contender for my favorite so far.