combatant Struct Reference

All combat-related infos. 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)
 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)
 Combat without chance of death, berserk, slow or drain is simple.
void one_strike_fight (combatant &opponent)
 Combat with <= 1 strike each is simple, too.
void complex_fight (combatant &opponent, unsigned int rounds)
 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 infos.

Definition at line 28 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 521 of file attack_prediction.cpp.

References summary.

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


Member Function Documentation

void combatant::fight ( combatant opponent  ) 

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

What's the average hp (weighted average of hp_dist).

Definition at line 826 of file attack_prediction.cpp.

References battle_context::unit_stats::max_hp, and u_.

Referenced by ai::attack_analysis::analyze(), and battle_context::better_combat().

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

unsigned combatant::min_hp (  )  const [private]

Minimum hp we could possibly have.

Definition at line 567 of file attack_prediction.cpp.

References battle_context::unit_stats::hp, summary, and u_.

Referenced by fight().

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 487 of file attack_prediction.cpp.

References battle_context::unit_stats::drains, battle_context::unit_stats::hp, hp_dist, and battle_context::unit_stats::max_hp.

void combatant::no_death_fight ( combatant opponent  )  [private]

Combat without chance of death, berserk, slow or drain is simple.

Definition at line 581 of file attack_prediction.cpp.

References battle_context::unit_stats::damage, hit_chances_, battle_context::unit_stats::hp, summary, and u_.

Referenced by fight().

void combatant::one_strike_fight ( combatant opponent  )  [private]

Combat with <= 1 strike each is simple, too.

Definition at line 629 of file attack_prediction.cpp.

References battle_context::unit_stats::damage, hit_chances_, battle_context::unit_stats::hp, summary, and u_.

Referenced by fight().

void combatant::complex_fight ( combatant opponent,
unsigned int  rounds 
) [private]

void combatant::adjust_hitchance (  )  [private]


Member Data Documentation

std::vector<double> combatant::hp_dist

Resulting probability distribution (may NOT be as large as max_hp).

Definition at line 40 of file attack_prediction.hpp.

Referenced by ai::attack_analysis::analyze(), battle_context::better_combat(), complex_fight(), fight(), and hp_dist_size().

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

Resulting chance we are poisoned.

Definition at line 46 of file attack_prediction.hpp.

Referenced by combatant().

Resulting chance we are slowed.

Definition at line 49 of file attack_prediction.hpp.

Referenced by combatant().

std::vector<double> combatant::hit_chances_ [private]

Usually uniform, but if we have swarm, then can be different.

Definition at line 79 of file attack_prediction.hpp.

Referenced by adjust_hitchance(), complex_fight(), fight(), no_death_fight(), and one_strike_fight().

std::vector<double> combatant::summary[2] [private]

Summary of matrix used to calculate last battle (unslowed & slowed).

Definition at line 82 of file attack_prediction.hpp.

Referenced by adjust_hitchance(), combatant(), complex_fight(), fight(), min_hp(), no_death_fight(), and one_strike_fight().


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

Generated by doxygen 1.5.5 on 23 May 2008 for The Battle for Wesnoth
Gna! | Forum | Wiki | CIA | devdocs