Пример #1
0
        public void GotoNextGen()
        {
            ToroidalZone <bool> newField = new ToroidalZone <bool>(MaxFieldSize, MaxFieldSize);

            Array.Copy(Field.Zone, newField.Zone, MaxFieldSize * MaxFieldSize);
            for (int i = 0; i < MaxFieldSize; i++)
            {
                for (int j = 0; j < MaxFieldSize; j++)
                {
                    int neighbours = CountNeighbours(i, j);
                    if (Field[i, j])
                    {
                        if (neighbours < 2 || neighbours > 3)
                        {
                            newField[i, j] = false;
                        }
                    }
                    else
                    {
                        if (neighbours == 3)
                        {
                            newField[i, j] = true;
                        }
                    }
                }
            }
            Field = newField;
        }
Пример #2
0
 public ToroidalGameOfLife(int maxFieldSize)
 {
     MaxFieldSize = maxFieldSize;
     Field        = new ToroidalZone <bool>(maxFieldSize, maxFieldSize);
 }