static void Main(string[] args) { GoLGrid gameGrid = new GoLGrid(); gameGrid.InitializeRandomly(); while (true) { System.Threading.Thread.Sleep(1000); gameGrid.Display(); gameGrid.Transform(); } }
// Lorsque la fenêtre est chargée, on crée une nouvelle grille, et on s’abonne à son évènement de mise à jour. void MainWindow_Loaded(object _sender, RoutedEventArgs _e) { grid = new GoLGrid((int)gridCanvas.ActualWidth / 3, (int)gridCanvas.ActualHeight / 3, 0.1); grid.gridUpdatedEvent += grid_gridUpdatedEvent; // On crée aussi un timer qui se lancera toutes les 500ms. updateTimer = new DispatcherTimer(); updateTimer.Tick += updateTimer_Tick; updateTimer.Interval = new TimeSpan(0, 0, 0, 0, 500); // On lance la simulation. updateTimer.Start(); running = true; }