コード例 #1
0
        public void SetInitialState_LiveCells_ConfirmGrid(int[] aliveCells)
        {
            var gridSize = new Vector(3, 3);
            var cells = new List<Vector>();
            var generationController = new GenerationController(gridSize);

            for (int i = 0; i < aliveCells.Length; i = i + 2)
                cells.Add(new Vector(aliveCells[i], aliveCells[i + 1]));

            generationController.SetInitialState(cells);

            foreach (var cell in cells)
                Assert.IsTrue(generationController.GetAliveCells().Contains(cell));
        }
コード例 #2
0
ファイル: Form1.cs プロジェクト: CassioMoraes/GameOfLife
        public Form1()
        {
            InitializeComponent();

            _isRunning = true;

            var gridSize = new Vector(3, 3);
            _generationController = new GenerationController(gridSize);
            _generationController.OnGenerationComplete += _generationController_OnGenerationComplete;

            _cellSize = new Vector(x: this.pctCanvas.Size.Width / _generationController.GridSize.X,
                                   y: this.pctCanvas.Size.Height / _generationController.GridSize.Y);

            this.GridLines = new List<Line>();
            this.GridLines.AddRange(GridLinesGenerator.GenerateGridLines(_generationController.GridSize, _cellSize));
        }