Пример #1
0
 public void GrowGrains()
 {
     for (int i = 0; i < Width - 1; i++)
     {
         for (int j = 0; j < Height - 1; j++)
         {
             Grain currentGrain   = GrainsInPreviousStep[i, j];
             Grain grainNeighbour = currentGrain.CheckNeigbours();
             if (grainNeighbour.IsAlive())
             {
                 GrainsInCurrentStep[i, j].Reviev(currentGrain);
                 Grains.Add(currentGrain);
             }
         }
     }
 }
Пример #2
0
        public List <Grain> InitializeBoard(int boardWidth, int boardHeight, int penColors)
        {
            Random random = new Random();

            for (int i = 0; i < penColors; i++)
            {
                Pen color = new Pen(Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 255)));
                PenColors.Add(color);
            }

            for (int i = 0; i < boardWidth; i++)
            {
                for (int j = 0; j < boardHeight; j++)
                {
                    Point position   = new Point(i, j);
                    int   colorIndex = random.Next(PenColors.Count);
                    Grain grain      = new Grain(position, PenColors[colorIndex]);
                    grain.SetGrainAlive();

                    Grains.Add(grain);
                }
            }
            return(Grains);
        }