Exemple #1
0
 private void StartButton_OnClicked(object sender, RoutedEventArgs e)
 {
     _cellRadius = Canvas.CanvasSize.Width / 200 / 2;
     _gol        = new HexGameOfLife(200, 200);
     _gol.ResetToSingleCell();
     _timer.Start();
 }
Exemple #2
0
        public void Benchmark()
        {
            var hexLife = new HexGameOfLife(1000, 1000);

            hexLife.ResetToSingleCell();

            var benchmark = new Benchmark();

            benchmark.Start();
            for (var i = 0; i < 100; i++)
            {
                hexLife.MakeNextGeneration();
            }
            benchmark.Stop();

            Assert.Fail($"{benchmark.MeanElapsed().TotalMilliseconds}");
        }
Exemple #3
0
        private void StartButton_OnClicked(object sender, EventArgs e)
        {
            CellRadius           = Canvas.CanvasSize.Width / 200 / 2;
            Sqrt3TimesCellRadius = Sqrt3 * CellRadius;
            TwoTimesCellRadius   = 2 * CellRadius;

            _gol = new HexGameOfLife(200, 200);
            _gol.ResetToSingleCell();
            _isPlaying = true;

            Device.StartTimer(TimeSpan.FromMilliseconds(0), () =>
            {
                _gol.MakeNextGeneration();

                Canvas.InvalidateSurface();
                return(_isPlaying);
            });
        }