mattsc
81ef9ea390
Merge pull request #3506 from mattsc/lua_ai_cleanup
...
Lua AI Cleanup
2018-09-22 06:18:33 -07:00
Severin Glöckner
c5cabd960b
Micro AI Demos: use Cme instead of Chw for lurkers map
...
[ci skip]
2018-09-14 22:50:31 +02:00
Severin Glöckner
c5d3539880
Micro AI Demos: save maps in new format
...
[ci skip]
2018-09-14 22:50:31 +02:00
mattsc
dcadab91a4
Lua AIs: use ai_helper.get_locations_no_borders()
2018-09-07 09:50:42 -07:00
mattsc
fdc3249496
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.
2018-09-04 07:16:56 -07:00
mattsc
45a3bf9363
Lua AIs: replace tabs with spaces
2018-09-02 15:08:24 -07:00
mattsc
3bfd59f28b
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.
2018-09-02 13:20:34 -07:00
mattsc
62625fd5e2
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.
2018-09-02 08:54:31 -07:00
mattsc
42b4430841
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.
2018-09-01 14:29:51 -07:00
mattsc
35d257f8fd
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.
2018-08-30 17:37:12 -07:00
mattsc
a23f06dc20
Lua AIs: don't initiate variables as empty tables
...
... if they might not be needed.
2018-08-30 17:27:18 -07:00
mattsc
80ae232935
Herding Micro AI: fix variabls not being local
2018-08-30 07:23:41 -07:00
mattsc
cb423b2fbd
Lua AIs: use math.huge to initialize extrema variables
2018-08-30 07:18:04 -07:00
mattsc
f4f2a441e4
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.
2018-08-29 19:26:49 -07:00
mattsc
1680436f72
Lua AIs: remove another unused library inclusion
2018-08-29 08:48:30 -07:00
mattsc
8a996c55b9
Lua AIs: remove inclusions of unused libraries
2018-08-29 08:00:32 -07:00
mattsc
133568efe6
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.
2018-08-27 18:39:41 -07:00
mattsc
b3058e8e8e
Messenger MAI Lua code: change proxy unit location directly
2018-08-27 07:13:18 -07:00
mattsc
a6866390df
Lua AIs: use unit methods instead of wesnoth functions
2018-08-27 07:05:43 -07:00
mattsc
d4213371b1
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.
2018-08-15 12:13:55 -07:00
Martin Hrubý (hrubymar10)
bc4d22dc72
Migrate links to https if available - Fwd c18537edc0
2018-07-16 19:07:08 +11:00
mattsc
6c38b8ce93
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.
2018-06-07 06:45:30 -07:00
mattsc
0dcbe1d0d0
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.
2018-06-07 06:45:14 -07:00
mattsc
4b6681a300
Do not load helper.lua where it is not used any more
2018-05-13 20:53:01 -07:00
mattsc
1684e2f5da
Remove unnecessary inclusions of helper.set_wml_action_metatable {}
2018-05-13 20:52:51 -07:00
mattsc
3c792fc7d7
Lua code: replace deprecated helper.[gs]et_variable_array() calls
2018-05-13 20:52:17 -07:00
mattsc
7c137e1a33
Lua code: replace deprecated helper.child_range() calls
2018-05-13 20:52:08 -07:00
mattsc
f0bb40590f
Lua code: replace deprecated helper.get_child() calls
2018-05-13 20:51:56 -07:00
mattsc
5e5a9e69e5
MAI test scenarios: remove uses of deprecated MESSAGE macro
2018-05-13 15:41:10 -07: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
Charles Dang
134353f863
Further cleanup of deprecated Lua API usecases (inc. ones from fef953a
)
...
[ci skip]
2018-03-17 00:41:32 +11:00
gfgtdf
fef953a48e
remove ai.synced_command
...
fixes #1649 . ai.synced_command could easily be used to implement all types of
undeteced cheats so it was removed. As a replacement this commit adds a
[custom_command] synced command that just calls
wesnoth.game_events.on_synced_command which calls a lua handler that
must first be set.
2018-03-16 13:43:05 +01:00
Charles Dang
33725add8f
Data/AI: wmlindent run
...
[ci skip]
Addresses some of the whitespace issues noted in #2613 .
2018-03-09 11:07:23 +11:00
mattsc
85b46f34b0
Fast Micro AI: make code robust against events removing units
...
The previous version caused errors under some circumstances when an
event removed units other than the attacker during or immediately after
an AI attack.
2018-02-11 08:05:58 -08:00
Matthias Krüger
b11d3fdcbe
fix a bunch of typos found by codespell in data directory.
...
https://github.com/lucasdemarchi/codespell
2018-02-06 23:03:06 +11:00
mattsc
b7efaadec4
Protect Unit Micro AI: fix typo/bug in AI aspect change
2017-11-27 06:54:14 -08:00
mattsc
d53243daa9
Fast Micro AI: fix typo from commit 6efc5ae090
2017-10-03 20:55:34 -07:00
Celtic Minstrel
4b8e37044c
Micro AIs: Fix Lua error in AIs that use unit variables
2017-05-11 16:00:51 -04:00
mattsc
24891d85e2
Lua AIs: remove unused library inclusions after distance_between change
...
Follow-up to 6efc5ae090
2017-05-11 10:22:00 -07:00
Celtic Minstrel
6efc5ae090
Replace helper.distance_between -> wesnoth.map.distance_between ( fixes #1686 )
2017-05-11 04:14:03 -04:00
Celtic Minstrel
0539a68eb4
Migrate ai_helper.LS_random_hex to location_set:random
2017-05-10 17:40:21 -04:00
Celtic Minstrel
9b635994e1
Add location_set.(of|to)_triples (migrated from ai_helper)
2017-05-10 17:40:14 -04:00
Celtic Minstrel
5da2d71a20
Move [micro_ai] implementation to data/lua/wml
2017-05-03 02:45:54 -04:00
Celtic Minstrel
8d4cf3cf62
Shorten requires where possible
2017-05-03 02:42:25 -04:00
Celtic Minstrel
f45d795134
fixup 0f01f97b
(GNA25615)
2017-03-23 17:00:51 -04:00
Celtic Minstrel
0f01f97b30
Update Micro AIs to use new Lua API functions for altering AI
2017-03-20 12:00:21 +11:00
mattsc
3236a4b085
Micro AIs: fix some MAIs not working under shroud
...
This is done by ignoring shroud for path finding (while still taking
hidden units into account correctly), consistent with default Wesnoth
AI behavior.
2016-12-09 18:59:52 -08:00
mattsc
acecd77bb4
Lua AIs: use new syntax for iterating over attacks
...
This is both simpler and faster than the old syntax.
2016-10-22 13:54:32 -07:00
mattsc
93f95f1d4c
Fast Micro AI: better recovery from ambushes etc.
...
This is not necessary for most other Micro AIs, but this AI moves many
units per execution for speed reasons. If an ambush or failed teleport
or similar happens, it is better to reconsider rather than pull through
with the rest of the moves.
2016-10-21 20:57:16 -07:00