Dances with Trolls

Say you have three trolls that wish to accost our plucky protagonist as is only right and proper roguelike. In a tight corridor this can lead to problems.

   #######
   .TTT.@.
   #######

If the most or almost most distant troll has the highest priority, their move may fail as they cannot move any closer to the hero. This may lead to delays advancing on the hero, especially if the monster closest to the hero is the slowest, and those behind it stack up on it wasting many turns.

One might fix this problem by allowing monsters to swap or trample or push aside one another, possibly based on the relative sizes of the monsters (Angband?), or whether the monsters are of the same species (Brogue?), or whatever.

However swapping may lead to degenerate behavior if the more distant troll has higher priority (moves sooner, assuming an integer energy system) than the one adjacent to the hero:

   #######
   ..TT@..
   #######

The more distant troll moves, swapping with peer. Then, the now more distant troll is up, and swaps with the other troll. Repeat. At no point would the monsters a chance to attack the hero, as they had always been pushed aside. This might be corrected for by making the attack phase distinct from the move phase; that is, after moves are done monsters that moved then check whether they can make an attack. (Monsters that did not move would not check for attack, as their number did not come up in the energy system, and presumably they're stuck in limbo until their number does come up.) In this case, after the higher priority but more distant troll swaps, it would then attack the hero, and avoid the "do nothing" swap problem.

Another solution would be to defer moves, so in the original conga line case the most distant monsters who want to move but cannot would get pushed onto a "TODO" list, or maybe have 0 energy set so they come up again the next check, and those monsters would be retried again and again until things clear out or there have been too many retries. Like, they're ready to move right away, pending the right condition opening up. The "too many retries" check is to prevent a softlock condition; maybe the troll fell into a trap that prevents motion for some amount of time, but the energy system says they have a move, they can't, still pending, retry, retry, retry, …

Moves that happen at the same time are another edge case to worry about, assuming the movement system allows for moves to happen at the exact same time. Under an integer energy system, this would be when two mobiles or entities or whatever both activate at the same time (hit zero energy during the same pass over the entities). Perhaps both of them want to move to the same square because that square has better footing or whatever:

   #######
   ..T,@..
   #######

One can resolve this by moving the entities in the order they appear in the entities list, which may favor the hero if they (typically) appear more towards the beginning of said list. Another solution would be to allow multiple entities to occupy the same cell, which is not typical for roguelikes but has seen use in e.g. Archon (1983) where moving to the same square then caused a battle for that square, much like how in Ultima one switched from the overmap to a battle-specific scene when overmap characters collide. Or maybe instead of a sub-battle there's some automatic resolution of the collision, possibly animated and with suitable messages, "you wrestle with the troll!" However in a roguelike given the above snapshot, the player would expect to be able to move to the comma first, and breaking that expectation may be problematic. This means the game will need to update the current view just before the player is set to go (something that can be difficult to get right if you're meshing an energy loop with a UI loop, and are the monsters always acting on non-stale information, like where they aim?), though again a monster could move at that exact same instant according to the energy system. The player usually does not have insight into the inner workings of this system (maybe someone knows of a roguelike where this is the case?), though the state could be conveyed via the raw numbers or a message "the Troll looks ready to move!"

has some energy systems in the event you have no idea what those are and wish to learn more in a complicated way