The ai_helper functions are optimized for speed (as much as possible in a general setting) and do all the necessary tests. For example, get_units_with_attacks() checks both whether the unit has attacks left, and whether it has any attacks in the first place.
(cherry-picked from commit 75843541bc)
ai_helper.robust_move_and_attack() does the stop_unit_moves automatically if the unit is at the destination hex.
(cherry-picked from commit fdc3249496)
The relative ranking of the CA scores is not changed, except for one case when two CAs had the same score.
Reasons:
- All scores should be lower than the scores of the default Goto CA (200,000) and the default scores of most Micro AIs (300,000).
- Break tie, resulting in uncertain order of execution, of place_healers and retreat_injured CA. Healers should be placed first, to allow retreating injured units to adjacent hexes.
- Set default for generic_recruit_engine to slightly above default AI recruiting score. That way it takes effect even if the default CA is not removed.
- Increase move_to_any_enemy CA score from 1 to 1,000. It is still the lowest score that way, but allows for setting up custom CAs with even lower scores (even if it is just for end-of-turn statistics or the like).
(cherry-picked from commit 35ba820509)
Now that all the AIs use external CAs, there is no need to use the persistent 'data' variable any more, unless information is to be exchanged between different CAs or is supposed to be persistent across save/load cycles.
(cherry-picked from commit 3bfd59f28b)
It probably doen't make a noticeable difference for these AIs, but in general we should not call the slow functions more than necessary.
(cherry-picked from commit 42b4430841)
This involves making the output independent of the stats CA (which is not used any more) and adding missing output to some CAs.
(cherry-picked from commit c2635abde1)
Most of the Fast MAI attack utils had been taken from a more general codebase and included things not needed here. This AI is supposed to be a slimmed down version doing only the absolutely necessary in as fast as possible a fashion.
(cherry-picked from commit f4f2a441e4)
The main reason for doing this, besides simplifying the code, is to avoid using the WML table dump __cfg, which is slow. This includes a change of the format in which the variables are stored, but since these are internal Micro AI utility functions, that does not matter.
(cherry-picked from commit 133568efe6)
These used to be accessible only through unit.__cfg or wesnoth.unit_types. The Fast Micro AI is not included here as it requires a larger clean-up.
(cherry-picked from commit 8af988c697)
Another efficiency improvement. This ensures that the side of the unit
is checked first before the potentially complex rest of the filter is
evaluated.
(cherry-picked from commit 6c38b8ce93)
This is for efficiency reasons, as location filters do not necessarily
change throughout a side’s turn, while fewer and fewer units have moves
left.
(cherry-picked from commit 0dcbe1d0d0)
The old method is very slightly faster in some circumstances (e.g. for
simple filters and when all units have moves/attacks/etc. left), but we
are talking fractions of micro seconds. By contrast, depending on the
filter used, the new method can save large amounts of evaluation time
once some units have move or attacked.
(cherry-picked from commit 972ecc2f56)
- Fix the rabbit AI
- Enable invoke_synced_command to also call (some) built-in commands
and give an error message in the case of an unknown command
- Remove some unnecessary implementation details