             deadlocked_positions.push({ m:pos_box.m, n:pos_box.n })
           if not @position_in_array(pos_box2, deadlocked_positions)
             deadlocked_positions.push({ m:pos_box2.m, n:pos_box2.n })
+            
+          # save this deadlock for the future
+          @already_found_deadlocks.push([
+            {m: pos_box.m,  n: pos_box.n}
+            {m: pos_box2.m, n: pos_box2.n}
+          ])
               
     return deadlocked_positions
           

        deadlocked_positions.push({ m:pos2.m, n:pos2.n })
      if not @position_in_array(pos3, deadlocked_positions) and cell3 == '$'
        deadlocked_positions.push({ m:pos3.m, n:pos3.n })
                
    return deadlocked_positions
    
  deadlocked_z: (cell_box, cell_box2, cell_wall1, cell_wall2, pos_box, pos_box2, deadlocked_positions) ->

       (cell1 == '#' or cell1 == '$') and
       (cell2 == '#' or cell2 == '$') and
       (cell3 == '#' or cell3 == '$')
      
      # add deadlocks in array        
      if not @position_in_array(pos_box, deadlocked_positions)
        deadlocked_positions.push({ m:pos_box.m, n:pos_box.n })
      if not @position_in_array(pos1, deadlocked_positions) and cell1 == '$'
