Public Member Functions | Public Attributes | Private Member Functions | Static Private Member Functions | Private Attributes

combatant Struct Reference

All combat-related info. More...

#include <attack_prediction.hpp>

Collaboration diagram for combatant:
Collaboration graph
[legend]

List of all members.

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

Detailed Description

All combat-related info.

Definition at line 31 of file attack_prediction.hpp.


Constructor & Destructor Documentation

combatant::combatant ( const battle_context_unit_stats u,
const combatant prev = NULL 
)
combatant::combatant ( const combatant that,
const battle_context_unit_stats u 
)

Copy constructor.

Definition at line 645 of file attack_prediction.cpp.

References summary.

combatant::combatant ( const combatant that  )  [private]

Member Function Documentation

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

Here is the caller graph for this function:

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

Here is the caller graph for this function:

void combatant::complex_fight ( combatant opponent,
unsigned  rounds,
bool  levelup_considered 
) [private]
void combatant::fight ( combatant opponent,
bool  levelup_considered = true 
)
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().

Here is the caller graph for this function:

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

Here is the call graph for this function:

Here is the caller graph for this function:

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

Here is the call graph for this function:

Here is the caller graph for this function:

combatant& combatant::operator= ( const combatant  )  [private]

Member Data Documentation

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

Resulting chance we are poisoned.

Definition at line 49 of file attack_prediction.hpp.

Referenced by battle_context::better_combat(), combatant(), and luaW_pushsimdata().

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

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


The documentation for this struct was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated by doxygen 1.7.1 on Fri May 25 2012 01:11:46 for The Battle for Wesnoth
Gna! | Forum | Wiki | CIA | devdocs