Пример #1
0
        public MainWindow()
        {
            InitializeComponent();
            InitializeCanvas();
            _gof = new Core.GameOfLife(GameOfLifeStringReader.Read(ExampleLands.Land1));

            DrawLand();
        }
Пример #2
0
        private static void Main(string[] args)
        {
            var land = GameOfLifeStringReader.Read(ExampleLands.Land1);

            var gof = new Core.GameOfLife(land);
            Console.WriteLine();
            for (var i = 0; i < 100; i++)
            {
                Console.WriteLine(gof);
                gof.NextGeneration();
                Thread.Sleep(500);
            }
        }
Пример #3
0
        public void CreatesNextGenerationCorrectly()
        {
            // arrange
            var land = new bool[,]
            {
                {false, false, false, false, false},
                {false, true, true, false, false},
                {false, true, false, false, false}
            };
            var gof = new Core.GameOfLife(land);

            // act
            gof.NextGeneration();

            // assert
            Assert.That(Core.GameOfLife.IsCellAlive(1, 1, land), Is.True);
            Assert.That(Core.GameOfLife.IsCellAlive(2, 1, land), Is.True);
            Assert.That(Core.GameOfLife.IsCellAlive(1, 2, land), Is.True);
        }
Пример #4
0
        public void LandProperty_Returns_A_ReadCopy()
        {
            // arrange
            var gol = new Core.GameOfLife(new[,]
            {
                {false, false},
                {false, false}
            });
            // act
            var copy = gol.Land;
            copy[0, 0] = true;

            // assert
            Assert.That(copy[0, 0], Is.True);
            Assert.That(gol.Land[0, 0], Is.False);
        }