Jun-13-2019, 09:37 AM
Game of Life neighbors calculation can be done like a 2D convolution in machine learning.
I assume it to be the fastest way imho.
I assume it to be the fastest way imho.
import numpy as np from scipy.signal import convolve2d size = 10, 10 table = np.random.randint(0, 2, size=size).astype(np.uint8) print(table) kernel = np.array([[1,1,1],[1,0,1],[1,1,1]]).astype(np.uint8) print(kernel) neighbors = convolve2d(table, kernel, 'same') print(neighbors)