       down_right: { m:box_position.m+1, n:box_position.n+1 }
 
     cell =
+      box:   level.read_pos(pos.box.m,   pos.box.n)
       left:  level.read_pos(pos.left.m,  pos.left.n)
       right: level.read_pos(pos.right.m, pos.right.n)
       down:  level.read_pos(pos.down.m,  pos.down.n)


  ###
    Test a specific deadlocked square and return the deadlocked positions
    @param box_pos position of the box we want to test
    @param cell1, cell2, cell3 values of cells that made a square with the current box
    @param pos1, pos2, pos3 {m,n} positions of the corresponding cells
    @param deadlocked_positions array of deadlocked boxes positions
    @return completed array of deadlocked_positions (no duplicates positions)
  ###
  deadlocked_square: (cell1, cell2, cell3, pos1, pos2, pos3, box_pos, deadlocked_positions) ->
    console.log("#{cell1} - #{cell2} - #{cell3}")
    console.log(pos1)
    console.log(pos2)
    console.log(pos3)
    console.log(box_pos)
    
    if (cell1 == '#' or cell1 == '$') and
       (cell2 == '#' or cell2 == '$') and
       (cell3 == '#' or cell3 == '$')
      if not @position_in_array(box_pos, deadlocked_positions)
        deadlocked_positions.push({ m:box_pos.m, n:box_pos.n })
      if not @position_in_array(pos1, deadlocked_positions) and cell1 == '$'
        deadlocked_positions.push({ m:pos1.m, n:pos1.n })
      if not @position_in_array(pos2, deadlocked_positions) and cell2 == '$'

      down_right: level.read_pos(pos.down_right.m, pos.down_right.n)
        
    # up-right square
    deadlocked_positions = @deadlocked_square(cell.box, cell.up, cell.up_right, cell.right,
                                              pos.box,  pos.up,  pos.up_right,  pos.right,
                                              deadlocked_positions)
    
    # up-left square
    deadlocked_positions = @deadlocked_square(cell.box, cell.up, cell.up_left, cell.left,
                                              pos.box,  pos.up,  pos.up_left,  pos.left,
                                              deadlocked_positions)
                                              
    # down-right square
    deadlocked_positions = @deadlocked_square(cell.box, cell.down, cell.down_right, cell.right,
                                              pos.box,  pos.down,  pos.down_right,  pos.right,
                                              deadlocked_positions)
    
    # down-left square
    deadlocked_positions = @deadlocked_square(cell.box, cell.down, cell.down_left, cell.left,
                                              pos.box,  pos.down,  pos.down_left,  pos.left,
                                              deadlocked_positions)
                                              
    return deadlocked_positions
    
