284 Commits

Author SHA1 Message Date
Pentarctagon
5af1f129cd Mass convert of *^Uf terrain for SP. 2020-09-15 09:26:00 -05:00
mattsc
a666a34055 ai_helper.next_hop: fix bug in fan-out code
This fixes the case when the unit cannot reach the previously found next_hop location from the ideal next_hop location in the part of the code that tries to keep units from moving in single file.
2020-07-07 20:14:11 -07:00
mattsc
396b258203 AI retreat CA: bug fix for cure-only abilities
That is, those that cure poison, but do not provide any healing.
2020-02-11 12:10:43 -08:00
mattsc
5f05ae31d6 ai_helper: deprecate has_ability() 2020-01-01 20:50:32 -08:00
mattsc
800c943221 ai_helper.has_ability: restore previous functionality
Before the recent change, the ability type (tag name) was checked. It then got changed to ability id. This commit changes it back to the old behavior.

For the record, there are situation when either the id or the type is needed. In addition, one sometimes wants to check wheter the ability is active (or will be active). Thus, no matter how this is done, neither will serve all purposes and sometimes other functions/functionality should be used. This commit does, however, restore the previous behavior and thus preserves backward compatibilty.
2020-01-01 20:33:59 -08:00
mattsc
34e3c9103f AI: convert leader related aspects to variants 2019-12-31 20:33:19 -08:00
mattsc
926662216a AI: allow list of ids for two passive leader aspects
In addition to 'yes' and 'no', comma separated lists of leader ids are now also accepted as values for these aspects. This allows setting the behavior only for specific leaders.
2019-12-30 19:43:28 -08:00
mattsc
c81ecca23b Experimental AI: do not target units without advancements in high_xp_attack CA 2019-12-30 19:43:28 -08:00
mattsc
a90964fd41 ai_helper: deprecate has_weapon_special() 2019-12-19 07:09:13 -08:00
mattsc
68bb48ddf1 Lua AIs: fix uses of new unit functions
I switched to using defense_on() and resistance_against() incorrectly in 55478e20. I had tested these, but apparently for cases when it does not make a difference ...

