How do I create a deck of cards that generates a dungeon of an average particular size?
This game mechanic introduces the problem of trying to establish the expected result of a dynamic series of events that can't be readily repeated. For common terms through out, I'll be using the following to describe the game pieces. 

Tile   Doors   Effect
A      1      -1
B      2       0
C      3       1
D      4       2


Additional variables are:  


  M = Totel Deck Size
  t = number of turns taken cards drawn
  a, b, c, d = Number of tiles drawn of that type
  A, B, C, D = Total Number of that Tile in the Deck  


In the Worst Case, if you draw every other tile before you start drawing A's, you would need sufficient A tiles to close the open dungeon. For this:  


  A >= 3 + C + 2*D  


This is because you are starting on the south edge of the map with 3 open doors (west, north, and east). For the tiles you draw, C adds 1 door, D adds two doors, and A subtracts 1 door. If this equation is true for your deck of tiles, than there will be no open doors left.

Not yet addressed is the total number of tiles, needed to provide for an game of t turns, but I'll get there. Crunching the permutations.