In general, the units specified in the MAI setup should be on the AI side. However, that might change during a scenario, for example when there is an event that switches units to other sides.
The final determination of the hex to move to must take enemies into account, otherwise the MAI might try to move the unit to a hex it cannot actually reach.
Numerical values are sometimes transferred from WML to Lua using the string type. This applies, for example, to very small numbers, such as 0.0000000000001. This needs to be taken into account when checking whether avoid_enemies is a number.
Previously, a rabbit hole item on the map border could be selected for spawning a new rabbit, resulting in an error message on screen and abandoning the CA for the rest of the turn.
Another efficiency improvement. This ensures that the side of the unit
is checked first before the potentially complex rest of the filter is
evaluated.
fixes#1649 . ai.synced_command could easily be used to implement all types of
undeteced cheats so it was removed. As a replacement this commit adds a
[custom_command] synced command that just calls
wesnoth.game_events.on_synced_command which calls a lua handler that
must first be set.
The previous version caused errors under some circumstances when an
event removed units other than the attacker during or immediately after
an AI attack.
This is done by ignoring shroud for path finding (while still taking
hidden units into account correctly), consistent with default Wesnoth
AI behavior.
This is not necessary for most other Micro AIs, but this AI moves many
units per execution for speed reasons. If an ambush or failed teleport
or similar happens, it is better to reconsider rather than pull through
with the rest of the moves.
ai_helper.get_attacks() now excludes hidden enemies by default -> they
need to be specifically included if they are to be attacked, as opposed
to having to be excluded when not.
This is not necessary for most other Micro AIs, but this AI moves
several units per execution. If an ambush or failed teleport or similar
happens, it is better to reconsider rather than pull through with the
previously planned moves.
This is not necessary for most other Micro AIs, but this AI moves
several units per execution. If an ambush or failed teleport or similar
happens, it is better to reconsider rather than pull through with the
previously planned moves.
Note that this requires that the enemy filter in the utils function now
matches the enemy units to be attacked, while previously it was set to
all enemy units NOT matching the filter. As this is not used anywhere
else, that’s not a problem, it’s just noted here for completeness.
Previously, the Micro AI behavior was inconsistent at best when it came
to dealing with these units and could even result in AI errors when an
AI unit was ambushed or a petrified unit was in the way of a move. Now,
both types of units are properly "ignored" and the AI moves have been
made robust against unexpected events such as ambushes. Incidentally,
the latter also makes the AI more robust against WML events doing
things the AI cannot know about (such as removing units).
There is essentially no time saving involved with doing it all in one
execution as all tables need to be reevaluated for each unit anyway in
order to adapt to potential changes due to ambushes or WML events. (The
latter is not all done yet, will be added in a follow-up commit.)
There is essentially no time saving involved with doing it all in one
execution as all tables need to be reevaluated for each unit anyway in
order to adapt to potential changes due to ambushes or WML events. (The
latter is not all done yet, will be added in a follow-up commit.)