All combat-related info. More...
#include <attack_prediction.hpp>
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... | |
| combatant (const combatant &that)=delete | |
| combatant & | operator= (const combatant &)=delete |
| 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... | |
| const battle_context_unit_stats & | u_ |
Private Attributes | |
| std::array< std::vector< double >, 2 > | summary |
| Summary of matrix used to calculate last battle (unslowed & slowed). More... | |
Static Private Attributes | |
| static const unsigned int | MONTE_CARLO_SIMULATION_THRESHOLD = 50000u |
All combat-related info.
Definition at line 25 of file attack_prediction.hpp.
| combatant::combatant | ( | const battle_context_unit_stats & | u, |
| const combatant * | prev = nullptr |
||
| ) |
Construct a combatant.
Definition at line 1665 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, prev, slowed, summary, and untouched.
| combatant::combatant | ( | const combatant & | that, |
| const battle_context_unit_stats & | u | ||
| ) |
|
delete |
| double combatant::average_hp | ( | unsigned int | healing = 0 | ) | const |
What's the average hp (weighted average of hp_dist).
Definition at line 2496 of file attack_prediction.cpp.
References hp_dist, 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().
| void combatant::fight | ( | combatant & | opponent, |
| bool | levelup_considered = true |
||
| ) |
Simulate a fight! Can be called multiple times for cumulative calculations.
Definition at line 2330 of file attack_prediction.cpp.
References game_config::combat_xp(), battle_context_unit_stats::experience, fight(), battle_context_unit_stats::firststrike, prefs::get(), hp_dist, i, game_config::kill_xp(), battle_context_unit_stats::level, battle_context_unit_stats::max_experience, MONTE_CARLO_SIMULATION_THRESHOLD, battle_context_unit_stats::num_blows, PLAIN_LOG, poisoned, battle_context_unit_stats::poisons, prev, s, utf8::size(), slowed, utils::split(), summary, t, u_, and untouched.
Referenced by ai::default_recruitment::attack_simulation::attack_simulation(), fight(), gui2::dialogs::tally(), and unit_weapons().
| std::vector<double> combatant::hp_dist |
Resulting probability distribution (might be not as large as max_hp)
Definition at line 40 of file attack_prediction.hpp.
Referenced by ai::attack_analysis::analyze(), average_hp(), battle_context::better_combat(), combatant(), gui2::dialogs::attack_predictions::draw_hp_graph(), fight(), and luaW_pushsimdata().
|
staticprivate |
Definition at line 63 of file attack_prediction.hpp.
Referenced by fight().
| double combatant::poisoned |
Resulting chance we are poisoned.
Definition at line 46 of file attack_prediction.hpp.
Referenced by battle_context::better_combat(), combatant(), fight(), ai::default_recruitment::attack_simulation::get_avg_hp_of_combatant(), and luaW_pushsimdata().
| double combatant::slowed |
Resulting chance we are slowed.
Definition at line 49 of file attack_prediction.hpp.
Referenced by combatant(), fight(), 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 67 of file attack_prediction.hpp.
Referenced by combatant(), and fight().
| const battle_context_unit_stats& combatant::u_ |
Definition at line 60 of file attack_prediction.hpp.
Referenced by average_hp(), battle_context::better_combat(), and fight().
| 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(), fight(), luaW_pushsimdata(), and gui2::dialogs::attack_predictions::set_data().