799 Commits

Author SHA1 Message Date
mattsc
30e1fd1742 Bottleneck Micro AI: simplify a conditional
Use elseif and no need to check experience again, that is already done earlier.
2018-11-09 06:57:07 -08:00
mattsc
bc956b3e7f Lua AIs: fix experience for killing level 0 units 2018-11-09 06:52:08 -08:00
mattsc
1856377d35 Lua AIs: distinguish between healing locations and villages
There are rating contributions for hexes which heal (not all of which are villages) and others for hexes that provide income (villages). Previously only villages were considered for both types of hexes.
2018-11-07 12:24:31 -08:00
mattsc
8bca955ad5 ai_helper: new function get_healing_locations() 2018-11-07 12:17:55 -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
5e0df80ad0 ExpAI retreating: take healthy trait into account 2018-11-05 07:02:46 -08:00
mattsc
dcf951434e Micro AIs: support named locations for [micro_ai] tag keys 2018-11-05 07:02:33 -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
873bf2f390 Multipack Wolves MAI: add [avoid] tag functionality
This includes both adding an [avoid] tag to the MAI itself, and taking the default AI [avoid] tag into account. If both are given, the former takes precedence over the latter.
2018-11-01 18:10:38 -07:00
mattsc
d7418ab8e2 Wolves Micro AI: take default AI [avoid] tag into account 2018-11-01 18:07:21 -07:00
mattsc
abaa2dcc84 Swarm Micro AI: add [avoid] tag functionality
This includes both adding an [avoid] tag to the MAI itself, and taking the default AI [avoid] tag into account. If both are given, the former takes precedence over the latter.
2018-11-01 18:05:17 -07:00
mattsc
7579d181c0 Goto Micro AI: add [avoid] tag functionality
This includes both adding an [avoid] tag to the MAI itself, and taking the default AI [avoid] tag into account. If both are given, the former takes precedence over the latter.
2018-11-01 08:03:24 -07:00
mattsc
f11700119a Micro AIs: use ai_helper.get_reachmap()
There are no functionality changes in this commit, it's simply switching over to the new ai_helper function. Changes to the MAI functionalities will be added separately.
2018-10-31 15:45:48 -07:00
mattsc
df4065c061 ai_helper: new function get_reachmap()
This is a generalized version of ai_helper.get_reachable_unocc(). It can include or exclude hexes with own units with moves > 0. It also allows passing an optional location set 'avoid_map' with hexes to be excluded.

In principle, this makes get_reachable_unocc() unnecessary, but we keep that function for backward compatibility.
2018-10-30 07:37:52 -07:00
mattsc
10b0631143 Micro AIs: use ai_helper.get_avoid_map()
There are no functionality changes in this commit, it's simply switching over to the new ai_helper function. Changes to the MAI functionalities will be added separately.
2018-10-29 07:26:07 -07:00
mattsc
ae22b2e08f ai_helper: new function get_avoid_map()
The goal is to add [avoid] tag capabilitiy to most Micro AIs.
2018-10-29 07:06:46 -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
5c73537412 ai_helper.lua: deprecate some functions 2018-10-26 07:19:13 -07:00
mattsc
cd8af96607 ai_helper.find_best_move: return nil instead of {} if no move found
This is done for consistency with similar functions in mainline. In principle this breaks backward compatibility.  However, while it is theoretically possible for this to happen, this function will generally always return at least the hex the unit is on, so it is very unlikely that this actually makes a difference somewhere.
2018-10-26 07:19:13 -07:00
mattsc
41bd835f76 Old patrol.lua: deprecation message should not be translatable 2018-10-24 19:53:45 -07:00
mattsc
e3b86f5648 Lua AIs: increase deprecation level of old ai/lua/patrol.lua 2018-10-24 19:51:53 -07:00
mattsc
5fe283d06c Lua AIs: use wesnoth.label instead of wml_action_metatable 2018-10-24 19:50:09 -07:00
mattsc
09e3891668 ai_helper.move_unit_out_of_way: prevent potential for divide-by-zero
dx = dy = 0 is a perfectly acceptable choice of values when there is no preferred direction.
2018-10-21 19:30:34 -07:00
Severin Glöckner
a10888ca5b Micro AI Demos: use Cme instead of Chw for lurkers map
[ci skip]

