Follow-up Comment #1, patch #1144 (project wesnoth):
When assasin attack a goblin, the game thinks that his melee attack is better
that his ranged.
This happens because of a bug in evaluation code - the presence of poison on
assasin's ranged attacks actually decreases chances to use it.
in GDB, in src/actions.cpp, just before returning from evaluation code which
compares assasin's ranged attack (A) and assasin's melee attack (B)
===
// Does combat A give us a better result than combat B?
bool battle_context::better_combat(const combatant &us_a, const combatant
&them_a,
const combatant &us_b, const combatant &them_b,
double harm_weight)
{
double a, b;
// Compare: P(we kill them) - P(they kill us).
a = them_a.hp_dist[0] - us_a.hp_dist[0] * harm_weight;
b = them_b.hp_dist[0] - us_b.hp_dist[0] * harm_weight;
if (a - b < -0.01)
return false;
if (a - b > 0.01)
return true;
// Add poison to calculations
double poison_a_us = (us_a.poisoned) * game_config::poison_amount;
double poison_a_them = (them_a.poisoned) *
game_config::poison_amount;
double poison_b_us = (us_b.poisoned) * game_config::poison_amount;
double poison_b_them = (them_b.poisoned) *
game_config::poison_amount;
// Compare: damage to them - damage to us (average_hp replaces
-damage)
a = (us_a.average_hp()-poison_a_us)*harm_weight -
(them_a.average_hp()-poison_a_them);
b = (us_b.average_hp()-poison_b_us)*harm_weight -
(them_b.average_hp()-poison_b_them);
if (a - b < -0.01)
return false;
if (a - b > 0.01)
return true;
// All else equal: go for most damage.
return them_a.average_hp() < them_b.average_hp();
}
===
(gdb) print poison_b_them
$17 = 0
(gdb) print poison_a_us
$18 = 0
(gdb) print poison_a_them
$19 = 7.4879999999999995
(gdb) print poison_b_us
$20 = 0
(gdb) print poison_b_them
$21 = 0
(gdb) print a
$22 = -8.6880000000000024
(gdb) print b
$23 = -6.3500000000000014
It is a sign error. That bonus of +7.4 (instead of -7.4 from the poison
turned "a" from a good attack with +13 to a bad attack with
"-8.6880000000000024"
Proposed patch:
==========================================
--- actions.cpp (revision 34146)
+++ actions.cpp (working copy)
-532,8 +532,8 @@
double poison_b_us = (us_b.poisoned) * game_config::poison_amount;
double poison_b_them = (them_b.poisoned) * game_config::poison_amount;
// Compare: damage to them - damage to us (average_hp replaces -damage)
- a = (us_a.average_hp()+poison_a_us)*harm_weight -
(them_a.average_hp()+poison_a_them);
- b = (us_b.average_hp()+poison_b_us)*harm_weight -
(them_b.average_hp()+poison_b_them);
+ a = (us_a.average_hp()-poison_a_us)*harm_weight -
(them_a.average_hp()-poison_a_them);
+ b = (us_b.average_hp()-poison_b_us)*harm_weight -
(them_b.average_hp()-poison_b_them);
if (a - b < -0.01)
return false;
if (a - b > 0.01)
_______________________________________________________
Reply to this item at:
<http://gna.org/patch/?1144>
_______________________________________________
Message sent via/by Gna!
http://gna.org/
_______________________________________________
Wesnoth-bugs mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-bugs