使用 APL 迭代初始的 N x N 生命游戏时,为什么要创建”邻域”?

huangapple go评论76阅读模式
英文:

Why create surrounding "neighborhoods" when using APL to iterate through the initial N by N game of life

问题

看起来,添加额外的活细胞和死细胞会改变原始的“邻域”如何在各代中发展。

当我将生命游戏规则应用于初始的N乘N数组时,经过各代后的结果与将初始数组周围围绕8个反转/转置数组后的结果相比,差异很大。

英文:

It seems that adding extra live and dead cells changes how the original "neighborhood" would progress through the generations.

When I apply the game of life rules to the initial N by N array, I get much different results going thru the generations than I get after surrounding the initial array with 8 reversed/transposed arrays.

答案1

得分: 0

不管细胞是在下一代中是活着还是死了,都取决于其Moore邻居中活细胞的确切数量。对于边缘的细胞,你要怎么处理呢?如果你只是计算现有邻居位置中的活细胞数量,那么你实际上会将缺失的位置(在数组之外)视为死细胞,这会产生明显的影响。替代方法包括但不限于,将其包裹到相对边缘或在边缘进行镜像处理,但无论如何,你都需要做出选择。

dfns工作区包括关于生命游戏的注释,其中解释、说明和实现了许多这样的选项。

英文:

Whether a cell is alive or dead in the next generation, depends on the exact number of live cells in its Moore neighbourhood. What do you do with cells at the edges? If you just count the live cells in the existing neighbour positions, you effectively count the missing positions (outside the array) as being dead, which has a noticable effect. Alternatives include, but are not limited to, wrapping around to the opposite edge, and mirroring in the edge, but either way, you have a choice to make.

The dfns workspace includes notes on the Game of Life which explains, illustrates, and implements many such options.

huangapple
  • 本文由 发表于 2023年2月16日 04:11:50
  • 转载请务必保留本文链接:https://go.coder-hub.com/75465002.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定