Commit graph

1020 commits

Author SHA1 Message Date
mattsc
56934ad576 Lua AIs: use ai_helper.get_locations_no_borders()
(cherry-picked from commit dcadab91a4)
2018-10-07 03:24:56 +00:00
mattsc
319c98d616 ai_helper: new function get_locations_no_borders()
(cherry-picked from commit 10463fdf60)
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 75843541bc)
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 a7d80240f2)
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 fdc3249496)
2018-10-07 03:24:53 +00:00
mattsc
7e63932c8e Lua AIs: remove commented-out debug code
(cherry-picked from commit 23f35546fc)
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 ec45b53fe2)
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 35ba820509)
2018-10-07 03:24:51 +00:00
mattsc
e78237c2a9 recruit_rushers CA: don't reserve village for passive leader
(cherry-picked from commit b92d8e8226)
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 0bcb98cf50)
2018-10-07 03:24:50 +00:00
mattsc
c52ce11e49 Lua AIs: replace tabs with spaces
(cherry-picked from commit 45a3bf9363)
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 3bfd59f28b)
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 62625fd5e2)
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 42b4430841)
2018-10-07 03:24:45 +00:00
mattsc
800947594c Experimental AI: convert to using external CAs
(cherry-picked from commit 5474785718)
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 c2635abde1)
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 35d257f8fd)
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 a23f06dc20)
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 0e7c09f7b5)
2018-10-07 03:24:40 +00:00
mattsc
3c558c7360 Herding Micro AI: fix variabls not being local
(cherry-picked from commit 80ae232935)
2018-10-07 03:24:40 +00:00
mattsc
37e83f1262 Lua AIs: use math.huge to initialize extrema variables
(cherry-picked from commit cb423b2fbd)
2018-10-07 03:24:40 +00:00
mattsc
613ccd859a Fast Micro AI: code cleanup
Most of the Fast MAI attack utils had been taken from a more general codebase and included things not needed here. This AI is supposed to be a slimmed down version doing only the absolutely necessary in as fast as possible a fashion.

(cherry-picked from commit f4f2a441e4)
2018-10-07 03:24:40 +00:00
mattsc
02c830a6df Lua AIs: remove another unused library inclusion
(cherry-picked from commit 1680436f72)
2018-10-07 03:24:39 +00:00
mattsc
08825afce5 Lua AIs: remove inclusions of unused libraries
(cherry-picked from commit 8a996c55b9)
2018-10-07 03:24:39 +00:00
mattsc
6ad4c7e42d Lua AI utility functions: fix for chance-to-hit specials without id
All mainline chance-to-hit weapon specials have ids, but it is not required for UMC specials.

(cherry-picked from commit 5335a2af33)
2018-10-07 03:24:39 +00:00
mattsc
3906d78abd Lua AIs: avoid using __cfg for accessing weapon specials
(cherry-picked from commit aa59ac5455)
2018-10-07 03:24:39 +00:00
mattsc
695fa69238 Micro AIs: simplify unit variable handling functions
The main reason for doing this, besides simplifying the code, is to avoid using the WML table dump __cfg, which is slow. This includes a change of the format in which the variables are stored, but since these are internal Micro AI utility functions, that does not matter.

(cherry-picked from commit 133568efe6)
2018-10-07 03:24:38 +00:00
mattsc
b5c8c60ad0 Lua AIs: get unit cost/level directly from proxy unit
These used to be accessible only through unit.__cfg or wesnoth.unit_types.  The Fast Micro AI is not included here as it requires a larger clean-up.

