#include <attack_prediction.hpp>
Public Member Functions | |
combatant (const battle_context::unit_stats &u, const combatant *prev=NULL) | |
Construct a combatant. | |
combatant (const combatant &that, const battle_context::unit_stats &u) | |
Copy constructor. | |
void | fight (combatant &opponent) |
Simulate a fight! Can be called multiple times for cumulative calculations. | |
double | average_hp (unsigned int healing=0) const |
What's the average hp (weighted average of hp_dist). | |
Public Attributes | |
std::vector< double > | hp_dist |
Resulting probability distribution (may NOT be as large as max_hp). | |
double | untouched |
Resulting chance we were not hit by this opponent (important if it poisons). | |
double | poisoned |
Resulting chance we are poisoned. | |
double | slowed |
Resulting chance we are slowed. | |
Private Member Functions | |
combatant (const combatant &that) | |
combatant & | operator= (const combatant &) |
unsigned | min_hp () const |
Minimum hp we could possibly have. | |
void | no_death_fight (combatant &opponent) |
Combat without chance of death, berserk, slow or drain is simple. | |
void | one_strike_fight (combatant &opponent) |
Combat with <= 1 strike each is simple, too. | |
void | complex_fight (combatant &opponent, unsigned int rounds) |
All other cases. | |
void | adjust_hitchance () |
We must adjust for swarm after every combat. | |
Static Private Member Functions | |
static unsigned | hp_dist_size (const battle_context::unit_stats &u, const combatant *prev) |
HP distribution we could end up with. | |
Private Attributes | |
const battle_context::unit_stats & | u_ |
std::vector< double > | hit_chances_ |
Usually uniform, but if we have swarm, then can be different. | |
std::vector< double > | summary [2] |
Summary of matrix used to calculate last battle (unslowed & slowed). |
Definition at line 28 of file attack_prediction.hpp.
combatant::combatant | ( | const battle_context::unit_stats & | u, | |
const combatant * | prev = NULL | |||
) |
Construct a combatant.
Definition at line 501 of file attack_prediction.cpp.
References battle_context::unit_stats::is_poisoned, battle_context::unit_stats::is_slowed, poisoned, slowed, summary, and untouched.
combatant::combatant | ( | const combatant & | that, | |
const battle_context::unit_stats & | u | |||
) |
combatant::combatant | ( | const combatant & | that | ) | [private] |
void combatant::fight | ( | combatant & | opponent | ) |
Simulate a fight! Can be called multiple times for cumulative calculations.
Definition at line 726 of file attack_prediction.cpp.
References adjust_hitchance(), complex_fight(), battle_context::unit_stats::damage, battle_context::unit_stats::drains, battle_context::unit_stats::dump(), fight(), battle_context::unit_stats::firststrike, hit_chances_, hp_dist, min_hp(), no_death_fight(), one_strike_fight(), battle_context::unit_stats::rounds, size, battle_context::unit_stats::slows, battle_context::unit_stats::stones, summary, and u_.
Referenced by battle_context::choose_attacker_weapon(), battle_context::choose_defender_weapon(), fight(), battle_context::get_attacker_combatant(), and battle_context::get_defender_combatant().
double combatant::average_hp | ( | unsigned int | healing = 0 |
) | const |
What's the average hp (weighted average of hp_dist).
Definition at line 826 of file attack_prediction.cpp.
References battle_context::unit_stats::max_hp, and u_.
Referenced by ai::attack_analysis::analyze(), and battle_context::better_combat().
unsigned combatant::min_hp | ( | ) | const [private] |
Minimum hp we could possibly have.
Definition at line 567 of file attack_prediction.cpp.
References battle_context::unit_stats::hp, summary, and u_.
Referenced by fight().
unsigned combatant::hp_dist_size | ( | const battle_context::unit_stats & | u, | |
const combatant * | prev | |||
) | [static, private] |
HP distribution we could end up with.
Definition at line 487 of file attack_prediction.cpp.
References battle_context::unit_stats::drains, battle_context::unit_stats::hp, hp_dist, and battle_context::unit_stats::max_hp.
void combatant::no_death_fight | ( | combatant & | opponent | ) | [private] |
Combat without chance of death, berserk, slow or drain is simple.
Definition at line 581 of file attack_prediction.cpp.
References battle_context::unit_stats::damage, hit_chances_, battle_context::unit_stats::hp, summary, and u_.
Referenced by fight().
void combatant::one_strike_fight | ( | combatant & | opponent | ) | [private] |
Combat with <= 1 strike each is simple, too.
Definition at line 629 of file attack_prediction.cpp.
References battle_context::unit_stats::damage, hit_chances_, battle_context::unit_stats::hp, summary, and u_.
Referenced by fight().
void combatant::complex_fight | ( | combatant & | opponent, | |
unsigned int | rounds | |||
) | [private] |
All other cases.
Definition at line 672 of file attack_prediction.cpp.
References battle_context::unit_stats::damage, debug, battle_context::unit_stats::drains, hit_chances_, battle_context::unit_stats::hp, hp_dist, battle_context::unit_stats::is_slowed, battle_context::unit_stats::max_hp, maximum(), battle_context::unit_stats::slow_damage, battle_context::unit_stats::slows, battle_context::unit_stats::stones, summary, and u_.
Referenced by fight().
void combatant::adjust_hitchance | ( | ) | [private] |
We must adjust for swarm after every combat.
Definition at line 533 of file attack_prediction.cpp.
References battle_context::unit_stats::chance_to_hit, debug, hit_chances_, battle_context::unit_stats::hp, battle_context::unit_stats::max_hp, size, summary, battle_context::unit_stats::swarm_max, battle_context::unit_stats::swarm_min, and u_.
Referenced by fight().
std::vector<double> combatant::hp_dist |
Resulting probability distribution (may NOT be as large as max_hp).
Definition at line 40 of file attack_prediction.hpp.
Referenced by ai::attack_analysis::analyze(), battle_context::better_combat(), complex_fight(), fight(), and hp_dist_size().
double combatant::untouched |
Resulting chance we were not hit by this opponent (important if it poisons).
Definition at line 43 of file attack_prediction.hpp.
Referenced by combatant().
double combatant::poisoned |
Resulting chance we are poisoned.
Definition at line 46 of file attack_prediction.hpp.
Referenced by combatant().
double combatant::slowed |
Resulting chance we are slowed.
Definition at line 49 of file attack_prediction.hpp.
Referenced by combatant().
const battle_context::unit_stats& combatant::u_ [private] |
Definition at line 76 of file attack_prediction.hpp.
Referenced by adjust_hitchance(), average_hp(), complex_fight(), fight(), min_hp(), no_death_fight(), and one_strike_fight().
std::vector<double> combatant::hit_chances_ [private] |
Usually uniform, but if we have swarm, then can be different.
Definition at line 79 of file attack_prediction.hpp.
Referenced by adjust_hitchance(), complex_fight(), fight(), no_death_fight(), and one_strike_fight().
std::vector<double> combatant::summary[2] [private] |
Summary of matrix used to calculate last battle (unslowed & slowed).
Definition at line 82 of file attack_prediction.hpp.
Referenced by adjust_hitchance(), combatant(), complex_fight(), fight(), min_hp(), no_death_fight(), and one_strike_fight().
Generated by doxygen 1.5.5 on 23 May 2008 for The Battle for Wesnoth | Gna! | Forum | Wiki | CIA | devdocs |