29 Commits

Author SHA1 Message Date
Celtic Minstrel
9d3bf196b0 Update everything to use the new wesnoth.map module
- get_terrain and set_terrain replaced with direct indexing operations
- get_map_size mostly replaced with either the iterator or an on_board call.
  Only a few cases really needed to know the size of the map for some other purpose.
- shroud and fog operations, village owner, time areas, and location filters
- get_terrain_info replaced with terrain_types table
- Map generation functions create_map and create_filter
2021-02-28 18:16:33 -05:00
Celtic Minstrel
3734bce276 Lua: Replace uses of deprecated (moved) sides functions 2019-11-23 14:41:03 -05:00
Celtic Minstrel
aaa2dc4ece Rollback possibility of wesnoth.get_units matching recall list units
Now it's renamed to wesnoth.units.find_on_map.

wesnoth.units.find implements the case of finding units on either the map or a recall list.
2019-11-15 22:39:09 -05:00
Celtic Minstrel
977f05d77f Lua: Replace uses of deprecated (moved) unit functions
Also backtracked the removal of wesnoth.get_recall_units, which is now available as wesnoth.units.find_on_recall - it's just more convenient than passing x=recall to wesnoth.units.find
2019-11-15 22:39:08 -05: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
37e83f1262 Lua AIs: use math.huge to initialize extrema variables
(cherry-picked from commit cb423b2fbd40fdf5e14549a301fee06237bf4626)
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 f4f2a441e41cea635861630eb555af9f510c9b52)
2018-10-07 03:24:40 +00:00
mattsc
25b2024ee8 Lua AIs: use unit methods instead of wesnoth functions
(cherry-picked from commit a6866390dfa64097fa4cb099b39736c3e2220ce4)
2018-10-07 03:24:36 +00:00
mattsc
d53243daa9 Fast Micro AI: fix typo from commit 6efc5ae090 2017-10-03 20:55:34 -07: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
8d4cf3cf62 Shorten requires where possible 2017-05-03 02:42:25 -04: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
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
Celtic Minstrel
e81131fcc5 Add deprecation messages for old AI aspect fetchers
This commit also updates uses of these fetchers in mainline Lua code.
2016-10-17 14:24:51 -04:00
mattsc
b302289402 Micro AIs: correctly deal with hidden and petrified enemies
Previously, the Micro AI behavior was inconsistent at best when it came
to dealing with these units and could even result in AI errors when an
AI unit was ambushed or a petrified unit was in the way of a move. Now,
both types of units are properly "ignored" and the AI moves have been
made robust against unexpected events such as ambushes. Incidentally,
the latter also makes the AI more robust against WML events doing
things the AI cannot know about (such as removing units).
2016-10-16 19:59:19 -07:00
mattsc
f28d4336bf ai_helper.move_unit_out_of_way: normalize dx/dy here
Instead of making it a requirement that they should be normalized by
the calling function.
2016-10-09 14:25:15 -07:00
Celtic Minstrel
c79874086d MicroAIs: Update all to use the new [args] syntax
Except for Protect Unit, all of them seem to still work correctly.
2016-03-27 15:13:21 -04:00
mattsc
f06030b0f5 Fast Micro AI: add support for [avoid] tags
This can either be an [avoid] tag inside the [micro_ai] tag itself, or
the [avoid] tag of the default AI (e.g. as defined in the side
definition).  If both are given, the former has priority.
2015-09-06 13:09:20 -07:00
mattsc
b7907127ae Fast MAI: bug fix for scenarios when there is no enemy leader (for the AI)
In this case, it can happen that there are no goals (e.g. if there are
also no villages or if the AI has no leader). Previously, this
situation caused an error message.
2015-02-12 12:15:04 -08:00
mattsc
b8608b199f Fast MAI: bug fix for leaderless AI sides
Leaderless AI sides cannot capture villages, thus villages should not
be set as goals.
2015-02-12 12:12:27 -08:00
mattsc
053a9350a1 Fast MAI: don't target unowned villages if AI side has no leader
Only enemy-owned villages should be targets for leaderless AI sides.
2014-05-05 07:23:02 -07:00
mattsc
7ef7d14978 Fast Micro AI: use hex 2 steps beyond next hop for move evaluation
It results in a better evaluation of the best hex to move to when
distance criterion is used (that is, when we are not in dungeon mode).
2014-05-04 14:18:15 -07:00
mattsc
ade936e0b0 Fast Micro AI: Add closeness-to-goal to unit order criterion
How fast (in how many turns) the unit can get there remains the main
criterion, but if that is equal for two units, use the closer unit
first.
2014-05-04 14:18:14 -07:00
mattsc
1dd6f7494e Fast Micro AI: add a dungeon mode 2014-05-04 14:18:14 -07:00
mattsc
6cfbe69784 Fast Micro AI: remove debug output 2014-05-04 14:18:14 -07:00
mattsc
48a0920732 Fast Micro AI: exclude guardians from move-to-targets CA 2014-05-03 17:46:37 -07:00
mattsc
d8b5984a19 Fast Micro AI: use wesnoth.require instead of wesnoth.dofile 2014-05-03 17:45:46 -07:00
mattsc
feabdfb4ea New Micro AI: Fast AI
This AI is meant as a fall-back AI for scenarios where there are so
many units that attacks and moves done by the default AI are slow with
long delays before each move. It replaces the default combat and
move-to-targets candidate actions.
See http://wiki.wesnoth.org/Micro_AIs
2014-05-03 16:52:58 -07:00