Commit graph

737 commits

Author SHA1 Message Date
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
972ecc2f56 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.
2018-06-07 06:44:55 -07:00
mattsc
a6c0012689 Experimental AI recruiting: use math.huge instead of 9e99 2018-05-20 14:55:17 -07:00
mattsc
f810504306 Experimental AI: clear recruit cache when no recruit action found 2018-05-20 14:55:01 -07:00
mattsc
a65605c547 Fix Experimental AI not working without enemy units
An example are the first two turns of Dark Forecast.
2018-05-20 14:54:45 -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
08a000a7da Lua code: remove deprecated helper.set_wml_var_metatable() call
It’s not needed here.
2018-05-13 20:52:40 -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
f1764d182f Lua code: replace deprecated wesnoth.get_variable() calls 2018-05-13 20:03:34 -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
3a90f86674 Addressed more whitespace issues from #2613
[ci skip]
2018-03-12 03:48:59 +11:00
Charles Dang
471c9e876a Addressed a large chunk of the whitespace issues from #2613
[ci skip]
2018-03-09 11:37:00 +11: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
Celtic Minstrel
dabf09fce1 Fix deprecation spam
This removes the Lua deprecation_message function in favour of exposing the C++ variant to Lua instead.
It also moves all deprecation messages to a separate logdomain, making them easily enabled en masse.
2018-03-04 21:21:33 -05:00
Charles Dang
4bf5c9341f Revert "Remove invalid attribute from idle AI"
This reverts commit 1d84d83c6c.

I had introduced use of the hidden= key in b2df837d8e, but
apparently didn't add them to the valid list of non-aspect keys.
2018-02-22 12:21:20 +11:00
Jyrki Vesterinen
1d84d83c6c Remove invalid attribute from idle AI
It was interpreted as a simplified aspect, resulting in a warning when
loading a replay.

Found with WML unit tests.
2018-02-21 22:34:11 +02: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
3b2077fdc3 Fast Micro AI ai_helper functions: fix rarely occurring bug
When the AI moves a unit out of the way for another unit’s move, it is
occasionally possible for the former unit to use up all its movement
points (e.g. if it has few MP or on narrow crowded maps). If that unit
is on the list to be moved later during the same sequence, this caused
ai_helper.robust_move_and_attack() to return nil, which then made the
Fast Micro AI produce an error message.
2017-11-08 22:33:24 -08:00
Charles Dang
b2df837d8e Hide AIs with hidden=yes from list of available AI options (fixes #2095)
This is enough to hide them as AI options in the UI, but I don't know if other parts of the AI
engine need to know about this key.
2017-10-11 08:41:38 +11:00
mattsc
70bd919631 Idle AI: remove from data/ai/dev after all
It was left there in cfb2aa8050 for backward compatibility. However,
this causes a “duplicate AI” error at start-up in debug mode.
Furthermore, the file is not included in any current 1.12 or 1.13
add-on, so it should be safe to remove it. Using
[ai]ai_algorithm=idle_ai is the preferred option to include the Idle AI.
2017-10-05 08:34:37 -07:00
mattsc
f097c3d7f6 Idle AI: add to comment on when empty [stage] tag is needed 2017-10-04 16:48:08 -07:00
mattsc
cfb2aa8050 AIs: idle_ai is not a "Dev AI", fixes #1955
As indicated in the comment of the idle_ai config file, an AI needs to
contain at least one stage, otherwise the default AI will be injected
under certain circumstances. Unlike indicated in the comment, this now
also applies to loading a mid-scenario save. (I will add that to the
comment in the next commit.)

As this AI was in data/ai/dev/, it was previously only loaded when
Wesnoth was started in debug mode. The config was thus not available
when playing in no-debug mode, causing the default AI to be injected on
reload. This caused issue #1955.

While not strictly necessary, we keep a redirect in data/ai/dev for
backward compatibility, in case the file is included in add-ons.
2017-10-04 16:48:08 -07:00
mattsc
d53243daa9 Fast Micro AI: fix typo from commit 6efc5ae090 2017-10-03 20:55:34 -07:00
Jozrael
e175bb1c7d Fix crash when unable to find closest enemy. 2017-10-02 14:43:16 -07:00
mattsc
a673e64d44 FAI files: remove trailing whitespaces 2017-10-01 13:43:27 -07:00
mattsc
6751172282 Poisoner FAI: prevent passing empty list to min(), fixes #1999
The WFL min() function was changed from returning zero to returning an
error when an empty list is passed as argument (commits eccd3d8e and
fd9f1153).  This adapts the Poisoner FAI code to deal with that
correctly.
2017-10-01 13:41:35 -07:00
Celtic Minstrel
d192f07123 Implement standard deprecation system for Lua API
(as proposed by @DeFender1031)

All existing deprecation messages in the Lua code have been changed to
use the new deprecation system.

The goal is to eventually use an equivalent system for ALL areas of the API.
2017-08-14 12:36:09 -04: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
f6c04e7dd1 Add functional.lua which implements higher-order functions
This covers all the main higher-order functions included in WFL, except zip.
The two already implemented in ai_helper have been replaced with redirection stubs.
2017-05-10 17:40:20 -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
37f1c490a5 Lua: Use the second argument to error() where appropriate 2017-05-10 17:40:13 -04:00
Celtic Minstrel
e945755793 Accidentally committed this 2017-05-08 13:52:31 -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