public void OneCellShouldDisappearAfterOneIteration() { game = new GameOfLife(3, 3); game[1, 1] = true; game.Update(); Assert.IsFalse(game[1, 1]); }
public void CreateSimplestGameOfLifeEverWith1X1() { game = new GameOfLife(1, 1); Assert.AreEqual(0, game.GenerationCount); game.Update(); Assert.AreEqual(1, game.GenerationCount); }
public void BlockShouldStayAlive() { game = new GameOfLife(4, 4); CreateBlock(1, 1); game.Update(); Assert.IsTrue(game[1, 1]); Assert.IsTrue(game[2, 2]); }
public void LineShouldAlternate() { game = new GameOfLife(3, 3); CreateVerticalLine(1, 0); Assert.IsTrue(game[1, 0]); Assert.IsFalse(game[0, 1]); game.Update(); Assert.IsFalse(game[1, 0]); Assert.IsTrue(game[0, 1]); Assert.IsTrue(game[1, 1]); Assert.IsTrue(game[2, 1]); }
public void ShowGameOfLife() { game = new GameOfLife(24, 24); game.Randomize(); if (Time.CheckEvery(0.1f)) { game.Update(); } for (int x = 0; x < game.width; x++) { for (int y = 0; y < game.height; y++) { float posX = 0.1f + 0.8f * x / game.width; float posY = 0.1f + 0.8f * y / game.height; Color color = game[x, y] ? Color.White : Color.DarkGray; new Ellipse(Rectangle.FromCenter(posX, posY, 0.025f, 0.025f), color); } } }
public void ShowGameOfLife() { game = new GameOfLife(24, 24); game.Randomize(); if (Time.CheckEvery(0.1f)) game.Update(); for (int x = 0; x < game.width; x++) for (int y = 0; y < game.height; y++) { float posX = 0.1f + 0.8f * x / game.width; float posY = 0.1f + 0.8f * y / game.height; Color color = game[x, y] ? Color.White : Color.DarkGray; new Ellipse(Rectangle.FromCenter(posX, posY, 0.025f, 0.025f), color); } }