41 Commits

Author SHA1 Message Date
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
59397a40b5 ExpAI recruiting: fix AI crash for unit type with unknown race 2018-11-13 06:53:20 -08:00
mattsc
c1343227e2 Generic recruit engine: cache pathfinding data
This results in a significant speed-up starting from the second recruit each turn.
2018-11-06 09:44:03 -08:00
mattsc
e379cf7333 Generic recruit engine: replace slow location filters 2018-11-06 09:38:33 -08:00
mattsc
0c57ae16e4 Lua AIs: do not use hard-coded values for modifiable parameters 2018-11-05 20:22:11 -08:00
mattsc
e3b2cbfc25 ExpAI recruiting: consider all villages not owned by allies
Instead of only the unowned villages.
2018-11-05 07:19:23 -08:00
mattsc
8676d3eaf1 ExpAI recruiting: add optional 'enemy_types' parameter
Ths is the enemy type list to be considered if the AI has no information about the enemies to expect, that is, if no enemy units are on the map and no enemy recruit lists can be found. It can be used to prepare AI recruiting for enemy sides that get added later during a scenario.
2018-11-02 15:43:14 -07:00
mattsc
a831edda6b ai_helper.get_closest_enemy: change return values
This is done for consistency with similar functions in mainline, and so that the function actual returns what it name says. This breaks backward compatibility, but note that the only practical difference for that is the order in which the arguments are returned, as both 'closest_enemy' and 'location' contain the enemy location in .x/.y format.
2018-10-27 16:24:13 -07:00
mattsc
c5e41497e1 generic_recruit_engine: remove unnecessary variable assignment
(cherry-picked from commit a7811395363f9edd1a40adb11e0748bd0b81c385)
2018-10-07 03:24:56 +00:00
mattsc
56934ad576 Lua AIs: use ai_helper.get_locations_no_borders()
(cherry-picked from commit dcadab91a418f4f7392bab2544367df580d46ecf)
2018-10-07 03:24:56 +00:00
mattsc
7e63932c8e Lua AIs: remove commented-out debug code
(cherry-picked from commit 23f35546fc31c6345acc24624039f16a92bbb8b7)
2018-10-07 03:24:52 +00:00
mattsc
4999b20bd1 Experimental AI: adjustments to candidate action scores
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 35ba82050954c2cee86321e05d6706993c08e143)
2018-10-07 03:24:51 +00:00
mattsc
e78237c2a9 recruit_rushers CA: don't reserve village for passive leader
(cherry-picked from commit b92d8e822639a90ca8bbfeaf8dea606e7cf4c8f2)
2018-10-07 03:24:51 +00:00
mattsc
59c7162b51 Experimental AI: fix eval/exec debug output
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 c2635abde1c6eea8bb74019ab78c61bddb219fff)
2018-10-07 03:24:43 +00:00
mattsc
8799772621 Lua AIs: don't compare variables with nil
... unless there is a difference between nil and false. Done mostly for consistency with all the other uses.

(cherry-picked from commit 35d257f8fd35fad70539dfdc57da69e38bc10536)
2018-10-07 03:24:43 +00:00
mattsc
f761493c75 Lua AIs: no need to set variables to nil explicitely
This is mostly done for consistency across the Lua AI code

(cherry-picked from commit 0e7c09f7b549bb43aec248bad04fcf0bffef17d5)
2018-10-07 03:24:40 +00:00
mattsc
08825afce5 Lua AIs: remove inclusions of unused libraries
(cherry-picked from commit 8a996c55b968b14b04a551db46b7ab3de735696f)
2018-10-07 03:24:39 +00:00
mattsc
3906d78abd Lua AIs: avoid using __cfg for accessing weapon specials
(cherry-picked from commit aa59ac54557bc24615cb3f990bcd1dbf6f5d1ea9)
2018-10-07 03:24:39 +00:00
mattsc
fbbbcfc67e Lua AIs: replace print() by std_print()
(cherry-picked from commit 3f54908b0ba69173442107105889caeb891b922d)
2018-10-07 03:24:36 +00:00
mattsc
25b2024ee8 Lua AIs: use unit methods instead of wesnoth functions
(cherry-picked from commit a6866390dfa64097fa4cb099b39736c3e2220ce4)
2018-10-07 03:24:36 +00:00
mattsc
0c707294cb Experimental AI recruiting: use math.huge instead of 9e99
(cherry-picked from commit a6c0012689b39d74e2d9578f17010a048ef7d296)
2018-10-07 03:21:29 +00:00
mattsc
f1eacc51ad Experimental AI: clear recruit cache when no recruit action found
(cherry-picked from commit f810504306f7b97bd5e532793b36591ada8ba671)
2018-10-07 03:21:29 +00:00
mattsc
9b6f933ded Fix Experimental AI not working without enemy units
An example are the first two turns of Dark Forecast.

