title: 2D array - Detect if a position is inside a closed pattern
body: <p>Let's say I have the following:</p>
  
  <pre><code>{ 0,0,0,0,0,0,0,0,0,0,
    0,0,0,0,0,0,X,X,X,0,
    0,0,0,X,X,X,X,0,X,0,
    0,0,0,X,0,A,0,0,X,0,
    0,0,0,X,0,0,X,X,X,0,
    0,0,0,X,X,X,X,0,0,0,
    0,0,0,0,0,0,0,0,0,0,
    0,0,0,0,0,0,0,0,0,0,
    0,0,0,0,0,0,0,0,0,0 }
  </code></pre>
  
  <p>As you can see, it's clearly that A is inside surrounded by all the X's ( Diagonal not counting ). So can I detect if a point in the array is surrounded by X's and it's of course closed? Any rescursive algorithm? I thought about the following pseudocode:</p>
  
  <pre><code>bool IsSurroundedByX( Vector2 A )
  {
       if A is an extrem from the matrix ( column is 0 or N-1 || row is 0 or M -1 ) and not an X return false
       if A is an X return true
       return IsSurroundedByX( A + left ) &amp;&amp; 
              IsSurroundedByX( A + right ) &amp;&amp; 
              IsSurroundedByX( A + bottom ) &amp;&amp; 
              IsSurroundedByX( A + top ) &amp;&amp; 
  }
  </code></pre>
  
  <p>But I think it's not going to work.</p>