Ejemplo n.º 1
0
 public void tick_world_returns_new_world_with_cells_after_applying_rules()
 {
     var world = new World();
     world.AddLiveCell(new Position(0, 0));
     World worldAftertick = world.Tick();
     Assert.True(worldAftertick.IsCellDead(new Position(0, 0)));
 }
Ejemplo n.º 2
0
 public void get_neighbours_for_cell_with_one_neighbour_returns_1()
 {
     var world = new World();
     world.AddLiveCell(new Position(0, 0));
     world.AddLiveCell(new Position(1, 1));
     Assert.Equal(1, world.GetLiveNeighbours(new Position(0, 0)));
 }
Ejemplo n.º 3
0
        public World Tick()
        {
            var newWorld = new World();

            foreach (Cell cell in GetRemainingLiveCellsAfterTick().Concat(GetNewLiveCellsAfterTick()))
            {
                newWorld.AddLiveCell(cell.Position);
            }

            return newWorld;
        }
Ejemplo n.º 4
0
        public void tick_world_brings_dead_cells_to_life_when_has_3_neighbours()
        {
            var world = new World();

            world.SetupWorld(
                "0+0", // <- we expect the cell at 2,0 to come alive because it has 3 neighbours
                "0++",
                "000");

            World worldAfterTick = world.Tick();

            Assert.True(worldAfterTick.IsCellAlive(new Position(2, 0)));
        }
Ejemplo n.º 5
0
        static void Main(string[] args)
        {
            var world = new World();

            string[] setup = ConwayBoards.Puffer();

            world.SetupWorld(setup);

            var model = new WorldToConwayModelWrapper(world);

            // you can use the constant speed model if you want things to happen at a specific pace - useful
            // if the technology being used to render does not take long - for us, console is the bottle neck.

            //var clock = new SystemClock();
            //var constantModel = new ConwayConstantSpeedModel(model, clock) {TicksPerSecond = 3};

            var display = new ConwayTerminalDisplay(79, 35, model);

            display.Start();
        }
 public bool Tick()
 {
     world = world.Tick();
     ticks++;
     return true;
 }
 public WorldToConwayModelWrapper(World initial)
 {
     world = initial;
 }