The change for movement_on() is for convenience and consistency with other code only.
2019-12-18 09:23:23 -08:00
mattsc
f1e8807330 ai_helper.has_ability: add optional parameter 'exact_match'
The default behavior is unchanged.
2019-12-18 07:40:16 -08:00
mattsc
f2df220579 Lua AIs: eliminate usages of __cfg
These are cases for which the respective variable was not accessible otherwise when the code was originally written.
2019-12-18 07:21:33 -08:00
mattsc
55478e20ad Lua AI code: update deprecated functions 2019-12-17 07:34:48 -08:00
mattsc
d650a8336d
Merge pull request #4600 from mattsc/expai_ca_merge
Merge Experimental AI candidate actions into the default AI
2019-12-15 14:15:55 -08:00
mattsc
0806a2bbe1 AI spread poison CA: take attacks aspect into account 2019-12-11 07:12:10 -08:00
mattsc
6a3015f0e2 battle_calcs.lua: fix bug in relative_damage_map() 2019-12-07 19:08:48 -08:00
mattsc
009a9ef2da AI spread poison CA: apply aggression aspect
In the same way as it is done in the combat CA
2019-12-07 08:02:00 -08:00
mattsc
1ba7e9c76c AI spread poison CA: use more complete attack rating
battle_calcs.attack_rating() includes most of the contributions to the previous rating, plus a lot more.
2019-12-07 08:01:43 -08:00
mattsc
2cc8cce0e8 AI: use ai_helper.robust_move_and_attack() in all CAs 2019-12-06 08:18:47 -08:00
mattsc
96dd9c1712 AI castle switch CA: use leader-specific cheapest recruit cost 2019-12-06 08:18:47 -08:00
mattsc
f8a9238e3f ai_helper.get_cheapest_recruit_cost: add optional input 'leader' 2019-12-06 08:18:47 -08:00
mattsc
a227e768f9 ai_helper.get_cheapest_recruit_cost: add extra recruits 2019-12-06 08:18:47 -08:00
mattsc
fd05a01af5 AI: make recruitment work with multi-leader castle switch
Recruiting itself still only handles one leader. This will be taken care of later.
2019-12-06 08:18:47 -08:00
mattsc
917f7ef9a5 AI castle_switch: reconsider CA score when using saved data
If the units previously on the keep moved off, we don't have to use the low score any more.
2019-12-06 08:18:47 -08:00
mattsc
18b5d5159e AI castle switch: bug fix for units on keep check 2019-12-06 08:18:47 -08:00
mattsc
ab2c3bfcc2 AI: enable multiple leaders in castle_switch CA
Previously the CA would already move multiple leaders if all leaders were to be moved, but it would abandon moving any leader after finding one that should not move.
2019-12-06 08:18:47 -08:00
mattsc
64e969af11 AI: ensure all CAs respect passive_leader aspect
Most of the former Experimental AI CAs did already (or don't use the leader in the first place), but not quite all of them.
2019-12-06 08:18:47 -08:00
mattsc
1391745c9f AI: consider caution in retreat_injured CA
Not retreating at all for caution <= 0 is the same as for the old retreating CA. The rest is specific to this CA.
2019-12-06 08:18:24 -08:00
mattsc
2d86cb20ce ai_helper.find_path_with_avoid: add 'ignore_enemies' option
Note that we do not add an 'ignore_units' option, as allies and enemies are taken into account in different ways and we want to have a way of ignoring each type individually.
2019-12-06 08:14:56 -08:00
mattsc
07d149cbfb ai_helper.next_hop: let units fan out
... as opposed to lining up if there are allied units in the way.

This changes (fixes) the default behavior. An optional 'no_fan_out' parameter is provided in order to restore the old behavior.
2019-12-06 08:14:57 -08:00
mattsc
34956ac15d AI: ensure all CAs respect [avoid] tags
This is for the candidate actions that were merged into the default AI from the former Experimental AI.
2019-12-06 08:14:56 -08:00
mattsc
620da22082 AI: fix score assignment in castle switch candidate action 2019-12-06 08:14:56 -08:00
mattsc
f5990b7e95 ai_helper.get_attackable_enemies: add optional parameter 'avoid_map' 2019-12-06 08:14:56 -08:00
mattsc
891ca93710 ai_helper.put_labels: add two optional parameters 2019-12-06 08:14:45 -08:00
Celtic Minstrel
732b7942bb Replace all references to deprecated functions in the helper module
(and remove the require if this meant it was no longer used)
2019-12-02 01:10:34 -05:00
mattsc
fdb3f2e71a ai_helper.next_hop: add optional parameter 'avoid_map' 2019-11-29 19:22:56 -08:00
mattsc
4e80a8f028 ai_helper.next_hop: add option to use pre-evaluated path 2019-11-29 19:22:56 -08:00
mattsc
bb23781b17 ai_helper: new function find_path_with_avoid()
This lets the AI find paths around areas defined by [avoid] tags, rather than being stopped dead by them. See comments in the code for details.

The relevant custom cost function, custom_cost_with_avoid(), can be accessed directly as well.
2019-11-29 19:22:56 -08:00
mattsc
3e70358d8d AI: ensure all CAs respect unit guardian status
This adds the correct behavior for the castle_switch, move_to_any_enemy and place_healers CAs.  It was already in place for the other former ExpAI CAs (except for recruiting and spread_poison, for which it does not apply).

This automatically also adds this behavior to the Healer Support Micro AI.
2019-11-29 19:22:56 -08:00
Celtic Minstrel
3734bce276 Lua: Replace uses of deprecated (moved) sides functions 2019-11-23 14:41:03 -05:00
mattsc
1816ee5249 AI: add [filter_own] to all Experimental AI candidate actions 2019-11-21 19:15:11 -08:00
mattsc
997e08c5d3 Experimental AI: fix bug in move_to_any_enemy CA
Previously, if the best move found for a unit was its own position, the entire CA would be blacklisted and no other unit would be moved.
2019-11-21 13:04:26 -08:00
mattsc
626d7ee381 AI: add [filter_own] to all default AI candidate actions
This allows restricting each CA individually to only a subset of the units. It also means that several instances of the same CA can be used in the same AI configuration, in order to, for example, force the order in which units are dealt with, or to apply different settings to different units.
2019-11-21 12:09:33 -08:00
Celtic Minstrel
aaa2dc4ece Rollback possibility of wesnoth.get_units matching recall list units
Now it's renamed to wesnoth.units.find_on_map.

wesnoth.units.find implements the case of finding units on either the map or a recall list.
2019-11-15 22:39:09 -05:00
Celtic Minstrel
977f05d77f Lua: Replace uses of deprecated (moved) unit functions
Also backtracked the removal of wesnoth.get_recall_units, which is now available as wesnoth.units.find_on_recall - it's just more convenient than passing x=recall to wesnoth.units.find
2019-11-15 22:39:08 -05:00
mattsc
cbf99a6f00 Fred ExpAI recruiting: set initial conditions for first recruit
Without this, the AI always starts with whatever it considers the best unit without taking the level bonus into account. This mostly only matters when one sets high_level_fraction to a very large value (1 or larger) in order to force only high-level recruits. In other cases it makes no, or no significant, difference.
2019-10-08 13:24:13 -07:00
mattsc
a51dee6761 Exp AI recruiting: add randomness as an optional parameter
This was already an optional parameter for the Recruit Rushers Micro AI.
2019-10-08 12:47:31 -07:00
mattsc
6dc199d4f8 ExpAI recruiting: make high_level_fraction parameter configurable
This also sets its default value to zero, in order to have consistent default behavior with versions from before this parameter was introduced.

It also provides a macro so that the ExpAI can be used with custom parameters in a scenario config, and adds high_level_fraction as an optional parameter to the Recruit Rushers Micro AI.
2019-10-08 12:45:59 -07:00
mattsc
b8d1ef94f0 Experimental AI: make AI recruit higher level units
Because unit cost is penalized in the ExpAI, it recruits almost no higher level units. This adds a bonus for such units to be recruited at approximately the ratio defined in 'high_level_fraction'.
2019-10-08 07:15:47 -07:00
mattsc
036bf8b6ae Experimental AI: fix poisoners ignoring [avoid] tag 2019-10-05 19:24:40 -07:00