Beispiel #1
0
        public MainWindow()
        {
            InitializeComponent();

            _hexPainter = new HexGridPainter();

            _timer          = new DispatcherTimer();
            _timer.Interval = TimeSpan.FromMilliseconds(1);
            _timer.Tick    += (o, args) =>
            {
                _gol.MakeNextGeneration();
                Canvas.InvalidateVisual();
            };
        }
Beispiel #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}");
        }
Beispiel #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);
            });
        }