Esempio n. 1
0
 private void GameRun(GOL.GameOfLife game)
 {
     while (true)
     {
         stopEvent.WaitOne();
         foreach (var cell in game.iterate())
         {
             SolidColorBrush color = cell.IsSet ? cellColor : Brushes.White;
             this.Dispatcher.BeginInvoke(new Action(() => {
                 gridRect[cell.X][cell.Y].Fill = color;
             }));
         }
         Thread.Sleep(speed);
     }
 }
Esempio n. 2
0
        private List <GOL.Cell> GetCellsSelected(GOL.GameOfLife game)
        {
            List <GOL.Cell> cells = new List <GOL.Cell>();

            for (int i = 0; i < width; i++)
            {
                for (int j = 0; j < height; j++)
                {
                    if (gridRect[i][j].Fill == cellColor)
                    {
                        cells.Add(game.GetBoard().Cells[i, j]);
                    }
                }
            }
            return(cells);
        }
Esempio n. 3
0
 private GOL.GameOfLife InitStartGame()
 {
     isBreak = false;
     GOL.GameOfLife game;
     if (rbnRandom.IsChecked ?? true)
     {
         game = new GOL.GameOfLife(width, height, true);
         CreateGrid();
     }
     else
     {
         game = new GOL.GameOfLife(width, height, false);
         game.SetCells(GetCellsSelected(game));
     }
     return(game);
 }