This page is intended to describe how the game chooses whether to give you a combat or a noncombat, and which one to give you.
For the visually inclined, here's a flowchart to illustrate the process described below.
Picking combat or noncombat
Every zone has some combat percentage, and this number is an integer (usually a multiple of 5). This number can be modified with +/- combat skills. The game rolls a 1D100, and if the rolled number is higher than the modified combat rate, you get a noncombat. If it's the same or lower, you get a combat. Let's illustrate with an example.
In the haunted ballroom the combat rate is 80%. If you have -20% combats running (say, smooth, sonata, RoC, and the ballroom song) then the rate is 60%. The game rolls a 1D100 and it's 59. You get a combat. The next roll is a 60, you get a combat. The next roll is 61, and you get a noncombat.
However, Jick introduced a new mechanism with Pandamonium that can circumvent this. Some zones (Infernal Rackets Backstage, The Laugh Floor and Cobb's Knob Barracks are the only ones currently known) check to see how many turns have been spent in the zone since the last noncombat before doing the C/NC roll. If that number is above a certain threshold, the roll is bypassed and you automatically get a noncombat, as though you had rolled it. Everything proceeds normally from there.
Ok, so now you know whether you're getting a combat or a noncombat. How does it choose among the possible alternatives? First we'll go through noncombats, because they're simpler.
Building the list
Once the die roll to determine C/NC is done, the game builds up a list of available adventures. For noncombats, this is solely a check to see if you meet the conditions on the adventures in the zone. Yes, that's right, any adventure can have a condition. These can be things like delay() (immateria, rampaging adding machine) or number of turns spent since it was last seen (Strung-Up Quartet, O Cap'm, My Cap'm), or even a die roll to see you can get the adventure at all (Izchak's, Astronomers). If you don't meet those conditions, the adventure isn't added to the list.
Choosing an adventure
Once the list is built the game rolls another die, this time 1DN_NC, where N_NC is the number of noncombats in the zone that pass the above cut (for the ballroom this would be either 1 or 2, you can always get curtains, and sometimes you can get curtains and the quartet). The adventures have numbers, and whichever number is rolled is the choice moving forward.
Checking the Queue
But it doesn't end there, thanks to the Adventure Queue. The queue is a list of the 5 most recently seen noncombats or combats, and every zone has both a combat and noncombat queue. A given c or nc can be in the queue multiple times. What does the queue do? If the chosen adventure is in the queue, it rolls a 1D4, and if the number rolled isn't a 4 it rejects that c/nc and rolls again among the possible c/nc choices (but still in that particular type). If the adventure is not in the queue, this step is skipped.
If you're confused look at the flowchart, it's much better at displaying this info.
You've just opened the ballroom and are looking to set the song. You've spent a few turns looking for it, and have already hit Curtains a couple times. So your queue looks like:
[Curtain,Curtain,_,_,_] (where the underscores are empty spots).
The next time you get a nc, the game builds up the noncombat list. Let's say you haven't met the conditions for the song yet, so there's only 1 possible NC, so the game picks it. It still checks the queue, and let's say it rolls a 3. It rerolls the 1D1 (useful!) and picks curtains. It rolls the 1D4 again, this time it's a 4. You get a curtains.
You keep adventuring, and the game rolls you another noncombat. This time you meet the conditionals for the song, so it rolls a 1D2. It picks curtains and goes to the queue, then rolls a 2, so it rolls the 1D2 again. This time it picks the ballroom song. It's not in the queue, so you get it. You set it to -combat, and move on.
Building the List
Combats by and large follow the same structure as noncombats. Once you've rolled a combat, the game builds up the list of available encounters. The first difference is that when you're building up the list you have to take into account olfaction. If a monster is olfacted, 4 times as many copies are added as normal (so if there is typically 1 monster, there are 4, if there are normally 2, there are now 8, and so on). The second difference is that any banished monster isn't added (unless it's olfacted, you can't banish olfacted monsters). Additionally, if you've banished every encounter in a zone (for some reason), they all become available again. Conditions are checked in the same way as ncs.
Choosing an adventure
Then the game rolls the 1DN_C, where N_C is the number of combats in the list. This is the same as for noncombats.
The final difference comes in the olfaction check. If the rolled combat is currently olfacted it skips the queue entirely, and that's your combat.
After that it proceeds with the Adventure Queue checks, as in noncombats. For a combat that is in the queue, 3/4 times the combat is rerolled, and 1/4 times it proceeds and that's your combat. I illustrated most of this above, so I'm not going to go through an example here. If you're confused look at the flowchart, it should make things pretty clear.
When an adventure type can't happen
There is one more thing to worry about, and that's what happens if the game rolls a noncombat but there's no suitable adventure. For instance, let's say you're on the poop deck looking for O Cap'm, and let's say you've already unlocked belowdecks. The game rolls a noncombat, but you haven't spent enough turns yet to pass the conditional. It builds up the list for the noncombats, checks O Cap'm's conditionals and it doesn't pass, then check's Swordfish's conditionals and it doesn't pass. It's finished building the list and there are 0 entries, so now it tries to switch to a combat. In this zone there's no problem with that, so you get a combat. This is believed to only happen going from noncombat to combat.