Commit graph

1020 commits

Author SHA1 Message Date
mattsc
2b3824f44c Retreat injured CA: do not take villages from ally 2022-06-22 07:51:46 -07:00
mattsc
fdb931bb16 Remove Lua AI code deprecated at level 3 in 1.15 2022-06-21 19:15:00 -07:00
Celtic Minstrel
473c6e468e
Fix wmlindent quote detection (#6764)
* wmlindent: Fix parsing quotes in comments

* Remove unnecessary wmlindent ignores

* Run wmlindent
2022-06-18 09:37:55 +02:00
mattsc
1769b6cf01 Protect Unit MAI: fix typo in MAI removal code 2022-06-11 06:18:51 -07:00
Celtic Minstrel
d886ddf61c Lua: Fix a leaky global function 2022-06-10 23:31:40 -04:00
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
mattsc
84531b834e Bottleneck Micro AI: fix bug involving units without moves
An integral part of this MAI is that it moves weaker units out of the way for stronger ones.  Units without moves are taken into account by giving them a very high rating.  This was previously only done on what's considered the AI's territory (the AI side of the bottleneck) which works fine most of the time since the AI does not try to move onto enemy territory.  However, it breaks down on more open maps, where there are way for units to move around the bottleneck, as AI territory is not always well defined on them.  However, there is no need to restrict this to AI territory only.

This fixes #6599.
2022-06-09 06:29:14 -07:00
mattsc
768b930fc4 ai_helper: fix visibility bug in get_attackable_enemies()
The passed filter needs to be enclosed in an [and] tag, otherwise the check for visibility might not work correctly, for example if the filter contains a top level [or] tag.
2022-06-04 09:13:53 -07:00
Pentarctagon
9bfd432abe Update image pages for webp extension. 2022-04-30 14:23:32 -05:00
Celtic Minstrel
759b040069 fix whitespace
The whitespace-fixing script seems to be slightly different depending on the platform.
Even though it produces no effect in the CI, it made these changes locally on my Mac.
I'm committing them now so as to avoid unrelated files being changed in other pull requests.
2022-02-06 00:05:09 -05:00
mattsc
7746f75f11 Wolves multipack MAI: prevent potential for infinite loop
The MAI was set up to be blacklisted if no attacks were found, but that did not always work. In addition, removing attacks from the wolves also means that no other CA can use them for other attacks instead.
2021-12-28 18:31:19 +01: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
Pentarctagon
254716e41e Expand lua whitespace check. 2021-11-28 14:26:02 -06:00
Celtic Minstrel
ce9bea0537 AI: Add an example of using [micro_ai] in [side][ai] 2021-09-04 22:20:28 -04:00
Celtic Minstrel
2d95c0f7d3 AI: Convert the FormulaAI example scenario to do all the same things using Lua
- Unit formulas are replaced by inline MicroAIs or candidate actions placed in the unit's [ai] tag.
  - The stationed_guardian MicroAI was chosen as the closest match to the guardian FormulaAI. It's not a perfect fit, but it's pretty close.
  - The goto and patrol MicroAIs are fairly obvious substitutes for the respective unit formulas.
  - The priority test in unit formulas is replaced by fairly basic inline non-external CAs with differing scores.
- The side formulas (opening.fai) have been converted to a separate Lua stage using a new opening.lua. However, that's only a partial conversion. The move and attack functionalities of opening.fai are missing from opening.lua; instead the built-in move, move leader to keep, and combat CAs are used.
- The scouting FormulaAI CA has been ported to Lua. It remains a very basic AI, probably not well-suited to genera use.
- The level up attack FormulaAI CA has been ported to Lua. Like the new scouting CA, this is mostly intended to serve as an example.
2021-09-04 22:20:28 -04:00
Celtic Minstrel
5d70dd9aca Lua: Add a new ai_helper debug function to print a simulate_combat HP distribution more succinctly 2021-09-04 22:20:28 -04:00
Celtic Minstrel
9fdaea5893 AI: Fix error in stationed_guardian 2021-09-04 22:20:28 -04:00
mattsc
b73078884c Messenger MAI: fix bug of own units blocking waypoint
ignore_own_units=true was accidentally dropped when adding [avoid] tag functionality to the Micro AI in a60736b6c7
2021-09-01 08:49:54 -07:00
Celtic Minstrel
632941b03d Lua AI: Fix a typo 2021-07-30 19:22:57 -04:00
Celtic Minstrel
4ec60b99d9 Lua: Update all mainline references to the helper module 2021-07-07 01:32:05 -04:00
Celtic Minstrel
9c2689ac9e Lua AI: Move the deprecation messages to Lua so that the deprecated functions get nulled out with --strict-lua 2021-07-02 14:04:53 -04:00
Celtic Minstrel
91f6bf93a4 Fix a broken deprecation and replace some deprecated uses
Fixes #5877
2021-06-20 00:59:59 -04:00
Celtic Minstrel
7f162cbd24 Lua: Rename find_vacant_tile to find_vacant_hex for naming consistency 2021-06-19 17:09:31 -04:00
Celtic Minstrel
1f62eae3ce Replace uses of wesnoth.find_path 2021-06-19 15:43:33 -04:00
Celtic Minstrel
5a1e38e99b
Add wesnoth.sync module for the synchronization-related commands (#5862) 2021-06-19 15:39:10 -04:00
Celtic Minstrel
f145dc2bba Replace uses of the moved interface functions 2021-06-19 12:09:46 -05:00
Celtic Minstrel
a03d59d7eb Lua: Add a new schedule module
The primary components of this are:
- wesnoth.current.schedule
- wesnoth.map.get_time_area()
- wesnoth.schedule module
2021-06-19 11:07:53 -04:00
Celtic Minstrel
0c42cdc038
Enable translation mark validation by the schema (#5800)
- The t_string type is now a schema built-in type and no longer attempts a regex match.
- You can also specify that non-t_string types may be optionally-translatable; this case supports a regex match on the string (but note that the translation mark is not part of the match).
- Error messages involving keys with very large values ( > 128 characters) will now truncate the value.
- To account for occasional cases where the schema is intentionally violated, the --validate command-line option now automatically defines the SCHEMA_VALIDATION preprocessor define.

A key validates as type t_string if one of the following is true:
- The key is not present
- The key has at least one segment with a translation mark
- The key is blank (an empty string)

Any type other than t_string is not allowed to be translatable by default, unless you specify allow_translatable=yes in the [type] tag.

An optionally-translatable string could also be defined as a union of t_string and some other type.
2021-06-14 23:59:52 -04:00
mattsc
d8e472e753
Merge pull request #5609 from mattsc/mai_fix_replay
Micro AIs: fix unit variables being lost in replays
2021-06-10 11:42:50 -07:00
mattsc
0a56a1af5d ai_helper.lua: remove unused variable 2021-05-22 13:33:50 -07:00
Celtic Minstrel
6584302d41
Merge pull request #5537 from wesnoth/lua_reorg
Various Lua reorganization work
2021-05-11 19:12:40 -04:00
Celtic Minstrel
bf746a0207 Update mainline content to use the wesnoth.scenario module 2021-05-11 14:52:21 -04:00
Celtic Minstrel
e8381ea9da Update uses of eval_conditional 2021-05-11 14:52:20 -04:00
Hejnewar
16c8fcc49c Remove remaining uses of wesnoth.special_locations 2021-05-10 11:26:12 +02:00
Celtic Minstrel
1dccc3ad76 Update mainline content to use the mathx module 2021-05-08 17:20:49 -04:00
Celtic Minstrel
1fc31c23d0 Replace all uses of get_time_stamp -> ms_since_init 2021-05-08 17:20:49 -04:00
Steve Cotton
de3e798e72 Update the animals Micro-AI demo with boars and piglets
This adjusts to the change in e7b5996e98.

The micro ai itself is unchanged, it's still controlled by `tusker_type` and
`tusklet_type`, it simply needed the new unit ids to be used in this scenario.
2021-04-04 20:23:46 +02:00
mattsc
f1c37f64ac
Merge pull request #5630 from mattsc/remove_fai_uses
Remove Formula AI uses
2021-03-24 08:04:47 -07:00
Celtic Minstrel
7c95e9d1a4 Lurker FAI: map(x, self) is exactly the same as just self
This caused the crash fixed in the previous commit. Although the crash is fixed, it's still stupid and we shouldn't do it.
2021-03-23 00:34:44 -04:00
mattsc
8d03d3ef08 Swarm Micro AI: add optional parameter [filter] 2021-03-22 09:09:30 -07:00
mattsc
4086758214 Remove Formula AI lurkers from Lurkers test scenario
This is part of removing Formula AI uses from mainline.
2021-03-21 17:15:43 -07:00
mattsc
92d22f18e6 Remove Home Guardian Formula AI from Guardians test scenario
This is part of removing Formula AI uses from mainline.
2021-03-21 17:03:50 -07:00
mattsc
f462416111 Remove MP dev (debug) AIs
This is part of removing Formula AI uses from mainline.  These are just small experimental additions to the default AI that have been superseded by more recent additions to the AI.
2021-03-21 16:51:11 -07:00
mattsc
4fe45bf22a Patrol Micro AI: add two optional parameters
attack_range: the patrol interrupts its route to attack enemies within this distance, not just enemies that it happens to end up next to

attack_invisible_enemies: include invisible enemies when considering whether there are enemies within attack_range

The default behavior is unchanged.
2021-03-21 14:56:37 -07:00
mattsc
ac9246aba1 Micro AIs: fix unit variables being lost in replays
Some Micro AIs save information in unit variables. Examples are the patrol and messenger AIs, which save the next waypoint for a unit. This needs to be done as a synced command, so that the information is not lost when continuing a game from a replay.
2021-03-13 19:36:56 -08:00
mattsc
a60736b6c7 Messenger Micro AI: add [avoid] tag functionality 2021-03-13 17:20:09 -08:00
mattsc
0c4d8ebbe6 ai_helper.lua: add 'avoid_map' functionality to move_unit_out_of_way()
Also add comment about passing it through from robust_move_and_attack().
2021-03-13 17:16:50 -08:00
mattsc
a50415b5e1 ai_helper.get_closest_location: add avoid_map parameter 2021-03-13 17:16:50 -08:00
mattsc
b56a44ed66 ExpAI recruiting: prevent potential divide-by-zero 2021-03-07 14:46:04 -08:00
mattsc
373559b6bf Protect Unit Micro AI test scenario: fix deprecated WML 2021-03-06 16:45:57 -08:00