Questions tagged «conways-game-of-life»

24
Code Golf:康威的人生游戏
已锁定。该问题及其答案被锁定,因为该问题是题外话,但具有历史意义。它目前不接受新的答案或互动。 挑战:编写实现John H. Conway的Game of Life细胞自动机的最短程序。[链接] 编辑:经过对竞争的一个星期,我选择了一个胜利者:pdehaan,管理由击败了Matlab解决一个字符用Perl。 对于那些还没有听说过“生命游戏”的人,您可以选择一个正方形的网格(理想情况下是无限个)。细胞可以是活的(填充的)或死亡的(空的)。通过应用以下规则,我们可以确定在下一个步骤中哪些细胞仍然存在: 任何具有少于两个活邻居的活细胞都会死亡,好像是由于人口不足造成的。 任何具有三个以上活邻居的活细胞都会死亡,就像人满为患一样。 任何有两个或三个活邻居的活细胞都可以存活到下一代。 具有正好三个活邻居的任何死细胞都将变成活细胞,就像通过繁殖一样。 您的程序将读取指定为命令行参数的40x80字符的ASCII文本文件,以及要执行的迭代次数(N)。最后,它将在N次迭代后将系统状态输出到ASCII文件out.txt。 这是运行相关文件的示例: in.txt: ................................................................................ ................................................................................ ................................................................................ ................................................................................ ................................................................................ ................................................................................ ................................................................................ ................................................................................ ................................................................................ ................................................................................ ................................................................................ ................................................................................ ..................................XX............................................ ..................................X............................................. .......................................X........................................ ................................XXXXXX.X........................................ ................................X............................................... .................................XX.XX...XX..................................... ..................................X.X....X.X.................................... ..................................X.X......X.................................... ...................................X.......XX................................... ................................................................................ ................................................................................ ................................................................................ ................................................................................ ................................................................................ ................................................................................ ................................................................................ ................................................................................ ................................................................................ ................................................................................ ................................................................................ ................................................................................ ................................................................................ ................................................................................ …
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.