public void Test3_Graphics() { GraphPointArray[] cells = new GraphPointArray[0]; GameOfLifeRules rules = new GameOfLifeRules(); rules.initialLiveCells = new PositionInt[] { new PositionInt(5, 5) }; rules.neighbours_ToSurvive = new int[] { 2, 3 }; rules.neighbours_ToDie = new int[] { 0, 1, 4, 5, 6, 7, 8 }; rules.neighbours_ToCreate = new int[] { 3 }; rules.plateSize = new PositionInt(20, 20); GameOfLifePlate plate = new GameOfLifePlate(rules); new Thread(() => { Graph graph = new Graph( 500, 500, 1, cells, Color.FromArgb(70, 70, 70), $"", new Size(1, 1), false ); }).Start(); }
public void Dead_Cell_With_Exactly_Three_Neighbors_Becomes_A_Live_Cell( [Values(CellState.Dead)] CellState currentState, [Values(3)] int liveNeighbors) { CellState newState = GameOfLifeRules.GetNewState(currentState, liveNeighbors); Assert.AreEqual(CellState.Alive, newState); }
public void Dead_Cell_With_More_Than_Three_Neighbors_Stays_Dead( [Values(CellState.Dead)] CellState currentState, [Range(4, 8)] int liveNeighbors) { CellState newState = GameOfLifeRules.GetNewState(currentState, liveNeighbors); Assert.AreEqual(CellState.Dead, newState); }
public void Live_Cell_With_Two_Or_Three_Live_Neighbors_Lives( [Values(CellState.Alive)] CellState currentState, [Values(2, 3)] int liveNeighbors) { CellState newState = GameOfLifeRules.GetNewState(currentState, liveNeighbors); Assert.AreEqual(CellState.Alive, newState); }
public void Live_Cell_With_Fewer_Than_Two_Live_Neighbors_Dies( [Values(CellState.Alive)] CellState currentState, [Values(0, 1)] int liveNeighbors) { CellState newState = GameOfLifeRules.GetNewState(currentState, liveNeighbors); Assert.AreEqual(CellState.Dead, newState); }
public void ShouldReturnDeadIfAliveAnd4OrMoreAliveNeighbours() { var gameOfLifeRule = new GameOfLifeRules(); var deadOrAliveNeighbourCount = new DeadOrAliveNeighboursCount { AliveNeighbourCount = 4 }; var result = gameOfLifeRule.LifeStatusForNextTick(deadOrAliveNeighbourCount, LifeStatus.Alive); Assert.AreEqual(LifeStatus.Dead, result); }
public void ShouldNotReturnAliveIfAliveAnd2AliveNeighbours() { var gameOfLifeRule = new GameOfLifeRules(); var deadOrAliveNeighbourCount = new DeadOrAliveNeighboursCount { AliveNeighbourCount = 2 }; var result = gameOfLifeRule.LifeStatusForNextTick(deadOrAliveNeighbourCount, LifeStatus.Alive); Assert.AreEqual(LifeStatus.Alive, result); }
public void AnAliveCellWithTwoOrThreeNeighbors_ShouldResultInALiveCell() { int numberOfNeighbors = 2; Assert.That(GameOfLifeRules.ApplyRules(numberOfNeighbors, State.Alive), Is.EqualTo(State.Alive)); numberOfNeighbors = 3; Assert.That(GameOfLifeRules.ApplyRules(numberOfNeighbors, State.Alive), Is.EqualTo(State.Alive)); }
public void Test1() { GameOfLifeRules gofr = new GameOfLifeRules(); //gofr.neighbours_ToBecomeAlive = new PositionInt[] { new PositionInt(1, 1), new PositionInt(0, 1) }; gofr.initialLiveCells = new PositionInt[] { new PositionInt(1, 1), new PositionInt(0, 0) }; gofr.neighbours_ToSurvive = new int[] { 2, 3 }; gofr.neighbours_ToDie = new int[] { 0, 1, 4, 5, 6, 7, 8 }; gofr.neighbours_ToCreate = new int[] { 3 }; gofr.plateSize = new PositionInt(20, 20); //Console.WriteLine(JsonSerializer.Serialize(gofr)); Console.WriteLine(JsonConvert.SerializeObject(gofr, Formatting.Indented)); }
public void ProduceNextGeneration1() { var board = new Board(4, 4); var gameOfLifeRule = new GameOfLifeRules(); board.SetCellExistence(0, 0, true); board.SetCellExistence(2, 0, true); board.SetCellExistence(0, 1, true); board.SetCellExistence(1, 1, true); board.SetCellExistence(2, 1, true); board.SetCellExistence(3, 1, true); board.SetCellExistence(0, 2, true); board.SetCellExistence(1, 2, true); board.SetCellExistence(2, 2, true); Board nextGeneration = gameOfLifeRule.ProduceNextGeneration(board); Assert.IsTrue(nextGeneration.IsAlive(0, 0)); Assert.IsFalse(nextGeneration.IsAlive(1, 0)); Assert.IsTrue(nextGeneration.IsAlive(2, 0)); Assert.IsTrue(nextGeneration.IsAlive(3, 0)); Assert.IsFalse(nextGeneration.IsAlive(0, 1)); Assert.IsFalse(nextGeneration.IsAlive(1, 1)); Assert.IsFalse(nextGeneration.IsAlive(2, 1)); Assert.IsTrue(nextGeneration.IsAlive(3, 1)); Assert.IsTrue(nextGeneration.IsAlive(0, 2)); Assert.IsFalse(nextGeneration.IsAlive(1, 2)); Assert.IsFalse(nextGeneration.IsAlive(2, 2)); Assert.IsTrue(nextGeneration.IsAlive(3, 2)); Assert.IsFalse(nextGeneration.IsAlive(0, 3)); Assert.IsTrue(nextGeneration.IsAlive(1, 3)); Assert.IsFalse(nextGeneration.IsAlive(2, 3)); Assert.IsFalse(nextGeneration.IsAlive(3, 3)); }
// Start is called before the first frame update void Start() { Transform cameraTransform = mainCamera.GetComponent <Transform>(); cameraTransform.position = new Vector3(SceneX / 2.0f, SceneY / 2.0f, mainCamera.GetComponent <Transform>().position.z); CreateAllCells(); BoxCollider2D boxCollider = GetComponent <BoxCollider2D>(); boxCollider.offset = new Vector2(SceneX / 2.0f, SceneY / 2.0f); boxCollider.size = new Vector2(SceneX, SceneY); gameOfLife = new GameOfLifeRules(gameRules); // Invoke("PararelUpdate", this.slider.value); buf = new ComputeBuffer(64, sizeof(float), ComputeBufferType.Default); Shader.SetGlobalBuffer(Shader.PropertyToID("Result"), buf); Shader.SetGlobalInt("WORLD_SIZE_X", 200); shader.Dispatch(shader.FindKernel("CSMain"), 1, 1, 1); float[] data = new float[64]; buf.GetData(data); print(data[0]); }
public void WhenIDetermineNextGeneration() { GameOfLifeRules.SetNextGeneration(); }
public void GivenInitialStateCellWithAliveNeighbours(GenerationState initSatate, int neighbour) { GameOfLifeRules.SetCurrentGeneration(initSatate, neighbour); }
public void Initialize() { gameOfLife = new GameOfLifeRules(); gameOfLife.InitializeBoard(4, 8); }
public void AnDeadCellWithExactlyThreeNeighbors_ShouldResultInAnAliveCell() { int numberOfNeighbors = 3; Assert.That(GameOfLifeRules.ApplyRules(numberOfNeighbors, State.Dead), Is.EqualTo(State.Alive)); }
public void ADeadCellWithNoNeighbors_ShouldResultInADeadCell() { int numberOfNeighbors = 0; Assert.That(GameOfLifeRules.ApplyRules(numberOfNeighbors, State.Dead), Is.EqualTo(State.Dead)); }