All combat-related info. More...
#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, bool levelup_considered=true) |
| 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, bool levelup_considered) |
| Combat without chance of death, berserk, slow or drain is simple. | |
| void | one_strike_fight (combatant &opponent, bool levelup_considered) |
| Combat with <= 1 strike each is simple, too. | |
| void | complex_fight (combatant &opponent, unsigned rounds, bool levelup_considered) |
| 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). | |
All combat-related info.
Definition at line 31 of file attack_prediction.hpp.
| combatant::combatant | ( | const battle_context_unit_stats & | u, | |
| const combatant * | prev = NULL | |||
| ) |
Construct a combatant.
Definition at line 622 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::adjust_hitchance | ( | ) | [private] |
We must adjust for swarm after every combat.
Definition at line 657 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, summary, battle_context_unit_stats::swarm_max, battle_context_unit_stats::swarm_min, and u_.
Referenced by fight().

| double combatant::average_hp | ( | unsigned int | healing = 0 |
) | const |
What's the average hp (weighted average of hp_dist).
Definition at line 1015 of file attack_prediction.cpp.
References battle_context_unit_stats::max_hp, and u_.
Referenced by ai::attack_analysis::analyze(), battle_context::better_combat(), and luaW_pushsimdata().

| void combatant::complex_fight | ( | combatant & | opponent, | |
| unsigned | rounds, | |||
| bool | levelup_considered | |||
| ) | [private] |
All other cases.
Definition at line 847 of file attack_prediction.cpp.
References battle_context_unit_stats::damage, debug, battle_context_unit_stats::drain_constant, battle_context_unit_stats::drain_percent, battle_context_unit_stats::experience, hit_chances_, battle_context_unit_stats::hp, hp_dist, battle_context_unit_stats::is_slowed, game_config::kill_xp(), battle_context_unit_stats::level, battle_context_unit_stats::max_experience, battle_context_unit_stats::max_hp, battle_context_unit_stats::petrifies, battle_context_unit_stats::slow_damage, battle_context_unit_stats::slows, summary, and u_.
Referenced by fight().


| void combatant::fight | ( | combatant & | opponent, | |
| bool | levelup_considered = true | |||
| ) |
Simulate a fight! Can be called multiple times for cumulative calculations.
Definition at line 915 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::petrifies, battle_context_unit_stats::rounds, battle_context_unit_stats::slows, 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().


| 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 610 of file attack_prediction.cpp.
References hp_dist, and battle_context_unit_stats::max_hp.
| unsigned combatant::min_hp | ( | ) | const [private] |
Minimum hp we could possibly have.
Definition at line 691 of file attack_prediction.cpp.
References battle_context_unit_stats::hp, summary, and u_.
Referenced by fight().

| void combatant::no_death_fight | ( | combatant & | opponent, | |
| bool | levelup_considered | |||
| ) | [private] |
Combat without chance of death, berserk, slow or drain is simple.
Definition at line 732 of file attack_prediction.cpp.
References battle_context_unit_stats::damage, battle_context_unit_stats::experience, forced_levelup(), hit_chances_, battle_context_unit_stats::hp, battle_context_unit_stats::level, battle_context_unit_stats::max_experience, battle_context_unit_stats::max_hp, summary, and u_.
Referenced by fight().


| void combatant::one_strike_fight | ( | combatant & | opponent, | |
| bool | levelup_considered | |||
| ) | [private] |
Combat with <= 1 strike each is simple, too.
Definition at line 790 of file attack_prediction.cpp.
References conditional_levelup(), battle_context_unit_stats::damage, battle_context_unit_stats::experience, forced_levelup(), hit_chances_, battle_context_unit_stats::hp, game_config::kill_xp(), battle_context_unit_stats::level, battle_context_unit_stats::max_experience, battle_context_unit_stats::max_hp, summary, and u_.
Referenced by fight().


std::vector<double> combatant::hit_chances_ [private] |
Usually uniform, but if we have swarm, then can be different.
Definition at line 82 of file attack_prediction.hpp.
Referenced by adjust_hitchance(), complex_fight(), fight(), no_death_fight(), and one_strike_fight().
| std::vector<double> combatant::hp_dist |
Resulting probability distribution (may NOT be as large as max_hp).
Definition at line 43 of file attack_prediction.hpp.
Referenced by ai::attack_analysis::analyze(), battle_context::better_combat(), complex_fight(), fight(), hp_dist_size(), luaW_pushsimdata(), and unit_weapons().
| double combatant::poisoned |
Resulting chance we are poisoned.
Definition at line 49 of file attack_prediction.hpp.
Referenced by battle_context::better_combat(), combatant(), and luaW_pushsimdata().
| double combatant::slowed |
Resulting chance we are slowed.
Definition at line 52 of file attack_prediction.hpp.
Referenced by combatant(), and luaW_pushsimdata().
std::vector<double> combatant::summary[2] [private] |
Summary of matrix used to calculate last battle (unslowed & slowed).
Definition at line 85 of file attack_prediction.hpp.
Referenced by adjust_hitchance(), combatant(), complex_fight(), fight(), min_hp(), no_death_fight(), and one_strike_fight().
const battle_context_unit_stats& combatant::u_ [private] |
Definition at line 79 of file attack_prediction.hpp.
Referenced by adjust_hitchance(), average_hp(), complex_fight(), fight(), min_hp(), no_death_fight(), and one_strike_fight().
| double combatant::untouched |
Resulting chance we were not hit by this opponent (important if it poisons).
Definition at line 46 of file attack_prediction.hpp.
Referenced by combatant().
| Generated by doxygen 1.7.1 on Fri May 25 2012 01:11:46 for The Battle for Wesnoth | Gna! | Forum | Wiki | CIA | devdocs |