introduce an AI cache which stores previous calculations on what
weapon to use against an opponent.
This operates on the assumption that similar types will usually use
the same weapon, and is about 99% accurate. Worst case, AI
underestimates the damage it could do.
Profiling shows that (after the next checking which fastpaths simple
attack_prediction) we were spending ~30% of time figuring out what the
effects of weapons should be, including 10% of time in timeofday_at.
This could be significantly cut if we eliminate unused generality in
all these calculations.
Time for wesbench before (-O3 -march=pentium-m): ~14 seconds. Time
after: 2.3 seconds.
...where one player (or observer) chooses a different defensive
weapon, as seen by Soliton (IIRC)
Xan pointed out this was a possibility: we calculate defense weapon
now based on attack_prediction code, but this uses floating point
calculations, which means that in the case where results are close,
rounding differences can mean that both ends choose different weapons.
The answer is to store the defense weapon as well as the attack
weapon, and pass it to all the relevent routines.
(it takes into account the exact circumstances of the battle).
This roughly doubles the calls to attack_prediction's fight() routine
during heavy AI load, but optimization yet to come.
battle_context/combatant could now use some cleanup.
May effect performance. ai::choose_weapon now simply uses
best_attack_weapon, which is a little smarter about poison and slow.
Some code movement because best_attack_weapon needs unit map to
indicate reality (for filters it needs exact location of units in
combat).
AI now uses attack_prediction code, not 50 iterations, to predict
results. This will handle specials better, but there may be
incidental changes to AI's decision-making.
uses (slightly modified) heuristic to figure out what the best weapon
to use is. Make mouse_events use it to choose default attack to
highlight.
Plan is for ai to use this as well.
(finish its conversion to battle_context)
The calculation of "best" attack weapon is now based on a rating from
battle_conext: even if it has changed under some circumstances, it's
only used to choose which weapon to highlight by default anyway.
For stoning we set damage to maximum (ie. kill) then revert after simulation.
For berserk we actually record how many rounds are set, not assume 30.
For slow we actually use the given "slowed" damage rather than assume
it's 1/2 normal.
Also remove debugging prints when configured with --enable-debug.
- Added time of day & terrain filter to abilities :
- implemented filter for every ability
- made [hides], [illuminates] and [steadfast] use their filter
todo : make the other abilities use their filter
- We now support multiple abilities of the same class.
if they use additional parameters, we will only use the maximum value
- [ambush] & [nightstalk] are now replaced by [hides]
- updated the abilities macros so ambush & nightstalk will still work
- updated changelog
- changed include paths to be relative to source root
- removed some unnecessary includes
- added some includes of global.hpp to editor files to prevent useless vc++ compiler warnings
- Extended vc++ project files
- fixed the bug of having to press escape two times in a continuous replay to get back to the titlescreen
...to work when the unit opposite the attacker is an enemy of the
defender and is not incapacitated. (Note someone familiar with the
code style might want to review this to see if I broke any style
guidelines. The main issue would probably be how I got access to
teams_ and units_.)
Updated the builtin help to describe backstab consistant with the above and
mentioned the 30 round limit in the beserk description.
Renamed "Across The River" as "Across the River" as articles don't seem
to be capitalized in most maps.
Renamed the config file containing "Across the River" to be consistant with
other maps, so it appears in a more normal order in the displayed list.
Changed "Load Game ..." to be the first multiplayer game option to make this
option easier to notice.
to fix weapons not being translated in the attack box. But now it also
handles the way the battle statistics are stored in memory: the
optional part is now strictly user-oriented, and hence can be fully
translated. As a consequence, the common part is much smaller, almost
a POD; it should speed up the AI since both the memory footprint and
the _struction time are notably reduced. To avoid changing too much
code, there are still two strings in the common structure in order to
handle attack specials; they could be replaced later on by an integer
bitset to further speed up the game.
There are four parts to this patch:
1) add the action to the usual places 2) add a gamemap::location to class unit,
which stores the location we were trying to move to, 3) clear this
location on end-of-turn, or if the unit moves again this turn, and 4)
if a move is interrupted, reslect the unit's hex.
The new hotkey is 't'. To use this feature, select a unit that had its
move interrupted by seeing allies/enemies, and right click >> "Continue
Move", or press the 't' key.