fun fact: I started programming with p5.js, and this donut.c remake was my first cool project.


Parallelized Lenia

Lenia written with CUDA kernels.

Lenia is a very sensible continuation of Conway’s Game of Life, extending the possible states of a single cell to the rationals in the range [0, 1].

You can check out the original paper for more details, it’s pretty short, and contains a lot of cool emergent phenomena.

DEFINITELY watch this, which started it all for me: Lenia: Expanded Universe 1080p.

text, text, text…

__device__ void convolution(double *C, double *kernel, int i, int j, double *result , double kernelMax) {
    int kernelSize = 2 * RADIUS + 1;
    double sum = 0.0;
    for (int ki = -RADIUS; ki <= RADIUS; ki++) {
        for (int kj = -RADIUS; kj <= RADIUS; kj++) {
            int ni = i + ki;
            int nj = j + kj;
            if (ni >= 0 && ni < N && nj >= 0 && nj < N) {
                sum += C[ni * N + nj] * kernel[(ki + RADIUS) * kernelSize + (kj + RADIUS)];
            }
        }
    }
    *result = sum / kernelMax;
}