Skip to content

Instantly share code, notes, and snippets.

@njbbaer
njbbaer / ca.py
Last active October 27, 2022 18:05
Fast implementation of cellular automata using 2D convolution
import time
import numpy as np
from numpy.fft import fft2, ifft2
from matplotlib import pyplot, animation
def fft_convolve2d(board, kernal):
board_ft = fft2(board)
kernal_ft = fft2(kernal)
height, width = board_ft.shape