mattsc
bd1b45e814
ai_helper checked actions: move error string into call to error()
...
… rather than making it a separate message.
2016-10-21 17:25:11 -07:00
mattsc
74792845d7
ai_helper.movefull_stopunit: return action result to calling function
2016-10-21 07:26:26 -07:00
mattsc
13d2cdfc29
ai_helper checked actions: return action result to calling function
2016-10-21 07:22:45 -07:00
mattsc
204ccb0584
ai_helper: move checks for incomplete/empty moves to functions
2016-10-21 07:04:02 -07:00
mattsc
022d2cd725
ai_helper checked actions: some modifications to error messages
2016-10-21 06:46:41 -07:00
Gregory A Lundberg
fc6774289e
Upgrade deprecated Lua
...
loadstring was removed, load does the same thing.
atan2 was remvoed, atan works instead
2016-10-17 10:34:43 -05:00
mattsc
5770fa74f0
ai_helper: check variable type when viewing_side is required parameter
...
This is done because the code will not complain but silently produce
non-sensical results if, for example, the filter is passed as the first
argument to get_visible_units().
2016-10-12 07:42:33 -07:00
mattsc
c91a65dde4
ai_helper check unit functions: also check if unit exists
2016-10-10 07:43:38 -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
mattsc
1a5e9051a8
ai_helper: correctly and consistently deal with invisible units
...
Previously, some functions saw invisible units, while others did not.
Moreover, this behavior could be triggered on and off for some
functions, but not for others, and the parameter to do so was not the
same in all cases.
Now, the default setting for all ai_helper functions is to ignore
invisible units and this can be turned on and off with the same
parameter, viewing_side, with the same syntax and meaning as for the
built-in functions wesnoth.find_path() and wesnoth.find_reach(). This
means hat it can be passed directly between those functions and all the
ai_helper functions.
2016-10-09 08:51:13 -07:00
mattsc
8ad055e77f
ai_helper: remove double spaces after punctuation
2016-10-05 19:30:47 -07:00
mattsc
e65a460342
ai_helper: add E_FAILED_TELEPORT to list of non-fatal move errors
2016-10-05 19:28:52 -07:00
mattsc
75817d3ba4
ai_helper: new function robust_move_and_attack()
2016-10-05 19:19:25 -07:00
mattsc
e38dd8ff16
ai_helper: new utility functions to find attackable enemies
...
Attackable enemies are defined as visible (can’t attack it if I can’t
see it) and not petrified.
This is in preparation for making the Micro AIs deal correctly with
hidden and petrified enemies.
2016-10-04 17:17:16 -07:00
mattsc
b00e6d5d96
ai_helper.LS_to_triples: fix function name
...
For consistency with LS_of_triples.
2016-10-04 17:17:16 -07:00
mattsc
371b9b67ec
Lua AI helper functions: remove attacks/moves on failed action
...
If this is not done, there are some rare cases in which a Lua AI might
get caught in an infinite loop by trying the same failed action over
and over again.
2016-10-02 09:13:54 -07:00
mattsc
c03bd5411f
Various Lua AI code: use simpler and faster new syntax
...
No change in behavior.
2016-09-04 18:54:26 -07:00
mattsc
ada80cfd34
Micro AIs: only display on-screen error messages when in debug mode
2014-11-01 07:45:15 -07:00
mattsc
156726a6a4
ai_helper.move_unit_out_of_way: fix direction rating
...
This is supposed to be a minor rating, secondary to the main rating.
2014-06-16 08:08:01 -07:00
mattsc
faeaf5e47c
ai_helper.get_attacks: improve check for units in the way
...
Check whether the unit in the way has an unoccupied hex to move to.
Previously, it was only checked whether its reach was >1, which
sometimes can include only hexes occupied by units on its own side,
making the actual move impossible.
2014-06-15 14:22:18 -07:00
mattsc
03c1b97802
next_hop(): bug fix for ignoring units when ignore_units=true is set
...
A bug in the previous version let to them not being ignored when the
were on the last hex of the next hop.
2014-05-02 19:29:37 -07:00
mattsc
f0c7ddcab1
ai_helper: make AI move error messages more descriptive
2014-04-30 18:59:25 -07:00
mattsc
bbffa5e88a
ai_helper: remove a debug message
...
It’s served its purpose and is not needed any more.
2014-04-26 18:26:45 -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
8e9780d606
ai_helper.get_live_units: don't use filter_wml
...
It’s slow, the new method is between 10 and 20 times faster.
2014-04-26 06:46:32 -07:00
mattsc
9701a724a8
ai_helper.lua: avoid using table.remove
...
It’s slow. The inverse logic using table.insert is much faster,
especially for large tables.
2014-04-17 21:03:38 -07:00
mattsc
19eff08fd7
Fix a typo
2014-04-17 21:03:38 -07:00
mattsc
f6cdd85182
AI helper functions: code cleanup, first pass
...
These function libraries are still work in progress and change
frequently, so the code cleanup is mostly just to make sure the syntax
is consistent with that used in the Micro AIs. Changes or improvements
to the algorithms might be made at a later time.
2014-04-17 21:03:38 -07:00
mattsc
98509aa2bf
Fix a typo
...
I had actually introduced this typo intentionally for testing purposes
and then forgotten to remove it. :-P
2014-04-10 10:39:12 -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
9e6b780306
ai_helper.get_closest_location(): fix bug with tags in SLF
...
The way how the Standard Location Filter was dealt with only worked
with keys, not tags.
2014-03-26 18:03:50 -07:00
mattsc
b7bc394f95
Micro AIs: improve error reporting
...
Use error() instead of wesnoth.message(), as this also produces a stack
traceback.
2014-02-27 17:06:20 -08:00
mattsc
d3e9cb3957
Micro AIs: add check for valid recruiting and error message
...
This now checks whether the recruiting intended to be done with
ai.recruit is possible and displays an error message if it is not.
2014-02-27 17:06:19 -08:00
mattsc
835194eee4
Micro AIs: add check for valid stopunit execution and error message
...
This now checks whether the stopunit execution intended to be done with
ai.stopunit_all, ai.stopunit_attacks or ai.stopunit_moves is possible
and displays an error message if it is not.
2014-02-27 17:06:19 -08:00
mattsc
f0506b2d31
Micro AIs: add check for valid move and error message
...
This now checks whether the move intended to be done with ai.move is
possible and display an error message if it is not.
2014-02-27 17:06:19 -08:00
mattsc
c06529aa18
Micro AIs: add check for valid full move and error message
...
This now checks whether the move intended to be done with ai.move_full
is possible and display an error message if it is not.
2014-02-27 17:06:19 -08:00
mattsc
70e3fc58bd
Micro AIs: add check for valid attacks and error message
...
This will now check whether the attack intended to be done with
ai.attack is possible and display an error message if it is not.
2014-02-27 17:06:18 -08:00
mattsc
e78462c395
Remove function ai_helper.random()
...
This was using the synced RNG which is exactly the wrong thing to do
within the AI evaluation/execution functions.
2014-02-20 11:33:05 -08:00
mattsc
21c8c5c860
ai_helper: add functions to get direction indices and strings
...
These consist of a number of supplementary functions, plus three
function get_cardinal_directions, get_intercardinal_directions and
get_hex_facing which return strings for the directions (in cartesian or
hex coordinates) between two hexes.
2013-12-02 11:01:44 -08:00
mattsc
623036af16
ai_helper.put_labels: display content of strings rather than 'nan'
2013-12-02 10:58:49 -08:00
mattsc
71f92aa05c
ai_helper.get_dst_src(units): minor code simplification
2013-11-14 20:04:53 -08:00
mattsc
5f39a7d2dc
ai_helper.get_enemy_dst_src: add optional parameter 'enemies'
...
If 'enemies' table is given, use it, otherwise use all enemy units.
2013-11-14 20:04:53 -08:00
mattsc
24f10a37ef
ai_helper: improve criterion for impassable terrain
...
Rather than checking whether the movement cost is <99, check whether it
is <= max_moves for the unit.
2013-11-14 20:04:52 -08:00
mattsc
e18378369b
ai_helper: remove unused function ai_helper.got_1_11()
2013-10-30 13:02:09 -07:00
mattsc
659162371b
Internal rewrite of ai_helper.get_attacks()
...
This is much faster than the previous version. No change in
functionality.
2013-09-04 20:20:25 -07:00
mattsc
0891bffafb
ai_helper.put_labels(): add optional keys= parameter
2013-07-16 08:32:45 -07:00
mattsc
e78585586f
ai_helper.put_labels: add show_coords= parameter
2013-07-07 10:50:05 -07:00
mattsc
019b6df9c4
Remove double spaces after periods
...
wmllint complains about this in WML. This is all in Lua code, done for
consistency only.
2013-07-07 10:35:07 -07:00
mattsc
06e896970d
Update ai_helper library
...
New functions print_ts() and print_ts_delta().
Update functions find_best_move() and get_attack_combos().
Use new 1.11.2 syntax and functionality.
2013-05-02 19:57:21 -07:00
Matthias Schoeck
93ba347695
Remove all references to Wesnoth Lua Pack dbms debug function.
...
They were all commented out, but better to remove them altogether.
2012-12-29 20:20:56 +00:00