title: Algorithm to detect no movable pieces in Stratego
body: <p>I am creating a Stratego Game and am having trouble creating an algorithm that can detect when there are no more possible moves because all your pieces are gone or the remaining pieces are unmovable or trapped by forbidden squares, unmovable pieces, or other trapped pieces.</p>
  
  <p>For simplicity you can think of the board as an array of Squares which can contain pieces.</p>
  
  <pre><code>Square[][] gameBoard = new Square[10][10]
  </code></pre>
  
  <p>Squares have easily checkable state such as hasPiece(), hasEnemyPiece(), hasUnMovablePiece(), hasMoveablePiece(), isBlocked().</p>
  
  <p>It would also probably be nice if this algorithm wasn't run every time a player moved but maybe checked in the beginning and then only certain conditions were checked when the player moved.</p>
  
  <pre><code>[ ][ ][ ][ ][ ][ ][ ][ ][ ][ ]
  [ ][ ][ ][ ][ ][ ][ ][ ][ ][ ]
  [B][ ][ ][ ][ ][ ][B][B][ ][ ]
  [F][B][ ][ ][ ][B][3][4][B][ ]
  </code></pre>
  
  <p>This is an example situation towards the end of a game, you need to be able to check each of the non-movable pieces (3 &amp; 4) to see whether they are movable[not trapped by water(blocked), other unmovable pieces(bomb or flag), or other trapped pieces].</p>