The Battle for Wesnoth  1.19.5+dev
Public Member Functions | Public Attributes | Private Attributes | Static Private Attributes | List of all members
combatant Struct Reference

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
 
combatantoperator= (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_statsu_
 

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
 

Detailed Description

All combat-related info.

Definition at line 25 of file attack_prediction.hpp.

Constructor & Destructor Documentation

◆ combatant() [1/3]

combatant::combatant ( const battle_context_unit_stats u,
const combatant prev = nullptr 
)

◆ combatant() [2/3]

combatant::combatant ( const combatant that,
const battle_context_unit_stats u 
)

Copy constructor.

Definition at line 1696 of file attack_prediction.cpp.

References summary.

◆ combatant() [3/3]

combatant::combatant ( const combatant that)
delete

Member Function Documentation

◆ average_hp()

double combatant::average_hp ( unsigned int  healing = 0) const

◆ fight()

void combatant::fight ( combatant opponent,
bool  levelup_considered = true 
)

◆ operator=()

combatant& combatant::operator= ( const combatant )
delete

Member Data Documentation

◆ hp_dist

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().

◆ MONTE_CARLO_SIMULATION_THRESHOLD

const unsigned int combatant::MONTE_CARLO_SIMULATION_THRESHOLD = 50000u
staticprivate

Definition at line 63 of file attack_prediction.hpp.

Referenced by fight().

◆ poisoned

double combatant::poisoned

◆ slowed

double combatant::slowed

Resulting chance we are slowed.

Definition at line 49 of file attack_prediction.hpp.

Referenced by combatant(), fight(), and luaW_pushsimdata().

◆ summary

std::array<std::vector<double>, 2> combatant::summary
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().

◆ u_

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().

◆ untouched

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().


The documentation for this struct was generated from the following files: