AI helper functions: code cleanup, first pass

These function libraries are still work in progress and change
frequently, so the code cleanup is mostly just to make sure the syntax
is consistent with that used in the Micro AIs.  Changes or improvements
to the algorithms might be made at a later time.
Fix a typo
battle_calcs.lua: avoid using formula= in SUFs

It’s slow for finding units with moves or attacks left. The alternative
method of getting all units and then looping over the table with a
condition is much faster.
ai_helper.lua: avoid using table.remove

It’s slow. The inverse logic using table.insert is much faster,
especially for large tables.
Protect Unit MAI test scenario: use fight_on_without_leader=yes

So that the scenario continues even if the side 2 leader is killed.
Micro AIs: don't check for specific value of move rating

Don’t check whether rating equals (or doesn’t equal) -9e99 or the like,
verify that a valid move was found instead.  Also, avoid setting
variables to empty tables if not needed.
always allow SAVE_REPLAY

We diallow save game during action because that would lead to broken saves, but this is not true for save_replay.
If, for some reason, we get stuck inside a an action we cannot save the game, with this we can at least save the replay in this case and create a vaild save with the 'replaying + saving durign replay' strategy.
fix 21933

durign human turns, we now use check_victory which impied check_end_level, just like we du during ai turns.
we also set tm->set_lost() before calling check_turn_end to that the lost_ value is also correct when ending with [endlevel]
add a check_victory after moves.

perviously it was possible that a moveto event removed units and we didnt get victory/defeat.