小编Rob*_*ten的帖子

生命游戏算法问题

我正在用C#编写一个生命游戏程序.我正在使用2D数组结构.似乎当我显示Random方法时,邻居或某事的算法是错误的.当它经历了几代人时,随机细胞就会变得"活着".有帮助吗?

public struct cellDetail
{
    public int curGenStatus;
    public int nextGenStatus;
    public int age;

}
public class Class1
{

    static cellDetail[,] Generations(cellDetail[,] cells)
    {

        int neighbours = 0;

        for (int i = 0; i < 40; i++)
            for (int j = 0; j < 60; j++)
                cells[i, j].nextGenStatus = 0;

        for (int row = 0; row < 39; row++)
            for (int col = 0; col < 59; col++)
            {
                neighbours = 0;

                if (row > 0 && col > 0) …
Run Code Online (Sandbox Code Playgroud)

c#

0
推荐指数
1
解决办法
895
查看次数

标签 统计

c# ×1