(cherry-picked from commit c5cabd960b257c258fda8e40d927ed427c595df9)
2018-10-07 03:25:08 +00:00
Severin Glöckner
ccaa9b75ed Micro AI Demos: save maps in new format
[ci skip]

(cherry-picked from commit c5d353988045c6f8099948a14c935507f80a7a39)
2018-10-07 03:25:08 +00: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
319c98d616 ai_helper: new function get_locations_no_borders()
(cherry-picked from commit 10463fdf608ade3ff223a58ad7cc43a1e475b803)
2018-10-07 03:24:56 +00:00
mattsc
46efcf15fd Lua AIs: use ai_helper get_unit functions where applicable
The ai_helper functions are optimized for speed (as much as possible in a general setting) and do all the necessary tests.  For example, get_units_with_attacks() checks both whether the unit has attacks left, and whether it has any attacks in the first place.

(cherry-picked from commit 75843541bcf92e743b911ef49046c54a050e8a0f)
2018-10-07 03:24:55 +00:00
mattsc
44ceaa1874 ai_helper: get_unit functions should only return live units
Live beiing defined as in get_live_units(), that is, non-petrified units

(cherry-picked from commit a7d80240f2ca11b01e14120f80cd9ecace3eaa85)
2018-10-07 03:24:54 +00:00
mattsc
fc6d71b023 Lua AIs: use ai_helper.robust_move_and_attack()
ai_helper.robust_move_and_attack() does the stop_unit_moves automatically if the unit is at the destination hex.

(cherry-picked from commit fdc3249496e7c2418a8ab8c7ec19b85bba3f79fb)
2018-10-07 03:24:53 +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
9e5ec5f060 Experimental AI: rename config file
This stopped being a rush AI long ago.

(cherry-picked from commit ec45b53fe29d00d25204f67a8c1ea95c86f01d9e)
2018-10-07 03:24:51 +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
aea3a4f7cb recruit_rushers CA: check if castle_switch CA is present
So that it is possible to use the recruit_rushers CA without the castle_switch CA.

(cherry-picked from commit 0bcb98cf5026710871d8b90919752c90808c56d0)
2018-10-07 03:24:50 +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
b47d6e3bdb Protect Unit MAI: remove unused configuration variables
They cannot be set for the MAI, and they would have to be set through 'cfg' not 'data' anyway.

(cherry-picked from commit 62625fd5e2821472181c53932ffe7f6b264373c5)
2018-10-07 03:24:48 +00:00
mattsc
2b6b1ed4fe Lua AIs: avoid calling wesnoth.get_terrain() more than needed
It probably doen't make a noticeable difference for these AIs, but in general we should not call the slow functions more than necessary.

(cherry-picked from commit 42b443084125ab7a989465e5f7f19835a17ba85b)
2018-10-07 03:24:45 +00:00
mattsc
800947594c Experimental AI: convert to using external CAs
(cherry-picked from commit 547478571871ffe59c5cf7ff59339a72a61c07dc)
2018-10-07 03:24:44 +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
e68a6eaba0 Lua AIs: don't initiate variables as empty tables
... if they might not be needed.

(cherry-picked from commit a23f06dc2052ece4d6de9fc1d80008f82761be4f)
2018-10-07 03:24:42 +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
3c558c7360 Herding Micro AI: fix variabls not being local
(cherry-picked from commit 80ae232935f2bbe5d0eb97c5a15136f8dc625068)
2018-10-07 03:24:40 +00:00
mattsc
37e83f1262 Lua AIs: use math.huge to initialize extrema variables
(cherry-picked from commit cb423b2fbd40fdf5e14549a301fee06237bf4626)
2018-10-07 03:24:40 +00:00