コード例 #1
0
        private void VerticalCheck(IBoard board, HashSet <BoardChange> changes)
        {
            for (int x = 0; x < board.Width; x++)
            {
                var ruleLine      = board.TopRules[x];
                var sum           = ruleLine.Sum();
                var numberOfRules = ruleLine.Count;
                var sizeNeeded    = sum + numberOfRules - 1;
                if (sizeNeeded == board.Height)
                {
                    int y = 0;
                    foreach (var rule in ruleLine)
                    {
                        for (int i = 0; i < rule; i++)
                        {
                            if (board[x, y] == CellState.None)
                            {
                                changes.Add(BoardChange.Filled(x, y));
                            }
                            y += 1;
                        }

                        if (y < board.Height)
                        {
                            if (board[x, y] == CellState.None)
                            {
                                changes.Add(BoardChange.Blocked(x, y));
                            }
                            y += 1;
                        }
                    }
                }
            }
        }
コード例 #2
0
        private void Vertical(IBoard board, HashSet <BoardChange> changes)
        {
            for (int x = 0; x < board.Width; x++)
            {
                IRuleLine?ruleLine = board.TopRules[x];

                if (ruleLine.Count != 1)
                {
                    continue;
                }

                int f = (ruleLine[0] * 2) - board.Height;
                if (f > 0)
                {
                    int e = ruleLine[0] - f;
                    for (int filledCells = e; filledCells < e + f; filledCells++)
                    {
                        if (board[x, filledCells] == CellState.None)
                        {
                            changes.Add(BoardChange.Filled(x, filledCells));
                        }
                    }
                }
            }
        }