title: Finding connected cells in a 2d array
body: <p><strong>Edit: Solved, see my post below.</strong></p>
  
  <p>I'm implementing a board game in Java and need to develop an algorithm to find the number of "connected" cells from a single cell in a 2d array. </p>
  
  <p><strong>Edit:</strong> By connected, I mean have the same value as the cell that I'm beginning at. If the method calls on a cell with the value x, I need to find all those that share an edge with it (not diagonals). </p>
  
  <p>IE if I had this 2d array of ones and zeros, I want to find the highest number of connected cells to a single cell of my choosing:</p>
  
  <pre><code>[1][1][1][0]
  [1][0][1][1]
  [1][0][0][1]
  [1][0][0][1]
  </code></pre>
  
  <p>Running the algorithm on [0][0] would return 10, as there are six 1s connected going down the right path and 3 going down the left path.</p>
  
  <p>Is there a known way to approach this problem? If not, how would you go about solving it? I'm racking my brain and can't seem to find a way off the bat. Any advice is appreciated. </p>