public void Test(string input, long expected) { Conway c = new Conway(input); long cycles = c.RunCycles(6); Assert.Equal(expected, cycles); }
public void First_state_is_initial_state(int[][] initialState) { var state = ToBoolArray(initialState); Assert.That(Conway.States(state).First(), Is.EqualTo(state)); }
public void GetBlinkerDataTest_OneChange() { //Given Conway conway = new Conway(new FakeDisplay()); var result = conway.GetBlinkerData(); //When conway.DrawNextGeneration(result, 5, 5); var cell1 = result.Where(w => w.X == 1 && w.Y == 2).First(); var cell2 = result.Where(w => w.X == 2 && w.Y == 2).First(); var cell3 = result.Where(w => w.X == 3 && w.Y == 2).First(); //Then Assert.AreEqual(25, result.Count); Assert.AreEqual(1, cell1.CurrentState); Assert.AreEqual(1, cell1.PreviousState); Assert.AreEqual(1, cell2.CurrentState); Assert.AreEqual(1, cell2.PreviousState); Assert.AreEqual(1, cell3.CurrentState); Assert.AreEqual(1, cell3.PreviousState); }
public void Next_state_is_generated_correctly(int[][] initialState, int[][] nextState) { var state1 = ToBoolArray(initialState); var state2 = ToBoolArray(nextState); Assert.That(Conway.States(state1).Skip(1).First(), Is.EqualTo(state2)); }
public void CellsWithMoreThanThreeLiveNeighbors() { // Any live cell with more than three live neighbours dies StateOfCell CurrentCellState = StateOfCell.Alive; int NumOfLiveNeighbors = 4; StateOfCell output = Conway.GetNewCellState(CurrentCellState, NumOfLiveNeighbors); Assert.AreEqual(StateOfCell.Dead, output); }
public void CellsWithTwoOrThreeliveNeighbors() { // Any live cell with two or three live neighbours lives StateOfCell CurrentCellState = StateOfCell.Alive; int NumOfLiveNeighbors = 3; StateOfCell output = Conway.GetNewCellState(CurrentCellState, NumOfLiveNeighbors); Assert.AreEqual(StateOfCell.Alive, output); }
public void CellsWithLessThanTwoLiveNeighb() { // Any live cell with fewer than two live neighbours dies StateOfCell CurrentCellState = StateOfCell.Alive; int NumOfLiveNeighbors = 1; StateOfCell output = Conway.GetNewCellState(CurrentCellState, NumOfLiveNeighbors); Assert.AreEqual(StateOfCell.Dead, output); }
public void BuildRandomBoardSizeTest_0Column_1Row() { //Given Conway conway = new Conway(new FakeDisplay()); //When var result = conway.BuildRandomBoard(1, 0); //Then Assert.AreEqual(0, result.Count); }
public void BuildRandomBoardSizeTest_24() { //Given Conway conway = new Conway(new FakeDisplay()); //When var result = conway.BuildRandomBoard(4, 6); //Then Assert.AreEqual(24, result.Count); }
public void DeadCellsWithExaltyThreeLiveNeighbors() { // Any dead cell with exactly three live neighbours becomes a live cell StateOfCell CurrentCellState = StateOfCell.Dead; int NumOfLiveNeighbors = 3; StateOfCell output = Conway.GetNewCellState(CurrentCellState, NumOfLiveNeighbors); Assert.AreEqual(StateOfCell.Alive, output); }
public void Oscillating_blinker_example() { var horizontalState = ToBoolArray(new [] { new [] { 0, 0, 0 }, new [] { 1, 1, 1 }, new [] { 0, 0, 0 } }); var verticalState = ToBoolArray(new [] { new [] { 0, 1, 0 }, new [] { 0, 1, 0 }, new [] { 0, 1, 0 } }); var states = Conway.States(horizontalState); Assert.That(states.Take(3), Is.EqualTo(new [] { horizontalState, verticalState, horizontalState })); }
public void Cannot_call_with_null_arguments() { Assert.That(() => Conway.States(null).ToArray(), Throws.TypeOf <ArgumentNullException>()); }
public void Next_state_is_generated_correctly(bool[][] initialState, bool[][] nextState) { Assert.That(Conway.NextState(initialState), Is.EqualTo(nextState)); }
void Awake() { Current = this; VisualTilesReady += OnVisualTilesReady; InitialStateReady += OnInitialStateReady; world = new World ( width, height ); conway = new Conway ( world.Width, world.Height ); Camera.main.transform.position = new Vector3 ( world.Width / 2, world.Height / 2, Camera.main.transform.position.z ); }