24 Commits

Author SHA1 Message Date
mattsc
fe0b375fca ExpAI castle switch CA: fix error when stored leader has been killed
The castle switch CA stores the leader move because the evaluation is expensive.  If the leader was killed in between storing and reevaluation of the CA, this would previously cause an on-screen error message and the CA to be blacklisted for the turn.

This fixes #6440.
2022-06-09 07:51:33 -07:00
Pentarctagon
370d03ccb7 Fix luacheck warnings and add to CI.
Note the `exclude_files` in .luacheckrc should be deleted once the eventual Ubuntu 22.04 base image has an updated luacheck that supports lua 5.4.
2021-11-28 14:26:02 -06:00
Celtic Minstrel
1f62eae3ce Replace uses of wesnoth.find_path 2021-06-19 15:43:33 -04:00
Celtic Minstrel
1fc31c23d0 Replace all uses of get_time_stamp -> ms_since_init 2021-05-08 17:20:49 -04:00
Celtic Minstrel
9d3bf196b0 Update everything to use the new wesnoth.map module
- get_terrain and set_terrain replaced with direct indexing operations
- get_map_size mostly replaced with either the iterator or an on_board call.
  Only a few cases really needed to know the size of the map for some other purpose.
- shroud and fog operations, village owner, time areas, and location filters
- get_terrain_info replaced with terrain_types table
- Map generation functions create_map and create_filter
2021-02-28 18:16:33 -05:00
Celtic Minstrel
56bdd42815
Fix segfaults and a few other issues in wesnoth.find_path
Co-authored-by: mattsc
2021-02-18 22:15:31 -06: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
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
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
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
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
1816ee5249 AI: add [filter_own] to all Experimental AI candidate actions 2019-11-21 19:15:11 -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
56934ad576 Lua AIs: use ai_helper.get_locations_no_borders()
(cherry-picked from commit dcadab91a418f4f7392bab2544367df580d46ecf)
2018-10-07 03:24:56 +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
c52ce11e49 Lua AIs: replace tabs with spaces
(cherry-picked from commit 45a3bf93636fb7b34b27a3411784d0484eeb18d6)
2018-10-07 03:24:49 +00:00
mattsc
ed406495d7 Lua AIs: do not use engine's 'data' variable unless necessary
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 3bfd59f28ba7f70a6ac32782e98cba9ca6c2a44a)
2018-10-07 03:24:48 +00:00
mattsc
800947594c Experimental AI: convert to using external CAs
(cherry-picked from commit 547478571871ffe59c5cf7ff59339a72a61c07dc)
2018-10-07 03:24:44 +00:00