Nevaan
Nevaan

Reputation: 129

Cellular automata - what to do on boundary cell?

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

Answers (1)

OB1
OB1

Reputation: 376

There are different solutions to your problem.

  1. Periodic boundary condition : consider the lattice as a torus and use a modulo to loop your cells.

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..

  1. Inert boundary condition : consider the border of your lattice to have an absorbing rule, that is, they simulate "external" cells which always have the same inert states.

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.

  1. Be creative ...

Example : All border cells are land (0).

Upvotes: 3

Related Questions