Why am I dying with the teleporter when I am in range of open space

I just died in the City of Gold because I thought I knew how the teleporter worked. According to the Spelunky HD Wiki:

Pressing the action button while carrying one will teleport you in the direction you are facing. You will appear a random number of tiles away in the direction you are holding, either 4-8 tiles horizontally or upwards, or 5-9 tiles downwards. Note that you have to jump in order to teleport downwards; otherwise you will just drop the teleporter.

If the destination tile is a solid block, the teleporter tries to find an empty space up to 3 tiles above the selected location - If there is no viable space, the teleporter will warp you into a solid block and you will be killed.

Whenever I use the teleporter, does the game try to find an empty space within the range of the user, then try to find empty space above to put you in, or does the game pick a random number between 4 and 8 and if the tile it wants to put you in is empty it tries to find a tile above?

Consider the following situation:

``````   0  1  2  3  4  5  6  7  8  9
0 [ ][X][X][X][X][X][X][X][X][X]
1 [ ][X][X][X][X][X][ ][X][X][X]
2 [ ][X][X][X][X][X][ ][X][X][X]
3 [ ][X][X][X][X][X][ ][X][X][X]
4 [ ][X][X][X][X][X][ ][X][X][X]
5 [P][X][X][X][X][X][ ][X][X][X]
6 [X][X][X][X][X][X][X][X][X][X]
``````

Where `P` is the player and `X` are filled tiles. If I try to teleport, will I always survive since there is an open tile 6 tiles in front of me, which is within the 4-8 horizontal range or will I probably die because the game has a 3/4 chance of trying to place me on a tile that has no open spaces above me?

In other words, how forgiving is the game with the teleporter? I had space about 6 tiles away, but still died. Did the game decide to put me 5 tiles ahead, find that that tile and all tiles above it were occupied, and telefrag me?

I am aware that there is already an answer to What is the teleporter and how does it work?. However, I want to know why I am dying whenever I theoretically have open space in the destination range and that answer does not go into sufficient mechanical depth.

• Not an answer since I have not used the teleporter much and most of my Spelunky time was not in HD, but the text you quoted from the wiki seems fairly clear that the destination tile is chosen at a random distance, and then it will adjust for an empty space if that tile is blocked but only upwards (up to 3 tiles). If it could go in any direction than that second paragraph would say something along the lines of "tries to find an empty space up to 3 tiles in any direction". Your experience would also seem to confirm this reading. Commented Jan 26, 2017 at 21:05

In your described situation, you've got a 20% chance of surviving the teleport.

From the same line in the wiki you outlined:

Pressing the action button while carrying one will teleport you in the direction you are facing. You will appear a random number of tiles away in the direction you are holding, either 4-8 tiles horizontally or upwards, or 5-9 tiles downwards.

If the destination tile is a solid block, the teleporter tries to find an empty space up to 3 tiles above the selected location - If there is no viable space, the teleporter will warp you into a solid block and you will be killed.

The teleporter does two checks when you use it, the first is picking the space in line with where you use the item; this check does not take into account whether or not you'll survive the teleport. After it's chosen how far you'll travel, then the second check will check the randomly selected space and the three spaces above; if the original space is open, you'll go there, otherwise you teleport to the first open space above. If none of the spaces above are open, then you teleport to the original space and die.

So this situation gives you a 20% chance of survival, where the initial check landing in columns 4, 5, 7, or 8 would mean instant death.

``````   0  1  2  3  4  5  6  7  8  9
0 [ ][X][X][X][X][X][X][X][X][X]
1 [ ][X][X][X][X][X][ ][X][X][X]
2 [ ][X][X][X][X][X][ ][X][X][X]
3 [ ][X][X][X][X][X][ ][X][X][X]
4 [ ][X][X][X][X][X][ ][X][X][X]
5 [P][X][X][X][X][X][ ][X][X][X]
6 [X][X][X][X][X][X][X][X][X][X]
``````

To contrast this, you'd survive this teleport every single time you tried it.

``````   0  1  2  3  4  5  6  7  8  9
0 [ ][X][X][X][X][X][X][X][X][X]
1 [ ][X][X][X][X][X][X][X][X][X]
2 [ ][X][X][X][X][X][X][X][X][X]
3 [ ][X][X][X][ ][ ][ ][ ][ ][X]
4 [ ][X][X][X][X][X][X][X][X][X]
5 [P][X][X][X][X][X][X][X][X][X]
6 [X][X][X][X][X][X][X][X][X][X]
``````