[英]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 我正在使用
r=2
Von Neumann社区, 如下所示
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]
. 例如:我有一个数组
a
,我想计算a[0][0]
。
States of cells are floats in range of (-1,1) where 0 is land. 单元格的状态是(-1,1)范围内的浮点数,其中0是陆地。 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.
在“常规”单元上,我可以采用邻居状态,但是当邻居较少(<12)时,结果就是错误的,并“产生”了新的浪潮。
There are different solutions to your problem. 您的问题有不同的解决方案。
Example: a[-1][0] = a[n-2][0] 例如: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. 示例:a [-1] [0] = 10e-6左右,因为0表示降落。
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 (eg a maëlstrom-like pattern?) or simply presenting a system that looks organic for an observer. 这种方法更适合用于定性用途:检查实现的有效性,查找模型伪像(例如,类似maëlstrom的模式?)或只是为观察者提供一个看起来有机的系统。
Example : All border cells are land (0). 示例:所有边界单元格均为陆地(0)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.