(cherry-picked from commit a65605c54726a391cc05d1bb75761966a8088cac)
2018-10-07 03:21:29 +00:00
mattsc
1c88a6d8c8 Do not load helper.lua where it is not used any more
(cherry-picked from commit 4b6681a300f29eab3b5adcf3b12df8bc6ad455dd)
2018-10-07 03:21:10 +00:00
mattsc
cb1bc56478 Remove unnecessary inclusions of helper.set_wml_action_metatable {}
(cherry-picked from commit 1684e2f5daa6b84906186b101c83a6a017b07581)
2018-10-07 03:21:10 +00:00
mattsc
4586e04eca Lua code: replace deprecated helper.child_range() calls
(cherry-picked from commit 7c137e1a336559acdd6f797192a9516135480b2e)
2018-10-07 03:21:09 +00:00
mattsc
58529e95f8 Lua code: replace deprecated helper.get_child() calls
(cherry-picked from commit f0bb40590fe1a9c2c6683157f9aa93b631848251)
2018-10-07 03:21:08 +00:00
Celtic Minstrel
6efc5ae090 Replace helper.distance_between -> wesnoth.map.distance_between (fixes #1686) 2017-05-11 04:14:03 -04:00
Celtic Minstrel
8d4cf3cf62 Shorten requires where possible 2017-05-03 02:42:25 -04:00
mattsc
f2406ac829 Experimental AI: correctly deal with hidden and petrified units 2016-10-19 07:37:19 -07:00
mattsc
3d0c29b7fc Experimental AI: do not let AI try to recruit on fogged/shrouded hexes
The engine will refuse to recruit on shrouded hexes, which will result
in part or all of the rest of the AI actions to be disabled.  Fogged
hexes may cause problems also if there is an enemy unit on them.

This fixes at least part of bug #25112.
2016-09-24 19:17:39 -07:00
mattsc
3f2df87bed Recruit rushers AIs: adapt syntax to recent AI changes
This caused an error message and recruiting to be abandoned when the
recruit rushers Micro AI was used for two different sides in the same
scenario.  It was only presents since the AI refactoring done during
1.13.4+dev and did not affect any release.
2016-07-27 19:58:22 -07:00
Celtic Minstrel
c79874086d MicroAIs: Update all to use the new [args] syntax
Except for Protect Unit, all of them seem to still work correctly.
2016-03-27 15:13:21 -04:00
mattsc
496a58d343 Experimental AI: use checked versions of the AI actions
So that only valid actions are executed and useful error messages are
produced if something goes wrong.
2014-02-28 07:04:54 -08:00
mattsc
3e6e7caa74 Put 'done_eval_messages()' behind 'if print_eval()' condition
... so that they only get printed when this sort of debug output is
selected.
2013-10-31 20:54:00 -07:00
mattsc
d355adbacb Clean up time stamps and debug output code 2013-10-31 20:31:37 -07:00
Alarantalara
c859d0d17b Keep villages unreachable by recruited unit
If the recruited unit cannot reach the target village, try again later
2013-10-31 23:14:36 -04:00
Alarantalara
33c1e493b2 Handle more damage specials for Lua recruiting 2013-10-31 23:14:35 -04:00
mattsc
b826e5ead5 Micro AIs: make recruit_rushers work with new external CA method
The previous code did not allow to get the ai table to the execution
function.
2013-10-30 09:42:41 -07:00
mattsc
7e0a05ed6e Experimental AI: consistently use underscores in AI ids and file names
This is the last step of making everything use consistent syntax.
2013-07-10 20:37:30 -07:00