コード例 #1
0
        public void Trace(Position position, StoneType putStoneType, ActionForSandwichedStoneDelegate action)
        {
            if (position == null || action == null)
            {
                throw new ArgumentException();
            }

            foreach (var dir in Position.Direction.AllDirections)
            {
                var neighberCell = board.GetNeighberCell(position, dir);
                TraceSub(neighberCell, putStoneType, dir, action);
            }
        }
コード例 #2
0
        private bool TraceSub(Cell tracingCell, StoneType putStoneType, Position.Direction dir, ActionForSandwichedStoneDelegate action)
        {
            if (tracingCell == null)
            {
                return(false);
            }

            if (tracingCell.Stone == null)
            {
                return(false);
            }

            if (putStoneType.Equals(tracingCell.Stone))
            {
                return(true);
            }

            var neighberCell = board.GetNeighberCell(tracingCell.Position, dir);

            bool isSandwiched = TraceSub(neighberCell, putStoneType, dir, action);

            if (isSandwiched)
            {
                action(tracingCell);
            }

            return(isSandwiched);
        }