(cherry-picked from commit 8af988c697)
2018-10-07 03:24:37 +00:00
mattsc
fbbbcfc67e Lua AIs: replace print() by std_print()
(cherry-picked from commit 3f54908b0b)
2018-10-07 03:24:36 +00:00
mattsc
98e5f0892e Lua AIs: remove unused debug output
(cherry-picked from commit 83c4ef2418)
2018-10-07 03:24:36 +00:00
mattsc
5bc44fcc0d Messenger MAI Lua code: change proxy unit location directly
(cherry-picked from commit b3058e8e8e)
2018-10-07 03:24:36 +00:00
mattsc
25b2024ee8 Lua AIs: use unit methods instead of wesnoth functions
(cherry-picked from commit a6866390df)
2018-10-07 03:24:36 +00:00
mattsc
35df7f6ba0 Fast Micro AI: fix for chance-to-hit specials without id
All mainline chance-to-hit weapon specials have ids, but it is not required for UMC specials.

(cherry-picked from commit d4213371b1)
2018-10-07 03:24:16 +00:00
Martin Hrubý (hrubymar10)
674fda85b7 Migrate links to https if available - Fwd c18537edc0
(cherry-picked from commit bc4d22dc72)
2018-10-07 03:23:36 +00:00
mattsc
22ca458bfd Goto Micro AI: add [and] to a filter
Another efficiency improvement.  This ensures that the side of the unit
is checked first before the potentially complex rest of the filter is
evaluated.

(cherry-picked from commit 6c38b8ce93)
2018-10-07 03:22:21 +00:00
mattsc
6a64e6e37e Goto Micro AI: change order of SLF and SUF evaluation
This is for efficiency reasons, as location filters do not necessarily
change throughout a side’s turn, while fewer and fewer units have moves
left.

(cherry-picked from commit 0dcbe1d0d0)
2018-10-07 03:22:21 +00:00
mattsc
674a39a43e AI helper: improve efficiency of get_unit functions
The old method is very slightly faster in some circumstances (e.g. for
simple filters and when all units have moves/attacks/etc. left), but we
are talking fractions of micro seconds. By contrast, depending on the
filter used, the new method can save large amounts of evaluation time
once some units have move or attacked.

(cherry-picked from commit 972ecc2f56)
2018-10-07 03:22:20 +00:00
mattsc
0c707294cb Experimental AI recruiting: use math.huge instead of 9e99
(cherry-picked from commit a6c0012689)
2018-10-07 03:21:29 +00:00
mattsc
f1eacc51ad Experimental AI: clear recruit cache when no recruit action found
(cherry-picked from commit f810504306)
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 a65605c547)
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 4b6681a300)
2018-10-07 03:21:10 +00:00
mattsc
cb1bc56478 Remove unnecessary inclusions of helper.set_wml_action_metatable {}
(cherry-picked from commit 1684e2f5da)
2018-10-07 03:21:10 +00:00
mattsc
49b1ef9549 Lua code: remove deprecated helper.set_wml_var_metatable() call
It’s not needed here.

(cherry-picked from commit 08a000a7da)
2018-10-07 03:21:09 +00:00
mattsc
f48f566afd Lua code: replace deprecated helper.[gs]et_variable_array() calls
(cherry-picked from commit 3c792fc7d7)
2018-10-07 03:21:09 +00:00
mattsc
4586e04eca Lua code: replace deprecated helper.child_range() calls
(cherry-picked from commit 7c137e1a33)
2018-10-07 03:21:09 +00:00
mattsc
58529e95f8 Lua code: replace deprecated helper.get_child() calls
(cherry-picked from commit f0bb40590f)
2018-10-07 03:21:08 +00:00
mattsc
05d5afa6a9 Lua code: replace deprecated wesnoth.get_variable() calls
(cherry-picked from commit f1764d182f)
2018-10-07 03:21:06 +00:00
mattsc
c98fad3791 MAI test scenarios: remove uses of deprecated MESSAGE macro
(cherry-picked from commit 5e5a9e69e5)
2018-10-07 03:21:04 +00:00
Celtic Minstrel
c266b35528 Fix rabbits AI being broken by save-load 2018-03-17 17:16:22 -04:00
Celtic Minstrel
23aac4f72f Cleanup of fef953a48e
- Fix the rabbit AI
- Enable invoke_synced_command to also call (some) built-in commands
  and give an error message in the case of an unknown command
- Remove some unnecessary implementation details
2018-03-17 16:48:00 -04:00