A better way to chose a random neighbor

This allocates an array [i,j] on every iteration. Better to use a tuple (i,j) .+ rand(neighborhood).

I would usually recommend employing ghost cells to avoid these kinds of boundary checks in inner loops.

2 Likes