元胞自动机的实现

发布于 2024-10-22 03:07:04 字数 34 浏览 5 评论 0原文

有人知道如何用 Java 或 C# 实现元胞自动机吗?

Does anybody know how to implement cellular automata in Java or C#?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

若有似无的小暗淡 2024-10-29 03:07:04

我编写了一个伪代码实现,您可以使用它来编写 .NET 实现:

function automate(cells,bornlist,survivelist,iterations)
{
    loop(iterations)
    {
        loop(row < height)
        {
            loop(collumn < width)
            {
                if(is edge)
                {
                    alive = true
                }
                else
                {
                    num = add states of all cells around the outside (if in 3d     include above and below and use less iterations)
                    state = cells[row,collumn]
                    alive = (state = 0 and bornlist.contains(num)) or (state = 1     and survivelist.contains(num))
                }

                cells[row,collumn] = alive ? 1 : 0
            }
        }
    }
}

这依赖于单元格已使用随机值初始化的事实
由诸如 Simplex 或 Perlin 噪声之类的噪声发生器产生。

I have write a Pseudo-Code implementation that you can use to write a .NET implementation:

function automate(cells,bornlist,survivelist,iterations)
{
    loop(iterations)
    {
        loop(row < height)
        {
            loop(collumn < width)
            {
                if(is edge)
                {
                    alive = true
                }
                else
                {
                    num = add states of all cells around the outside (if in 3d     include above and below and use less iterations)
                    state = cells[row,collumn]
                    alive = (state = 0 and bornlist.contains(num)) or (state = 1     and survivelist.contains(num))
                }

                cells[row,collumn] = alive ? 1 : 0
            }
        }
    }
}

This relies on the fact that the cells have already been initialised with a random value
by a noise generator such a Simplex or Perlin noise.

云之铃。 2024-10-29 03:07:04

我们需要更多信息,例如您遇到了哪些问题、困难等。同时,
以下是一些可以帮助您的链接:

http://www.primaryobjects.com/CMS/Article106.aspx

http://cplus.about.com/b/2008/08/17/programming-challenge-17-implement-the-cellular-automaton-known-as-life.htm

https://web.archive.org/web/20110503020104/http://www.kim-team.com/blog/2009/06/cellular-automaton-in-net/

编辑:谢谢哈利勒,我已编辑答案以包含 web.archive.org 链接。

We need more info, like, what issues have you encountered, difficulties, etc. In the meantime,
here are some links to help you:

http://www.primaryobjects.com/CMS/Article106.aspx

http://cplus.about.com/b/2008/08/17/programming-challenge-17-implement-the-cellular-automaton-known-as-life.htm

https://web.archive.org/web/20110503020104/http://www.kim-team.com/blog/2009/06/cellular-automaton-in-net/

Edit: thanks Halil, I've edited the answer to include web.archive.org link.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文