Commit graph

1012 commits

Author SHA1 Message Date
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
1e01df84ff AI: do not use new grab_villages CA for default AI
The old villages CA is quite a bit better at distributing multiple units across multiple villages. The advantage of the new grab_villages CA is that it has a variable score, sometimes grabbing villages before, and sometimes after attacks. This does not outweigh its shortcomings though.

So for now, the default AI will continue to use the previous CA, and the Experimental AI will use the new one. Thus, the two AIs are not quite identical any more (but still very similar).

I also added a todo comment that the grab_villages CA might be reinstated if it is improved.
2019-12-06 08:18:47 -08:00
mattsc
038dc2d7fe AI: remove old retreat_phase CA from AI configs
It is now superseded by the retreat_injured CA (of the former Experimental AI).
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
mattsc
24af20cf83 Experimental AI: show in MP menu in debug mode only
It is now identical to the default AI, so we only show it in debug mode in the MP computer player selection menu. It will be moved back to be always available when there is new development happening.
2019-11-29 19:22:56 -08:00
mattsc
a38356e61c Experimental AI: add comments that it is now same as default 2019-11-29 19:22:56 -08:00
mattsc
5c285cfde0 AI: copy Experimental AI candidate actions into default AI 2019-11-29 19:22:56 -08:00
mattsc
7bbe5329c1 AI: create copy of the current default AI
... and call it the "1.14 default AI".
2019-11-29 19:22:56 -08:00
mattsc
3bd6613dda AI: Set up macros for Experimental AI candidate actions
In the same way as they are set up for the default 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
74c7c17ec8 Experimental AI: fix AI setup max_score values
The return scores were changed in commit 4999b20bd1, but the max_score values in the configurations have not been updated yet. As the relative ranking was not changed, this should not have any effect on gameplay.
2019-11-21 21:11:34 -08: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
24b11221cf Use wml.array_variables instead of wml.array_access.get/set 2019-11-16 13:09:04 -05: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
Steve Cotton
39c5df7544
Simple Attack Micro AI Demo: Update dialogue for 1.14's AI improvements (#4431)
The default 1.14 already considers high-XP attacks.  Other than the dialogue,
the only change is to reduce the AI's default aggression, so there's more
contrast between what the Micro AI does compared to what the default AI does.

Switched to typographic quotation marks in the dialogue, and removed double
spaces between sentences.
2019-10-06 06:46:00 +02:00
mattsc
036bf8b6ae Experimental AI: fix poisoners ignoring [avoid] tag 2019-10-05 19:24:40 -07:00
Severin Glöckner
9c099d5d07 remove TODOs regaring overlays 2019-10-02 03:50:39 +02:00
Severin Glöckner
6da85e9042 switch from map_data to map_file in SP 2019-10-02 02:54:25 +02:00
mattsc
f5b6b50565 Experimental AI: fix guardians being used for village actions 2019-09-19 19:16:48 -07:00
Martin Hrubý (hrubymar10)
6f468a3757
Migrate links to https if available
Closes #3343
2019-09-08 07:53:28 +02:00
Steve Cotton
1c123fb3fa Allow '1-infinity' in ranges, and tighten the schema's validation of ranges
Fixes #4253.

The schema's validation of ranges now rejects negative numbers, because the C++
code doesn't support them (both before and after this commit):
* utils::parse_range("-7") will return {0,0}, because std::stoi("") throws invalid_argument.
* src/map/location.cpp will parse it as -7, but that will never match an on-map coordinate
2019-08-29 22:28:22 +02:00
gfgtdf
ef06634485 use overlay effect over [unit] overlays= 2019-08-25 22:29:49 +02:00
gfgtdf
5cb93694c6 move loyal overlays to the loyal trait
since the recent changes to overlays= in particular 1a7724e547,
e71033374c and b2cd1cf6c [unit]overlays= is no longer the
recommended way to add an overlay and the use of the
apply_to=overlay effect is reccomended instead, so adding it
to the [trait] is the most natural option here.

this in particular fixes #4058 . Also people simply forgetting the
IS_LOYAL macro was a not-so-uncommon cause of bugs.

In some cases people want to give the LOYAL trait without giving the
loyal overlays for those cases i added a optional OVERLAY parameter to
the {TRAIT_LOYAL} macro, also heroes should now use {TRAIT_LOYAL_HERO}
instead which uses the hero overlay. The IS_LOYAL and IS_HERO macros are
no longer needed in combination with those traits.
2019-08-25 20:36:35 +02:00
mattsc
e148d25d2a ExpAI grab villages CA: fix enemy distance rating under fog
ai_helper.get_closest_enemy() returns math.huge for the enemy distance if no enemy is visible to the AI. This fixes #4157.
2019-07-10 08:07:11 -07:00