Don't make monsters 'flee' seemingly at random (7645)

Specifically, ranged monsters would flee a few spaces after you
went upstairs, to minimize stairdancing vs centaurs and such.
(Good!) If you waited a few turns before going back down, they'd
be left in the 'fleeing' state, which looked extremely strange to
players. (Bad!) This fixes the latter.
Replace a loop with a distribution (PleasingFungus)
Use an unwind_var for restoration.

In case someone later adds an early return.
Refactor catchup_monster_moves
Remove a redundant check
Fix a bad tag in debug mode x-over-an-upstair.
Fix a return type.

Doh.  Copy-pasted from player_under_penance.
Avoid an MSVC debug assertion and C++03 u.b. (johnny0)

We were using operator[] to access one-past-the-end of a std::string,
expecting a null terminator.  However, in C++03, this is only allowed
with the const version of operator[], producing undefined behaviour
with the non-const version.  In particular, MSVC with _SECURE_SCL
(default for debug builds) would throw a runtime exception.

Adjust the bounds of the loop so we don't iterate up to the last
character.  This doesn't change the behaviour in non-crashing cases,
because the one-past-the-end '\0' is not a VAR_CHAR and would break
the loop anyway.

We could use a const_cast<const string &> or a constify template
instead, but this version is less code.