A better way to chose a random neighbor

Thanks! is there an example of how to implement ghost cells?

Anyways that would work for closest neighbours if I have a function that gives a random position with an arbitrary maximum distance e.g.


 x=(i,j) .+  rand_max_distance(fil)

will be more difficult to avoid boundary checks, and something similar would happen with periodic boundary conditions, you would need to use getindex(a, i) = a.a[i % n] as you suggested to avoid in Arrays with periodic boundaries - #4 by stevengj