Commit graph

390 commits

Author SHA1 Message Date
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
mattsc
6f84e14b89 Hang Out MAI: bug fix in best move selection
In rare cases (when the unit has no hexes to move to, not even the one
it is on because it is in a zone to be avoided), this would cause an
error and crash the AI.
2014-04-30 18:52:02 -07:00
mattsc
e99423bad9 Lua AIs: do not use empty tables as filters
It’s faster not to provide any argument to wesnoth.get_units() if all
units are to be found.
2014-04-26 07:18:23 -07:00
mattsc
8599266769 Micro AIs other engines: code cleanup 2014-04-20 14:30:02 -07:00
mattsc
7578eb592a [micro_ai] tag setup: minor code cleanup 2014-04-20 14:30:02 -07:00
mattsc
7e8964c48d Goto Micro AI: prevent potential conflict between Goto MAIs
If several Goto MAIs are used on the same side and both have
unique_goals=yes set, they previously might have interfered with each
other, one preventing the other from working correctly. Now the “goal
taken” information is saved such that it only applies to the CA by
which it was set.
2014-04-20 14:30:02 -07:00
mattsc
e4ea795c96 Messenger MAI: fix typo
Sigh.  Intentional typo for testing, forgotten to revert it.
2014-04-19 16:25:46 -07:00
mattsc
d3ce1051ff Messenger Escort Micro AI: code cleanup 2014-04-19 16:23:26 -07:00
mattsc
83d23fac52 Bottleneck Defense Micro AI: code cleanup 2014-04-19 13:09:43 -07:00
Elvish_Hunter
b22ceefa0d Changed all mainline occurrences of {FLAG_VARIANT ragged} to {FLAG_VARIANT6 ragged} 2014-04-19 10:57:48 +02:00
mattsc
5fc48b3e88 Micro AIs: don't check for specific value of move rating
Don’t check whether rating equals (or doesn’t equal) -9e99 or the like,
verify that a valid move was found instead.  Also, avoid setting
variables to empty tables if not needed.
2014-04-18 07:54:56 -07:00
mattsc
9d440fac8e Protect Unit MAI test scenario: use fight_on_without_leader=yes
So that the scenario continues even if the side 2 leader is killed.
2014-04-17 21:03:39 -07:00
mattsc
4a7292e993 Goto Micro AI: code cleanup 2014-04-16 09:47:10 -07:00
mattsc
f6830897aa Protect Unit Micro AI: code cleanup 2014-04-16 09:47:10 -07:00
mattsc
8fa3a60e56 Protect Unit Micro AI: fix bug in goal selection
There was a typo in the goal table indexing.  It worked for the
multi-unit test scenario (the Elves Besieged) because the goal x
coordinates for both units were the same.
2014-04-16 09:47:10 -07:00
mattsc
d4917d534e Healer Support Micro AI: code cleanup 2014-04-16 09:47:09 -07:00
mattsc
a4ca7c164f Micro AIs: prevent potential conflicts of stored data
It’s theoretically possible that different Micro AIs’ evaluation
functions store information in the same variable within self.data.
This would only happen if the CAs have the same score and while this
should generally be avoided when setting up a scenario, it is better to
ensure that it cannot cause conflicts (not in the stored data at least,
the MAIs might still interfere with each other in other respects).
2014-04-15 08:15:37 -07:00
mattsc
51251d48e1 Hunter Micro AI: code cleanup 2014-04-15 08:15:37 -07:00
mattsc
85b36fd32f Random Recruiting Micro AI: code cleanup 2014-04-15 08:15:37 -07:00
mattsc
6532fdbb4b Hang-out Micro AI: code cleanup 2014-04-15 08:15:37 -07:00
mattsc
3a85688c60 Multi-pack Wolves MAI: code cleanup 2014-04-15 08:15:36 -07:00
mattsc
326d998728 Animals Micro AIs: code cleanup 2014-04-14 12:45:20 -07:00
mattsc
e13f60e86e Big Animals MAI: check that attack target is enemy of AI side
… not only that it is on a different side.
2014-04-14 12:45:20 -07:00
mattsc
62e9eab4fa Micro AIs: make loop variables more descriptive 2014-04-14 12:45:19 -07:00
mattsc
074df432d7 Herding Micro AI: code cleanup 2014-04-14 12:45:19 -07:00
mattsc
54babada05 Recruit Rushers Micro AI: remove unused library 2014-04-14 12:45:19 -07:00
mattsc
6140b52234 Wolves Micro AI: code cleanup 2014-04-14 12:45:19 -07:00
mattsc
41687b5569 Guardian Micro AIs: code cleanup 2014-04-12 21:57:16 -07:00
mattsc
20eb5b27dc Patrol Micro AI: code cleanup 2014-04-12 21:57:16 -07:00
mattsc
65bc85d030 Lurkers Micro AI: code cleanup 2014-04-12 21:57:15 -07:00
mattsc
8902e649d4 Swarm Micro AI: code cleanup 2014-04-12 21:57:15 -07:00
mattsc
ec9017584b Simple Attack Micro AI: code cleanup 2014-04-12 21:57:15 -07:00
mattsc
bb8c08a314 Micro AIs: standardize eval/exec function table setup 2014-04-11 17:21:58 -07:00
mattsc
c4cb6168e4 Micro AIs: avoid using formula= in SUFs
It’s slow for finding units with moves or attacks left.  The
alternative method of getting all units and then looping over the table
with a condition is much faster.
2014-04-10 10:06:25 -07:00
mattsc
161470c149 Micro AIs: avoid using table.remove
It’s slow.  The inverse logic using table.insert is much faster,
especially for large tables.  Only kept table.remove in a couple places
where it doesn’t matter.
2014-04-10 07:36:45 -07:00
mattsc
a131572e09 Messenger Micro AI: minor code simplification 2014-04-10 07:36:44 -07:00
mattsc
7fc8e9797b Micro AIs: avoid code duplication between eval and exec functions 2014-04-09 18:23:46 -07:00
mattsc
6f40ed8046 Micro AIs: use new fight_on_without_leader= key as needed
So that the scenarios with leaderless AI sides work.
2014-04-09 18:21:52 -07:00
mattsc
f260dd3be5 Micro AIs: one more wesnoth.dofile -> wesnoth.require 2014-04-07 14:36:36 -07:00
mattsc
bb5ed2e5a2 Micro AIs: clean up loading of Lua files
Consistently use wesnoth.require, avoid wesnoth.dofile. Move commands
as close to beginning of file as possible in order to facilitate custom
modifications of MAIs.
2014-04-07 14:23:42 -07:00
mattsc
1dfd79c3a5 Micro AIs: use the new functions for storing information in self.data
… so that it is done in a consistent way and conflicts can be avoided
when setting up a subsequent MAI.
2014-03-31 20:04:18 -07:00
mattsc
73a11634f7 Micro AIs: check for existence of [micro_ai] tags in self.data when...
… setting up an MAI. Ideally, we would delete such previous occurrences
of [micro_ai] tags in the AI's self.data variable. However, the MAI can
be changed while it is not the AI's turn, when this is not possible. So
instead, we check for the existence of such tags and make sure we are
using a different ai_id.
2014-03-31 20:02:16 -07:00
mattsc
6cfe5fa351 MAIs: add utility functions for storing information in AI's self.data
These provide a simple and consistent method of storing variables
inside [micro_ai] tags in the AI's persistent self.data variable. This
is needed for fixing a bug with variables stored there from a previous
MAI causing problems with a subsequent MAI
2014-03-31 19:58:58 -07:00
mattsc
6bd3bae330 Fix typos in comments 2014-03-31 19:55:24 -07:00
mattsc
d69d4e9858 Goto MAI: store whether unit is released in the unit, not self.data
This is unit specific information, and therefore should go into the
unit.  By contrast, information whether all units of the side have been
released needs to remain in self.data.
2014-03-31 18:18:51 -07:00
mattsc
c24ddb71b2 Micro AIs bug fix: remove MAI unit variables on MAI removal
Previously this information remained in units and could alter the
behavior of subsequent MAIs, or even entirely disable them.
2014-03-31 08:21:50 -07:00
mattsc
49cc3bc7f9 Micro AIs: use the new functions for storing information in units
… such that it is done in a consistent way and this information can be
removed on MAI deletion.
2014-03-31 08:19:31 -07:00
mattsc
a4ee966d06 Fix comments 2014-03-31 08:16:14 -07:00
mattsc
bfb3315153 Micro AIs: another bug fix for required keys for MAI removal
The random recruiters MAI also required unnecessary keys to be provided
for MAI removal.
2014-03-31 08:15:12 -07:00