74 Commits

Author SHA1 Message Date
Rusty Russell
4b4163c8f2 Fix speed on Wesbench_ai:
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.
2006-06-11 10:07:27 +00:00
Rusty Russell
3d280bbc3d Fix OOS bug...
...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.
2006-06-08 07:16:37 +00:00
Gunter Labes
23ca57f01e ran codeclean over all files and set them all to svn:eol-style 'native' 2006-06-05 20:02:25 +00:00
Rusty Russell
bbae6cf1c2 Neatening:
use unit_map everywhere in preparation for making it a real class to
speed up AI
2006-05-28 05:21:57 +00:00
Patrick Parker
cfb19e2583 added slate-border selection style to attack dialog
also, minor warning fix and documentation
2006-05-23 17:39:22 +00:00
Rusty Russell
64b6b55c03 Use simulation to choose weapons, making for a more accurate choice
(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.
2006-05-21 13:03:34 +00:00
Rusty Russell
f22beebe51 Get rid of last user of evaluate_battle_stats: the AI.
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.
2006-05-15 11:48:04 +00:00
Rusty Russell
95727ed284 New function best_attack_weapon:
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.
2006-05-09 12:51:05 +00:00
Jérémy Rosen
fc168242bd make recruit undoable when there is no randomness in recruiting 2006-05-08 06:55:40 +00:00
Rusty Russell
61003c69dd Remove all unused warnings, and remove unused function parameters 2006-05-06 15:21:53 +00:00
Rusty Russell
e3ab954c17 Remove battle_stats entirely from mouse_event.cpp
(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.
2006-04-27 12:32:00 +00:00
Rusty Russell
8c65520a19 Wean actions.cpp and statistics.cpp off battle_stats:
use battle_context instead.  (Another decker2 cleanup: only AI and
mouse_handler still use evaluate_battle_stats now)
2006-04-27 10:53:31 +00:00
Rusty Russell
fa04f01d5e Fix bug where I forgot to change rounds to an unsigned int,
...fixes warning reported by Sapient
2006-04-12 05:14:39 +00:00
Rusty Russell
aa48048b51 Enhance attack_prediction to handle stoning, non-30 berserk, non 1/2 slow.
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.
2006-04-11 10:31:55 +00:00
Rusty Russell
c65d466167 Finally! Merge decker2's hitpoint distribution graph code.
attack_prediction still needs to understand stone.
2006-04-11 04:51:19 +00:00
Rusty Russell
282342687f Implement assignment and copy constructor for battle_context. 2006-04-10 03:28:49 +00:00
Dominic Bolin
415025c2f8 Illumination now lays an overlay on the ToD graphic;
convert some files to unix line endings.
2006-04-09 18:24:14 +00:00
Rusty Russell
3367b8d31b Tie attack_prediction into using battle_context's unit stats,
...so you can use them together.
2006-04-09 01:08:43 +00:00
Rusty Russell
febcbec8a5 Battle context now chooses defensive weapon itself,
...next step is to integrate with attack_prediction.
2006-04-08 23:06:46 +00:00
Rusty Russell
d361f64ed1 Decker2's battle_context (preparing to integrate attack_prediction)
Slight neatening by me.
2006-04-08 10:22:05 +00:00
Jörg Hinrichs
45dd38ff87 merges the gameplay_refactoring branch
please report any problems to me
2006-04-06 21:31:55 +00:00
Jörg Hinrichs
e433a699a6 incorporated trunk changes to playlevel.cpp and playturn.cpp since 2006-03-09T16:32:07Z!jhinrichs
watch out, this does not compile!
2006-04-05 19:55:52 +00:00
Dominic Bolin
8560711a13 Merge with trunk. 2006-03-28 22:57:58 +00:00
Dominic Bolin
807f6f7d75 All modified source code for the rewrite. 2006-03-20 22:37:59 +00:00
Jörg Hinrichs
cb0392a6f3 implements feature to skip mp replays for observer
(actually they are not really skipped but accelerated quite a lot)
2006-03-04 20:56:24 +00:00
Benoît Timbert
fe5979e1eb [[WML enhancements]]
- 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
2006-01-15 12:00:53 +00:00
Benoît Timbert
7401d9b1a3 Improved default weapon selection on player attack
(patch #500, by John Smith <decker> )
2006-01-06 23:26:17 +00:00
Jörg Hinrichs
8674b86082 [[vc++ and inclusion handling fixes]]
- 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
2006-01-03 20:04:50 +00:00
Bruno Wolff III
1f0096172d Change to backstab...
...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.
2005-11-06 02:55:53 +00:00
Dave White
8f4d5a8031 fix to make capture events mutating like other events 2005-09-18 23:32:23 +00:00
Philippe Plantier
5f2f3e9c88 Using const_cast to modify a const variable is just wrong,
...even if the modification is temporary. Removing the const casts.
2005-09-12 21:36:04 +00:00
Philippe Plantier
ff0a20ccc1 Applying a refactored version of patch #4267 (thanks Ihsan) to fix #13638. 2005-08-27 22:24:10 +00:00
András Salamon
8d25fb99a6 codeclean in src, mostly Dave's new email address (checked with cvs diff -b)
BY THE WAY, many of the source files have no copyright headers!
2005-07-02 21:37:20 +00:00
András Salamon
8bd9bc98a5 ran codeclean against files 2005-06-04 19:16:06 +00:00
John W. C. McNabb
4775cb3bbc changelog 2005-03-29 17:41:09 +00:00
Yann Dirson
6ec8596b61 include cleanup: about, actions, cavegen, mapgen 2005-03-09 20:48:42 +00:00
Guillaume Melquiond
5f2d71b016 At first it was supposed to be a small patch...
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.
2004-12-05 18:37:36 +00:00
Dave White
28b93b239a CHANGELOG: added feature to move and attack a unit in one go...
...by clicking on an enemy that can be reached this turn.
2004-12-03 01:19:29 +00:00
Guillaume Melquiond
d0293b6c85 Remove two unused parameters from actions.cpp. 2004-11-27 08:41:49 +00:00
Dave White
0172e51f45 removed some unnecessary diagnostics (CVS internal) 2004-08-25 02:59:51 +00:00
Dave White
8997cfc402 rebalanced various scenarios; fixed bug with roles not working properly 2004-06-26 20:57:49 +00:00
Dave White
c34a31cfa4 rebalanced 'Valley of Death' and 'Ford of Abez'. Made 'Skip AI Moves' option 2004-06-07 20:19:27 +00:00
Dave White
ff620f6ca4 tweaked 'Crossroads' scenario 2004-06-04 20:20:41 +00:00
Dave White
768d90e9db added 'first strike' ability...
...and assigned it to Spearman, Halbardier, and Pikeman
2004-05-31 00:14:52 +00:00
Dave White
a74e99cf69 fixed bug where pressing 'n' while a unit is attacking ...
...would transfer damage to another unit
2004-05-27 19:45:22 +00:00
Dave White
05ce6863a1 some changes to scenarios and AI in Heir to the Throne 2004-05-13 21:52:18 +00:00
Dave White
0f2691d478 attempt to fix assertion failure in move_unit() 2004-05-06 20:07:41 +00:00
John B. Messerly
08e46b18d9 Added a "continue move" action.
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.
2004-05-04 01:50:19 +00:00
Dave White
0310f739d6 added in patch to allow 'image_healing' and 'image_leading' animations...
...for units performing those actions
2004-04-30 20:01:51 +00:00
John B. Messerly
d06c918024 Fixed an assertion failure in delayed fog-of-war update code
(apply_shroud_changes(...)). Specifically, the code had an implicit
dependency on a unit only being moved once per turn. This has been
fixed.
2004-04-26 05:13:40 +00:00