mattsc
25e10121f5
Lua AIs: fix bug occurring when number= in an attack is set to zero
...
Apparently, when this is the case, the number key is not included at
all, rather than set to zero, when the Lua table containing the attack
information is retrieved.
2015-05-19 19:54:41 -07:00
aquileia
504fd44747
Fixup and expand cc8ec3a934bd
...
[skip ci]
2015-01-29 01:36:34 +01: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
9e8ee00ad0
battle_calcs: provide default value for resistance modifiers
...
This is done for cases when the value cannot be read from the unit_info
table, which might happen in some UMC. This fixes a rare bug affecting
the Fast Micro AI attack evaluation
2014-06-15 19:34:25 -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
82e4ccad4d
battle_calcs.attack_rating(): overhaul attack rating system
...
This was long overdue. The return value is now much closer to
something describing the actual gain/loss (roughly) in units of gold.
2014-04-30 19:09:28 -07:00
mattsc
7623c5513a
battle_calcs: do not use variance of attack in attack rating
...
This was an idea we tried so that we’d start with the most uncertain
attack first, but it did not work very well.
Keep the code for now, just comment it out.
2014-04-30 19:06:57 -07:00
mattsc
0218b88180
attack_combo_stats(): also cache intermediate battle outcomes
...
Speeds up some calculations significantly.
2014-04-30 19:05:08 -07:00
mattsc
2336921a81
simulate_combat_fake(): don't fill empty HP chances with zeros
...
That’s what wesnoth.simulate_combat() does, but is different from the
other functions in battle_calcs. Only hp_chance[0] needs to be set,
even if it is zero.
2014-04-30 19:02:08 -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
664eeae888
battle_calcs.lua: fix bug in get_attack_map_unit() for enemy units
...
Own units with MP left need to be taken off the map before enemy path
finding, not just added to the table.
2014-04-23 18:48:46 -07:00
mattsc
ddfdae5e52
battle_calcs.lua: fix a variable name
2014-04-22 16:46:49 -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
e87240c67f
battle_calcs.lua: 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-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
f1faf1d6e3
Experimental AI: fix a parameter in call to healer support AI
...
This was an oversight from a change made in d4917d534e just two days
ago, so it was not in any released version.
2014-04-17 07:11:42 -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
496a58d343
Experimental AI: use checked versions of the AI actions
...
So that only valid actions are executed and useful error messages are
produced if something goes wrong.
2014-02-28 07:04:54 -08:00
mattsc
0b6fa7ed19
Experimental AI: remove potential of causing errors through WML events
...
Events taking units off the map after the move could previously have
caused errors, and thus disabled the AI for the rest of the turn.
2014-02-28 07:03:02 -08: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
ea915d36c2
battle_calcs.attack_rating: bug fix for when AI side has no leader
...
Check for AI side's leader's existence before trying to calculate
distance from leader.
2013-11-25 19:37:20 -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
c46d8459d6
Retreat AI eval: poisoned units do not get resting healing bonus
...
... in evaluation of best retreat positions.
2013-11-14 20:04:52 -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
c6db6cd8d5
Lua AIs: Remove unnecessary arguments in call to wesnoth.put_unit()
2013-11-14 20:04:52 -08:00
mattsc
9976eac873
Micro AI CA files: replace tabs by spaces
...
I had not realized that TextWrangler changes spaces to tabs when
shifting blocks of text to the left, which had been done for all CA
files when converting the engine files.
2013-11-14 10:54:14 -08:00
mattsc
cb2a22acd4
ExpAI move_to_enemy CA: fix file path
...
Had accidentally copied over the AI-demos path.
2013-11-01 09:44:45 -07:00
mattsc
a45cf2ac58
ExpAI: capture more villages if we can't recruit any more this turn
2013-11-01 09:27:38 -07:00
mattsc
241fd529e0
ExpAI: ignore unreachable enemy leaders when selecting keep
2013-11-01 09:24:05 -07:00
mattsc
d8c35a75c8
ExpAI: capture villages with injured units if no enemy can reach
2013-11-01 09:19:54 -07:00
mattsc
948147550a
ExpAI: Encourage forward advancement when capturing villages
2013-11-01 09:14:55 -07:00
mattsc
9c86a71ef7
ExpAI retreat code: also return enemy attack map
2013-11-01 08:51:21 -07:00
mattsc
1fa06a6811
Exp AI retreat code: make function min_hp() externally accessible
2013-11-01 08:51:21 -07:00