示例#1
0
        private void cbCellList_SelectedIndexChanged(object sender, EventArgs e)
        {
            ICell         _cell = null;
            ComboBox      cb    = (sender as ComboBox);
            ComboBoxEntry entry = (cb.SelectedItem as ComboBoxEntry);

            switch (entry.ID)
            {
            case -1:
                _cell = new AllDeadCell(GRID_SIZE);
                break;

            case 0:
                _cell = new SimpleCustomCell(GRID_SIZE);
                break;

            case 1:
                _cell = new GliderCell(GRID_SIZE);
                break;

            case 2:
                _cell = new SmallExploderCell(GRID_SIZE, 20);
                break;

            case 3:
                _cell = new ExploderCell(GRID_SIZE, 20);
                break;

            case 4:
                _cell = new TenCellRowCell(GRID_SIZE, 20);
                break;

            case 5:
                _cell = new TumblerCell(GRID_SIZE, 20);
                break;

            case 6:
                _cell = new GosperGliderGunCell(GRID_SIZE, 7);
                break;

            case 7:
                _cell = new RandomCell(GRID_SIZE);
                break;

            default:
                break;
            }
            if (_cell != null)
            {
                this.grid1.GridBits = _cell.ToGrid();
                this.generation     = 0;
                this.lblGenNum.Text = generation.ToString();
            }
        }
示例#2
0
        public void GliderTest_correctSizeReturned()
        {
            bool[,] _result = new GliderCell(25).ToGrid();
            Assert.AreEqual(_result.GetLongLength(0), 25);
            Assert.AreEqual(_result.GetLongLength(1), 25);

            //Odd (unusual) size
            _result = new GliderCell(37).ToGrid();
            Assert.AreEqual(_result.GetLongLength(0), 37);
            Assert.AreEqual(_result.GetLongLength(1), 37);

            _result = new GliderCell(50).ToGrid();
            Assert.AreEqual(_result.GetLongLength(0), 50);
            Assert.AreEqual(_result.GetLongLength(1), 50);
        }
示例#3
0
        public void GliderTest_correctShape()
        {
            bool[,] expected =
            {
                { false, true,  false },
                { false, false, true  },
                { true,  true,  true  }
            };
            bool[,] testGrid = new GliderCell(3, 0).ToGrid();

            //Assert.AreEqual(expected, testGrid); //fails but probably because the objects are not the same reference (as opposed to contents).

            for (int i = 0; i < 3; i++)
            {
                for (int j = 0; j < 3; j++)
                {
                    Assert.AreEqual(expected[i, j], testGrid[i, j]);
                }
            }
        }