Exemplo n.º 1
0
        public void RefreshCells()
        {
            List <MyCell> cells = new List <MyCell>();

            foreach (MyCell myCell in MyCells)
            {
                cells.Add(new MyCell(myCell));
            }

            for (int i = 0; i < MyCells.Count; ++i)
            {
                int countLife = cells[i].CountLivingNeighbors(MyCells);

                if (!cells[i].Life && (countLife >= Setting.MinBorn && countLife <= Setting.MaxBorn))
                {
                    cells[i].Life = true;
                }
                else if (cells[i].Life)
                {
                    if (countLife < Setting.MinAlive || countLife > Setting.MaxAlive)
                    {
                        cells[i].Life = false;
                    }
                }
            }


            MyCells.Clear();

            foreach (MyCell myCell in cells)
            {
                MyCells.Add(myCell);
            }
        }
Exemplo n.º 2
0
        public void RandFilling()
        {
            MyCells.Clear();
            Random random = new Random();

            for (int i = 0; i < Setting.FieldRow; ++i)
            {
                for (int j = 0; j < Setting.FieldColumn; ++j)
                {
                    MyCells.Add(new MyCell((random.Next(-80, 19) < 0 ? false : true)));
                }
            }

            RegistrationOfNeighbors();
        }