/// <summary>
        /// A list of board squares that are yielded via the given navigation function.
        /// </summary>
        private IEnumerable <GameBoardSquareViewModel> NavigateBoard(NavigationFunction navigationFunction, int row, int column)
        {
            navigationFunction(ref column, ref row);
            while (column >= 0 && column <= 7 && row >= 0 && row <= 7)
            {
                yield return(GetSquare(row, column));

                navigationFunction(ref column, ref row);
            }
        }
        /// <summary>
        /// Determines whether the given move 'surrounds' any of the opponents pieces.
        /// </summary>
        private bool MoveSurroundsCounters(int row, int column,
                                           NavigationFunction navigationFunction, BoardSquareState state)
        {
            int index = 1;

            var squares = NavigateBoard(navigationFunction, row, column);

            foreach (var square in squares)
            {
                BoardSquareState currentCellState = square.State;

                // the cell that is the immediate neighbour must be of the other colour
                if (index == 1)
                {
                    if (currentCellState != InvertState(state))
                    {
                        return(false);
                    }
                }
                else
                {
                    // if we have reached a cell of the same colour, this is a valid move
                    if (currentCellState == state)
                    {
                        return(true);
                    }

                    // if we have reached an empty cell - fail
                    if (currentCellState == BoardSquareState.EMPTY)
                    {
                        return(false);
                    }
                }

                index++;
            }

            return(false);
        }
 /// <summary>
 /// A list of board squares that are yielded via the given navigation function.
 /// </summary>
 private IEnumerable<GameBoardSquareViewModel> NavigateBoard(NavigationFunction navigationFunction, int row, int column)
 {
     navigationFunction(ref column, ref row);
       while (column >= 0 && column <= 7 && row >= 0 && row <= 7)
       {
     yield return GetSquare(row, column);
     navigationFunction(ref column, ref row);
       }
 }
        /// <summary>
        /// Determines whether the given move 'surrounds' any of the opponents pieces.
        /// </summary>
        private bool MoveSurroundsCounters(int row, int column,
      NavigationFunction navigationFunction, BoardSquareState state)
        {
            int index = 1;

              var squares = NavigateBoard(navigationFunction, row, column);
              foreach(var square in squares)
              {
            BoardSquareState currentCellState = square.State;

            // the cell that is the immediate neighbour must be of the other colour
            if (index == 1)
            {
              if (currentCellState != InvertState(state))
              {
            return false;
              }
            }
            else
            {
              // if we have reached a cell of the same colour, this is a valid move
              if (currentCellState == state)
              {
            return true;
              }

              // if we have reached an empty cell - fail
              if (currentCellState == BoardSquareState.EMPTY)
              {
            return false;
              }
            }

            index++;
              }

              return false;
        }