We had huge discussions about retreating in beta. There are a number of issues that cannot be coded to meet all situations such as the game has no concept of which direction stacks are facing when in battle, which should dictate in which direction they would retreat.
I just wrote up a suggestion last night in one of the developer forums after losing 2 armies in RUS and possibly a third shortly due to weird retreats.
What happens during a retreat? Lose a battle, game engine consults algorithm, game engine plots retreat move.
What if: Lose a battle, game engine checks for a player designated retreat city, game engine plots and executes move to designated retreat city. If there is no player designated retreat city, use normal retreat algorithm to plot and execute move.
So give the player the option to designate a retreat city during the plotting portion of the move. If battle is lost, game engine checks to see if a retreat city is designated. If yes, ignore retreat algorithym, plot move to retreat city. If no, use retreat algorithm.
Note, it doesn't matter where or when the battle takes place. Lose a battle anywhere or anytime, game engine plots quickest move to retreat city and executes. It is the same process as now but instead of using the algorithm to determine where to plot and execute the move, the designated retreat city is used to determine where to plot and execute the move.
The algorithm gives good results most of the time but not all the time. And people have been complaining about the occasional weird and disasterous retreat since the original BOA years ago.
Keeping fingers crossed that it is doable.