This AI is meant as a fall-back AI for scenarios where there are so
many units that attacks and moves done by the default AI are slow with
long delays before each move. It replaces the default combat and
move-to-targets candidate actions.
See http://wiki.wesnoth.org/Micro_AIs
This was an idea we tried so that we’d start with the most uncertain
attack first, but it did not work very well.
Keep the code for now, just comment it out.
That’s what wesnoth.simulate_combat() does, but is different from the
other functions in battle_calcs. Only hp_chance[0] needs to be set,
even if it is zero.
In rare cases (when the unit has no hexes to move to, not even the one
it is on because it is in a zone to be avoided), this would cause an
error and crash the AI.
If several Goto MAIs are used on the same side and both have
unique_goals=yes set, they previously might have interfered with each
other, one preventing the other from working correctly. Now the “goal
taken” information is saved such that it only applies to the CA by
which it was set.
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.
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.
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.
There was a typo in the goal table indexing. It worked for the
multi-unit test scenario (the Elves Besieged) because the goal x
coordinates for both units were the same.
It’s theoretically possible that different Micro AIs’ evaluation
functions store information in the same variable within self.data.
This would only happen if the CAs have the same score and while this
should generally be avoided when setting up a scenario, it is better to
ensure that it cannot cause conflicts (not in the stored data at least,
the MAIs might still interfere with each other in other respects).