All combat-related info. More...
#include <attack_prediction.hpp>
Classes | |
struct | combat_slice |
A struct to describe one possible combat scenario. More... | |
Public Member Functions | |
combatant (const battle_context_unit_stats &u, const combatant *prev=nullptr) | |
Construct a combatant. More... | |
combatant (const combatant &that, const battle_context_unit_stats &u) | |
Copy constructor. More... | |
void | fight (combatant &opponent, bool levelup_considered=true) |
Simulate a fight! Can be called multiple times for cumulative calculations. More... | |
double | average_hp (unsigned int healing=0) const |
What's the average hp (weighted average of hp_dist). More... | |
Public Attributes | |
std::vector< double > | hp_dist |
Resulting probability distribution (might be not as large as max_hp) More... | |
double | untouched |
Resulting chance we were not hit by this opponent (important if it poisons) More... | |
double | poisoned |
Resulting chance we are poisoned. More... | |
double | slowed |
Resulting chance we are slowed. More... | |
Private Member Functions | |
combatant (const combatant &that) | |
combatant & | operator= (const combatant &) |
std::vector< combat_slice > | split_summary () const |
Split the combat by number of attacks per combatant (for swarm). More... | |
Private Attributes | |
const battle_context_unit_stats & | u_ |
std::vector< double > | summary [2] |
Summary of matrix used to calculate last battle (unslowed & slowed). More... | |
All combat-related info.
Definition at line 30 of file attack_prediction.hpp.
combatant::combatant | ( | const battle_context_unit_stats & | u, |
const combatant * | prev = nullptr |
||
) |
Construct a combatant.
Definition at line 1054 of file attack_prediction.cpp.
References battle_context_unit_stats::hp, hp_dist, battle_context_unit_stats::is_poisoned, battle_context_unit_stats::is_slowed, battle_context_unit_stats::max_hp, poisoned, slowed, summary, and untouched.
combatant::combatant | ( | const combatant & | that, |
const battle_context_unit_stats & | u | ||
) |
|
private |
double combatant::average_hp | ( | unsigned int | healing = 0 | ) | const |
What's the average hp (weighted average of hp_dist).
Definition at line 1651 of file attack_prediction.cpp.
References i, battle_context_unit_stats::max_hp, and u_.
Referenced by ai::attack_analysis::analyze(), battle_context::better_combat(), ai::attack_result::do_execute(), ai::default_recruitment::attack_simulation::get_avg_hp_of_combatant(), and luaW_pushsimdata().
Simulate a fight! Can be called multiple times for cumulative calculations.
Definition at line 1511 of file attack_prediction.cpp.
References fight(), battle_context_unit_stats::firststrike, hp_dist, i, battle_context_unit_stats::num_blows, prev, utils::split(), split_summary(), summary, and u_.
Referenced by ai::default_recruitment::attack_simulation::attack_simulation(), battle_prediction_pane::battle_prediction_pane(), battle_context::choose_attacker_weapon(), battle_context::choose_defender_weapon(), fight(), battle_context::get_attacker_combatant(), battle_context::get_defender_combatant(), and unit_weapons().
|
private |
Split the combat by number of attacks per combatant (for swarm).
This also clears the current summaries.
Definition at line 1112 of file attack_prediction.cpp.
References battle_context_unit_stats::calc_blows(), debug, battle_context_unit_stats::max_hp, battle_context_unit_stats::num_blows, 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 (might be not as large as max_hp)
Definition at line 42 of file attack_prediction.hpp.
Referenced by ai::attack_analysis::analyze(), battle_context::better_combat(), combatant(), fight(), luaW_pushsimdata(), and unit_weapons().
double combatant::poisoned |
Resulting chance we are poisoned.
Definition at line 48 of file attack_prediction.hpp.
Referenced by ai::attack_analysis::analyze(), battle_context::better_combat(), combatant(), ai::default_recruitment::attack_simulation::get_avg_hp_of_combatant(), and luaW_pushsimdata().
double combatant::slowed |
Resulting chance we are slowed.
Definition at line 51 of file attack_prediction.hpp.
Referenced by combatant(), and luaW_pushsimdata().
|
private |
Summary of matrix used to calculate last battle (unslowed & slowed).
Invariant: summary[1].size() == summary[0].size() or summary[1].empty()
Definition at line 74 of file attack_prediction.hpp.
Referenced by combatant(), fight(), and split_summary().
|
private |
Definition at line 70 of file attack_prediction.hpp.
Referenced by average_hp(), fight(), and split_summary().
double combatant::untouched |
Resulting chance we were not hit by this opponent (important if it poisons)
Definition at line 45 of file attack_prediction.hpp.
Referenced by combatant().