This is an implementation of the water fill problem.
Given a grid, with columns along X, how many cells of "water" can be filled, considering runoff:
Example Grid
_
| |
_ | | _
| | | | |
| _ _ | | _ _ | | _
| | | | | | | | | |
_| _| _| _| _| _|_| _| _|_| _
Result: 14
Note: the bottom is solid, but the left edge and right edge are open (there are no walls).