Stardew Valley : Exits appearance in mines

stardew-valley

I was wondering how exits appear while mining in Stardew Valley.

I though about two possibilities :

1- Each time you mine a rock, there is a chance an exit appears. The probability get greater and greater to make sure you can find a way out.

2 – The number of exits is calculated and placed depending on the floor size / number of rocks. Then, rocks are added to "hide" them.

Of course, in both cases, "extra exits" can appears after killing an enemy.

I'm wondering which one is the most likely to be true.

Best Answer

I decompiled the source and found that approach 1 is how this was implemented (as of V1.07). When breaking a rock the likelihood of a ladder being placed is inversely proportional to the number of rocks left and directly proportional to the luck level of the player and the daily luck level. When breaking the last block you will have a 100% chance of getting the ladder regardless of the other factors.

Interestingly enough from the quick look I had it seems like the game only intends for a single ladder to spawn this way, but I have also observed multiple ladders spawning when breaking rocks. It looks like this might be a bug, but without really digging into the code it is hard to say if this is actually intended.

As a bonus it looks like there is often (about 95% of the time) an attempt to place a ladder when populating the level, but if the block that is randomly picked is blocked in any way it will not spawn the ladder.