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); } }
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); }
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); }