Reputation: 129
I'm trying to implement a cellular automata simulating wave behaviour. I'm using Von Neumann neighbourhood with r=2
like here
My question is: How should I count state of the cell on the boundary?
For example: I'm having an array a
, and I want to count value of a[0][0]
.
States of cells are floats in range of (-1,1) where 0 is land. On "regular" cells I can take states of neighbours, but when there are fewer neighbours (<12) the result is just wrong, and "generates" a new wave.
Upvotes: 0
Views: 838
Reputation: 376
There are different solutions to your problem.
Example: a[-1][0] = a[n-2][0]
Good side: this avoid any "border-effect" by making the lattice invariant by translation, which should lead to a more natural evolution. Bad side: at smaller scales, this can have undesired effects such as resonance.
This approach is particularly suitable if you wanna do a quantitative study of your model, such as phase transition, mean-field, etc..
Example: a[-1][0] = 10e-6 or so because 0 means land.
Good side: you avoid resonance effects. Bad side: potentially border-effects, as well as the absence of external source of waves.
This approach is better-suited for qualitative uses: checking the validity of your implementation, looking for model artefacts (e.g. a maëlstrom-like pattern?) or simply presenting a system that looks organic for an observer.
Example : All border cells are land (0).
Upvotes: 3