コード例 #1
0
        // ***************************************************************************
        // *                            Constructors                                 *
        // ***************************************************************************

        /// <summary>
        /// Initializes a new instance of the <see cref="FloodZone"/> class.
        /// </summary>
        /// <param name="seedCell">The starting cell of the flood</param>
        public FloodZone(GridCell seedCell)
        {
            _floodedCells     = new List <GridCell>();
            _currentCellIndex = -1;
            Extents           = new Extents();

            if (seedCell != null && !seedCell.IsOccupied)
            {
                _floodedCells.Add(seedCell);
                Extents.Extend(seedCell);

                Flood(seedCell.GetUnoccupiedNeighborsCardinal());
            }
        }
コード例 #2
0
        // ***************************************************************************
        // *                           Private Methods                               *
        // ***************************************************************************

        /// <summary>
        /// Recursively floods adjacent, unoccupied cells
        /// </summary>
        /// <param name="unoccupiedCells">List of unoccupied cells that are members of a contiguous group</param>
        private void Flood(List <GridCell> unoccupiedCells)
        {
            foreach (var cell in unoccupiedCells)
            {
                // If this cell has not been flooded yet, add it to the list of flooded cells
                if (!_floodedCells.Contains(cell))
                {
                    _floodedCells.Add(cell);
                    Extents.Extend(cell);

                    Flood(cell.GetUnoccupiedNeighborsCardinal());
                }
            }
        }
コード例 #3
0
ファイル: GamePiece.cs プロジェクト: MaxMan79/IQ-XOXO-Solver
        // ***************************************************************************
        // *                            Constructors                                 *
        // ***************************************************************************

        /// <summary>
        /// Initializes a new instance of the <see cref="GamePiece"/> class.
        /// </summary>
        /// <param name="cells">List of game piece cells</param>
        public GamePiece(List <GamePieceCell> cells, Color color, string name = null)
        {
            _cells = cells;
            Color  = color;
            Name   = name;

            Extents = new Extents();

            foreach (var cell in cells)
            {
                Extents.Extend(cell);
            }

            Reset();
        }