warning round two, unused parameters in AI

This commit is contained in:
Jérémy Rosen 2006-01-12 09:23:21 +00:00
parent db3b24ace9
commit 244d6962c5
8 changed files with 85 additions and 88 deletions

View file

@ -822,7 +822,7 @@ void ai::do_move()
}
}
move_leader_to_goals(enemy_srcdst,enemy_dstsrc);
move_leader_to_goals(enemy_dstsrc);
LOG_AI << "get villages phase\n";
@ -836,7 +836,7 @@ void ai::do_move()
LOG_AI << "healing phase\n";
LOG_AI << "healing...\n";
const bool healed_unit = get_healing(possible_moves,srcdst,dstsrc,enemy_srcdst,enemy_dstsrc);
const bool healed_unit = get_healing(possible_moves,srcdst,enemy_dstsrc);
if(healed_unit) {
do_move();
return;
@ -845,7 +845,7 @@ void ai::do_move()
LOG_AI << "retreat phase\n";
LOG_AI << "retreating...\n";
const bool retreated_unit = retreat_units(possible_moves,srcdst,dstsrc,enemy_srcdst,enemy_dstsrc,leader);
const bool retreated_unit = retreat_units(possible_moves,srcdst,dstsrc,enemy_dstsrc,leader);
if(retreated_unit) {
do_move();
return;
@ -859,7 +859,7 @@ void ai::do_move()
LOG_AI << "move/targetting phase\n";
const bool met_invisible_unit = move_to_targets(possible_moves,srcdst,dstsrc,enemy_srcdst,enemy_dstsrc,leader);
const bool met_invisible_unit = move_to_targets(possible_moves,srcdst,dstsrc,enemy_dstsrc,leader);
if(met_invisible_unit) {
LOG_AI << "met_invisible_unit\n";
do_move();
@ -1090,7 +1090,7 @@ bool ai::get_villages(std::map<gamemap::location,paths>& possible_moves, const m
if(vuln != vulnerability.end()) {
threat = vuln->second;
} else {
threat = power_projection(j->first,enemy_srcdst,enemy_dstsrc);
threat = power_projection(j->first,enemy_dstsrc);
vulnerability.insert(std::pair<location,double>(j->first,threat));
}
@ -1134,7 +1134,7 @@ bool ai::get_villages(std::map<gamemap::location,paths>& possible_moves, const m
const unit_map::const_iterator new_unit = units_.find(loc);
if(new_unit != units_.end() && power_projection(i->first,enemy_srcdst,enemy_dstsrc) >= new_unit->second.hitpoints()/4) {
if(new_unit != units_.end() && power_projection(i->first,enemy_dstsrc) >= new_unit->second.hitpoints()/4) {
add_target(target(new_unit->first,1.0,target::SUPPORT));
}
}
@ -1151,7 +1151,7 @@ bool ai::get_villages(std::map<gamemap::location,paths>& possible_moves, const m
return moves_made > 0 && village_moves.size() == max_village_moves;
}
bool ai::get_healing(std::map<gamemap::location,paths>& possible_moves, const move_map& srcdst, const move_map& dstsrc, const move_map& enemy_srcdst, const move_map& enemy_dstsrc)
bool ai::get_healing(std::map<gamemap::location,paths>& possible_moves, const move_map& srcdst, const move_map& enemy_dstsrc)
{
//find units in need of healing
unit_map::iterator u_it = units_.begin();
@ -1173,8 +1173,7 @@ bool ai::get_healing(std::map<gamemap::location,paths>& possible_moves, const mo
while(it.first != it.second) {
const location& dst = it.first->second;
if(map_.gives_healing(dst) && (units_.find(dst) == units_.end() || dst == u_it->first)) {
const double vuln = power_projection(it.first->first,
enemy_srcdst,enemy_dstsrc);
const double vuln = power_projection(it.first->first, enemy_dstsrc);
LOG_AI << "found village with vulnerability: " << vuln << "\n";
if(vuln < best_vulnerability || best_loc == it.second) {
best_vulnerability = vuln;
@ -1202,25 +1201,25 @@ bool ai::get_healing(std::map<gamemap::location,paths>& possible_moves, const mo
return false;
}
bool ai::should_retreat(const gamemap::location& loc, const unit_map::const_iterator un, const move_map& srcdst, const move_map& dstsrc, const move_map& enemy_srcdst, const move_map& enemy_dstsrc) const
bool ai::should_retreat(const gamemap::location& loc, const unit_map::const_iterator un, const move_map& srcdst, const move_map& dstsrc, const move_map& enemy_dstsrc) const
{
const double caution = current_team().caution();
if(caution <= 0.0) {
return false;
}
const double optimal_terrain = best_defensive_position(un->first,dstsrc,srcdst,enemy_dstsrc,enemy_srcdst).chance_to_hit/100.0;
const double optimal_terrain = best_defensive_position(un->first,dstsrc,srcdst,enemy_dstsrc).chance_to_hit/100.0;
const double proposed_terrain = un->second.defense_modifier(map_,map_.get_terrain(loc))/100.0;
//the 'exposure' is the additional % chance to hit this unit receives from being on a sub-optimal defensive terrain
const double exposure = proposed_terrain - optimal_terrain;
const double our_power = power_projection(loc,srcdst,dstsrc);
const double their_power = power_projection(loc,enemy_srcdst,enemy_dstsrc);
const double our_power = power_projection(loc,dstsrc);
const double their_power = power_projection(loc,enemy_dstsrc);
return caution*their_power*(1.0+exposure) > our_power;
}
bool ai::retreat_units(std::map<gamemap::location,paths>& possible_moves, const move_map& srcdst, const move_map& dstsrc, const move_map& enemy_srcdst, const move_map& enemy_dstsrc, unit_map::const_iterator leader)
bool ai::retreat_units(std::map<gamemap::location,paths>& possible_moves, const move_map& srcdst, const move_map& dstsrc, const move_map& enemy_dstsrc, unit_map::const_iterator leader)
{
//get versions of the move map that assume that all units are at full movement
std::map<gamemap::location,paths> dummy_possible_moves;
@ -1238,7 +1237,7 @@ bool ai::retreat_units(std::map<gamemap::location,paths>& possible_moves, const
//this unit still has movement left, and is a candidate to retreat. We see the amount
//of power of each side on the situation, and decide whether it should retreat.
if(should_retreat(i->first,i,fullmove_srcdst,fullmove_dstsrc,enemy_srcdst,enemy_dstsrc)) {
if(should_retreat(i->first,i,fullmove_srcdst,fullmove_dstsrc,enemy_dstsrc)) {
bool can_reach_leader = false;
@ -1262,8 +1261,8 @@ bool ai::retreat_units(std::map<gamemap::location,paths>& possible_moves, const
//on the hex we're planning to flee to.
const gamemap::location& hex = itors.first->second;
const int defense = i->second.type().movement_type().defense_modifier(map_,map_.get_terrain(hex));
const double our_power = power_projection(hex,srcdst,dstsrc);
const double their_power = power_projection(hex,enemy_srcdst,enemy_dstsrc) * double(defense)/100.0;
const double our_power = power_projection(hex,dstsrc);
const double their_power = power_projection(hex,enemy_dstsrc) * double(defense)/100.0;
const double rating = our_power - their_power;
if(rating > best_rating) {
best_pos = hex;
@ -1304,13 +1303,13 @@ bool ai::retreat_units(std::map<gamemap::location,paths>& possible_moves, const
return false;
}
bool ai::move_to_targets(std::map<gamemap::location,paths>& possible_moves, move_map& srcdst, move_map& dstsrc, const move_map& enemy_srcdst, const move_map& enemy_dstsrc, unit_map::const_iterator leader)
bool ai::move_to_targets(std::map<gamemap::location,paths>& possible_moves, move_map& srcdst, move_map& dstsrc, const move_map& enemy_dstsrc, unit_map::const_iterator leader)
{
LOG_AI << "finding targets...\n";
std::vector<target> targets;
for(;;) {
if(targets.empty()) {
targets = find_targets(leader,enemy_srcdst,enemy_dstsrc);
targets = find_targets(leader,enemy_dstsrc);
targets.insert(targets.end(),additional_targets_.begin(),
additional_targets_.end());
if(targets.empty()) {
@ -1319,7 +1318,7 @@ bool ai::move_to_targets(std::map<gamemap::location,paths>& possible_moves, move
}
LOG_AI << "choosing move...\n";
std::pair<location,location> move = choose_move(targets,srcdst,dstsrc,enemy_srcdst,enemy_dstsrc);
std::pair<location,location> move = choose_move(targets,srcdst,dstsrc,enemy_dstsrc);
for(std::vector<target>::const_iterator ittg = targets.begin(); ittg != targets.end(); ++ittg) {
wassert(map_.on_board(ittg->loc));
}
@ -1524,10 +1523,10 @@ void ai::analyze_potential_recruit_movements()
log_scope2(ai, "analyze_potential_recruit_movements()");
const int max_targets = 5;
const unsigned int max_targets = 5;
const move_map srcdst, dstsrc;
std::vector<target> targets = find_targets(leader,srcdst,dstsrc);
std::vector<target> targets = find_targets(leader,dstsrc);
if(targets.size() > max_targets) {
std::sort(targets.begin(),targets.end(),target_comparer_distance(start));
targets.erase(targets.begin()+max_targets,targets.end());
@ -1682,7 +1681,7 @@ void ai::do_recruitment()
}
}
void ai::move_leader_to_goals(const move_map& enemy_srcdst, const move_map& enemy_dstsrc)
void ai::move_leader_to_goals( const move_map& enemy_dstsrc)
{
const config* const goal = current_team().ai_parameters().child("leader_goal");
@ -1721,7 +1720,7 @@ void ai::move_leader_to_goals(const move_map& enemy_srcdst, const move_map& enem
gamemap::location loc;
for(std::vector<gamemap::location>::const_iterator itor = route.steps.begin(); itor != route.steps.end(); ++itor) {
if(leader_paths.routes.count(*itor) == 1 && power_projection(*itor,enemy_srcdst,enemy_dstsrc) < double(leader->second.hitpoints()/2)) {
if(leader_paths.routes.count(*itor) == 1 && power_projection(*itor,enemy_dstsrc) < double(leader->second.hitpoints()/2)) {
loc = *itor;
}
}
@ -1910,7 +1909,7 @@ int ai::rate_terrain(const unit& u, const gamemap::location& loc)
if(map_.is_village(terrain)) {
const int owner = village_owner(loc,teams_);
if(owner+1 == team_num_) {
if(owner+1 == (int)team_num_) {
rating += friendly_village_value;
} else if(owner == -1) {
rating += neutral_village_value;
@ -1922,9 +1921,7 @@ int ai::rate_terrain(const unit& u, const gamemap::location& loc)
return rating;
}
const ai::defensive_position& ai::best_defensive_position(const gamemap::location& loc,
const move_map& dstsrc, const move_map& srcdst,
const move_map& enemy_dstsrc, const move_map& enemy_srcdst) const
const ai::defensive_position& ai::best_defensive_position(const gamemap::location& loc, const move_map& dstsrc, const move_map& srcdst, const move_map& enemy_dstsrc) const
{
const unit_map::const_iterator itor = units_.find(loc);
if(itor == units_.end()) {
@ -1952,8 +1949,8 @@ const ai::defensive_position& ai::best_defensive_position(const gamemap::locatio
continue;
}
const double vulnerability = power_projection(i->second,enemy_srcdst,enemy_dstsrc);
const double support = power_projection(i->second,srcdst,dstsrc);
const double vulnerability = power_projection(i->second,enemy_dstsrc);
const double support = power_projection(i->second,dstsrc);
if(defense < pos.chance_to_hit || support - vulnerability > pos.support - pos.vulnerability) {
pos.loc = i->second;

View file

@ -46,8 +46,8 @@ public:
double vulnerability, support;
};
const defensive_position& best_defensive_position(const location& unit, const move_map& dstsrc, const move_map& srcdst,
const move_map& enemy_dstsrc, const move_map& enemy_srcdst) const;
const defensive_position& best_defensive_position(const location& unit,
const move_map& dstsrc, const move_map& srcdst, const move_map& enemy_dstsrc) const;
void invalidate_defensive_position_cache();
bool leader_can_reach_keep() const;
@ -63,17 +63,17 @@ protected:
virtual bool do_combat(std::map<gamemap::location,paths>& possible_moves, const move_map& srcdst, const move_map& dstsrc, const move_map& enemy_srcdst, const move_map& enemy_dstsrc);
virtual bool get_villages(std::map<gamemap::location,paths>& possible_moves, const move_map& srcdst, const move_map& dstsrc, const move_map& enemy_srcdst, const move_map& enemy_dstsrc, unit_map::const_iterator leader);
virtual bool get_healing(std::map<gamemap::location,paths>& possible_moves, const move_map& srcdst, const move_map& dstsrc, const move_map& enemy_srcdst, const move_map& enemy_dstsrc);
virtual bool retreat_units(std::map<gamemap::location,paths>& possible_moves, const move_map& srcdst, const move_map& dstsrc, const move_map& enemy_srcdst, const move_map& enemy_dstsrc, unit_map::const_iterator leader);
virtual bool move_to_targets(std::map<gamemap::location,paths>& possible_moves, move_map& srcdst, move_map& dstsrc, const move_map& enemy_srcdst, const move_map& enemy_dstsrc, unit_map::const_iterator leader);
virtual bool get_healing(std::map<gamemap::location,paths>& possible_moves, const move_map& srcdst, const move_map& enemy_dstsrc);
virtual bool retreat_units(std::map<gamemap::location,paths>& possible_moves, const move_map& srcdst, const move_map& dstsrc, const move_map& enemy_dstsrc, unit_map::const_iterator leader);
virtual bool move_to_targets(std::map<gamemap::location,paths>& possible_moves, move_map& srcdst, move_map& dstsrc, const move_map& enemy_dstsrc, unit_map::const_iterator leader);
virtual bool should_retreat(const gamemap::location& loc, unit_map::const_iterator un, const move_map& srcdst, const move_map& dstsrc, const move_map& enemy_srcdst, const move_map& enemy_dstsrc) const;
virtual bool should_retreat(const gamemap::location& loc, unit_map::const_iterator un, const move_map& srcdst, const move_map& dstsrc, const move_map& enemy_dstsrc) const;
virtual void do_recruitment();
virtual void move_leader_to_keep(const move_map& enemy_dstsrc);
virtual void move_leader_after_recruit(const move_map& enemy_dstsrc);
virtual void move_leader_to_goals(const move_map& enemy_srcdst, const move_map& enemy_dstsrc);
virtual void move_leader_to_goals(const move_map& enemy_dstsrc);
virtual bool recruit_usage(const std::string& usage);
@ -108,7 +108,7 @@ protected:
{
void analyze(const gamemap& map, std::map<location,unit>& units, int sims,
class ai& ai_obj, const move_map& dstsrc, const move_map& srcdst,
const move_map& enemy_dstsrc, const move_map& enemy_srcdst);
const move_map& enemy_dstsrc);
double rating(double aggression, class ai& ai_obj) const;
@ -181,7 +181,7 @@ protected:
//Example: 'loc' can be reached by two units, one of whom has a 10-3 attack and has 48/48 hp, and
//can defend at 40% on the adjacent grassland. The other has a 8-2 attack, and has 30/40 hp, and
//can defend at 60% on the adjacent mountain. The rating will be 10*3*1.0*0.4 + 8*2*0.75*0.6 = 19.2
virtual double power_projection(const gamemap::location& loc, const move_map& srcdst, const move_map& dstsrc, bool use_terrain=true) const;
virtual double power_projection(const gamemap::location& loc, const move_map& dstsrc, bool use_terrain=true) const;
virtual std::vector<attack_analysis> analyze_targets(
const move_map& srcdst, const move_map& dstsrc,
@ -190,15 +190,15 @@ protected:
bool is_accessible(const location& loc, const move_map& dstsrc) const;
virtual std::vector<target> find_targets(unit_map::const_iterator leader, const move_map& enemy_srcdst, const move_map& enemy_dstsrc);
virtual std::vector<target> find_targets(unit_map::const_iterator leader, const move_map& enemy_dstsrc);
//function to form a group of units suitable for moving along the route, 'route'.
//returns the location which the group may reach this turn.
//stores the locations of the units in the group in 'units'
virtual location form_group(const std::vector<location>& route, const move_map& dstsrc, const move_map& srcdst, std::set<location>& units);
virtual location form_group(const std::vector<location>& route, const move_map& dstsrc, std::set<location>& units);
//function to return the group of enemies that threaten a certain path
virtual void enemies_along_path(const std::vector<location>& route, const move_map& dstsrc, const move_map& srcdst, std::set<location>& units);
virtual void enemies_along_path(const std::vector<location>& route, const move_map& dstsrc, std::set<location>& units);
virtual bool move_group(const location& dst, const std::vector<location>& route, const std::set<location>& units);
@ -206,7 +206,7 @@ protected:
virtual double compare_groups(const std::set<location>& our_group, const std::set<location>& enemy_groups, const std::vector<location>& battlefield) const;
virtual std::pair<location,location> choose_move(std::vector<target>& targets,const move_map& srcdst, const move_map& dstsrc, const move_map& enemy_srcdst, const move_map& enemy_dstsrc);
virtual std::pair<location,location> choose_move(std::vector<target>& targets,const move_map& srcdst, const move_map& dstsrc, const move_map& enemy_dstsrc);
//function which rates the value of moving onto certain terrain for a unit
virtual int rate_terrain(const unit& u, const location& loc);
@ -216,7 +216,7 @@ protected:
const game_data& gameinfo_;
unit_map& units_;
std::vector<team>& teams_;
int team_num_;
unsigned int team_num_;
const gamestatus& state_;
bool consider_combat_;
std::vector<target> additional_targets_;

View file

@ -195,12 +195,12 @@ void ai::do_attack_analysis(
}
//find out how vulnerable we are to attack from enemy units in this hex
const double vulnerability = power_projection(tiles[j],enemy_srcdst,enemy_dstsrc);
const double vulnerability = power_projection(tiles[j],enemy_dstsrc);
//calculate how much support we have on this hex from allies. Support does not
//take into account terrain, because we don't want to move into a hex that is
//surrounded by good defensive terrain
const double support = power_projection(tiles[j],fullmove_srcdst,fullmove_dstsrc,false);
const double support = power_projection(tiles[j],fullmove_dstsrc,false);
//if this is a position with equal defense to another position, but more vulnerability
//then we don't want to use it
@ -225,7 +225,7 @@ void ai::do_attack_analysis(
cur_analysis.is_surrounded = is_surrounded;
cur_analysis.analyze(map_, units_, 50, *this, dstsrc, srcdst, enemy_dstsrc, enemy_srcdst);
cur_analysis.analyze(map_, units_, 50, *this, dstsrc, srcdst, enemy_dstsrc);
if(cur_analysis.rating(current_team().aggression(),*this) > rating_to_beat) {
@ -355,7 +355,7 @@ int ai::choose_weapon(const location& att, const location& def,
void ai::attack_analysis::analyze(const gamemap& map, unit_map& units, int num_sims, ai& ai_obj,
const ai::move_map& dstsrc, const ai::move_map& srcdst,
const ai::move_map& enemy_dstsrc, const ai::move_map& enemy_srcdst)
const ai::move_map& enemy_dstsrc)
{
const unit_map::const_iterator defend_it = units.find(target);
wassert(defend_it != units.end());
@ -570,7 +570,7 @@ void ai::attack_analysis::analyze(const gamemap& map, unit_map& units, int num_s
const unit_map::const_iterator att = units.find(movements[i].first);
const double cost = att->second.type().cost();
cost_sum += cost;
alternative_terrain_quality += cost*ai_obj.best_defensive_position(att->first,dstsrc,srcdst,enemy_dstsrc,enemy_srcdst).chance_to_hit;
alternative_terrain_quality += cost*ai_obj.best_defensive_position(att->first,dstsrc,srcdst,enemy_dstsrc).chance_to_hit;
}
alternative_terrain_quality /= cost_sum*100;
@ -715,7 +715,7 @@ std::vector<ai::attack_analysis> ai::analyze_targets(
return res;
}
double ai::power_projection(const gamemap::location& loc, const move_map& srcdst, const move_map& dstsrc, bool use_terrain) const
double ai::power_projection(const gamemap::location& loc, const move_map& dstsrc, bool use_terrain) const
{
static gamemap::location used_locs[6];
static double ratings[6];

View file

@ -30,7 +30,7 @@ public:
///that an AI might need access to in order to make and implement its decisions
struct info {
info(display& disp, const gamemap& map, const game_data& gameinfo, unit_map& units,
std::vector<team>& teams, int team_num, const gamestatus& state, class turn_info& turn_data)
std::vector<team>& teams, unsigned int team_num, const gamestatus& state, class turn_info& turn_data)
: disp(disp), map(map), gameinfo(gameinfo), units(units), teams(teams),
team_num(team_num), state(state), turn_data_(turn_data)
{}
@ -52,7 +52,7 @@ public:
///the number of the team the AI is. Note that this number is 1-based, so it
///has to have 1 subtracted from it for it to be used as an index of 'teams'
int team_num;
unsigned int team_num;
///information about what turn it is, and what time of day
const gamestatus& state;

View file

@ -83,7 +83,7 @@ private:
const bool avoid_enemies_;
};
std::vector<ai::target> ai::find_targets(unit_map::const_iterator leader, const move_map& enemy_srcdst, const move_map& enemy_dstsrc)
std::vector<ai::target> ai::find_targets(unit_map::const_iterator leader, const move_map& enemy_dstsrc)
{
log_scope2(ai, "finding targets...");
@ -93,7 +93,7 @@ std::vector<ai::target> ai::find_targets(unit_map::const_iterator leader, const
//if enemy units are in range of the leader, then we target the enemies who are in range.
if(has_leader) {
const double threat = power_projection(leader->first,enemy_srcdst,enemy_dstsrc);
const double threat = power_projection(leader->first,enemy_dstsrc);
if(threat > 0.0) {
//find the location of enemy threats
std::set<gamemap::location> threats;
@ -187,7 +187,7 @@ std::vector<ai::target> ai::find_targets(unit_map::const_iterator leader, const
return targets;
}
gamemap::location ai::form_group(const std::vector<location>& route, const move_map& dstsrc, const move_map& srcdst, std::set<location>& res)
gamemap::location ai::form_group(const std::vector<location>& route, const move_map& dstsrc, std::set<location>& res)
{
if(route.empty()) {
return location();
@ -228,7 +228,7 @@ gamemap::location ai::form_group(const std::vector<location>& route, const move_
return *i;
}
void ai::enemies_along_path(const std::vector<location>& route, const move_map& dstsrc, const move_map& srcdst, std::set<location>& res)
void ai::enemies_along_path(const std::vector<location>& route, const move_map& dstsrc, std::set<location>& res)
{
for(std::vector<location>::const_iterator i = route.begin(); i != route.end(); ++i) {
gamemap::location adj[6];
@ -378,7 +378,7 @@ double ai::compare_groups(const std::set<location>& our_group, const std::set<lo
return a/b;
}
std::pair<gamemap::location,gamemap::location> ai::choose_move(std::vector<target>& targets, const move_map& srcdst, const move_map& dstsrc, const move_map& enemy_srcdst, const move_map& enemy_dstsrc)
std::pair<gamemap::location,gamemap::location> ai::choose_move(std::vector<target>& targets, const move_map& srcdst, const move_map& dstsrc, const move_map& enemy_dstsrc)
{
log_scope2(ai, "choosing move");
@ -456,7 +456,7 @@ std::pair<gamemap::location,gamemap::location> ai::choose_move(std::vector<targe
//scouts do not like encountering enemies on their paths
if(u->second.type().usage() == "scout") {
std::set<location> enemies_guarding;
enemies_along_path(cur_route.steps,enemy_dstsrc,enemy_srcdst,enemies_guarding);
enemies_along_path(cur_route.steps,enemy_dstsrc,enemies_guarding);
if(enemies_guarding.size() > 1) {
rating /= enemies_guarding.size();
@ -537,7 +537,7 @@ std::pair<gamemap::location,gamemap::location> ai::choose_move(std::vector<targe
//scouts do not like encountering enemies on their paths
if(u->second.type().usage() == "scout") {
std::set<location> enemies_guarding;
enemies_along_path(cur_route.steps,enemy_dstsrc,enemy_srcdst,enemies_guarding);
enemies_along_path(cur_route.steps,enemy_dstsrc,enemies_guarding);
if(enemies_guarding.size() > 1) {
rating /= enemies_guarding.size();
@ -584,7 +584,7 @@ std::pair<gamemap::location,gamemap::location> ai::choose_move(std::vector<targe
for(std::vector<location>::const_iterator i = locs.begin(); i != locs.end(); ++i) {
const int distance = distance_between(*i,best_target->loc);
const int defense = best->second.defense_modifier(map_,map_.get_terrain(*i));
const double vulnerability = power_projection(*i,enemy_srcdst,enemy_dstsrc);
const double vulnerability = power_projection(*i,enemy_dstsrc);
if(best_loc.valid() == false || defense < best_defense || defense == best_defense && vulnerability < best_vulnerability) {
best_loc = *i;
@ -618,8 +618,8 @@ std::pair<gamemap::location,gamemap::location> ai::choose_move(std::vector<targe
//if any point along the path is too dangerous for our single unit, then we hold back
for(std::vector<location>::const_iterator i = best_route.steps.begin(); i != best_route.steps.end() && movement > 0; ++i) {
const double threat = power_projection(*i,enemy_srcdst,enemy_dstsrc);
if(threat >= double(best->second.hitpoints()) && threat > power_projection(*i,fullmove_srcdst,fullmove_dstsrc) ||
const double threat = power_projection(*i,enemy_dstsrc);
if(threat >= double(best->second.hitpoints()) && threat > power_projection(*i,fullmove_dstsrc) ||
i >= best_route.steps.end()-2 && unit_at_target != units_.end() && current_team().is_enemy(unit_at_target->second.side())) {
dangerous = true;
break;
@ -636,8 +636,8 @@ std::pair<gamemap::location,gamemap::location> ai::choose_move(std::vector<targe
if(dangerous) {
LOG_AI << "dangerous path\n";
std::set<location> group, enemies;
const location dst = form_group(best_route.steps,dstsrc,srcdst,group);
enemies_along_path(best_route.steps,enemy_dstsrc,enemy_srcdst,enemies);
const location dst = form_group(best_route.steps,dstsrc,group);
enemies_along_path(best_route.steps,enemy_dstsrc,enemies);
const double our_strength = compare_groups(group,enemies,best_route.steps);
@ -677,7 +677,7 @@ std::pair<gamemap::location,gamemap::location> ai::choose_move(std::vector<targe
for(move_map::const_iterator i = itors.first; i != itors.second; ++i) {
const int distance = distance_between(target_loc,i->second);
const int defense = un.defense_modifier(map_,map_.get_terrain(i->second));
const double threat = (power_projection(i->second,enemy_srcdst,enemy_dstsrc)*defense)/100;
const double threat = (power_projection(i->second,enemy_dstsrc)*defense)/100;
if(best_loc.valid() == false || threat < maximum<double>(best_threat,max_acceptable_threat) && distance < best_distance) {
best_loc = i->second;
@ -715,7 +715,7 @@ std::pair<gamemap::location,gamemap::location> ai::choose_move(std::vector<targe
std::pair<Itor,Itor> its = dstsrc.equal_range(*ri);
while(its.first != its.second) {
if(its.first->second == best->first) {
if(!should_retreat(its.first->first,best,fullmove_srcdst,fullmove_dstsrc,enemy_srcdst,enemy_dstsrc)) {
if(!should_retreat(its.first->first,best,fullmove_srcdst,fullmove_dstsrc,enemy_dstsrc)) {
const double value = best_target->value - best->second.type().cost()/20.0;
if(value > 0.0 && best_target->type != target::MASS) {

View file

@ -110,7 +110,7 @@ unit::unit(const unit_type* t, int side, bool use_traits, bool dummy_unit, unit_
clock_t ct = clock();
char buf[20];
snprintf(buf,sizeof(buf),"-%d",ct);
snprintf(buf,sizeof(buf),"-%lu",ct);
std::string time_tag(buf);
if(use_traits) {
@ -223,7 +223,7 @@ void unit::rename(const std::string& new_description)
}
}
int unit::side() const
unsigned int unit::side() const
{
return side_;
}
@ -247,7 +247,7 @@ unit_race::GENDER unit::gender() const
return gender_;
}
void unit::set_side(int new_side)
void unit::set_side(unsigned int new_side)
{
side_ = new_side;
}
@ -1152,7 +1152,7 @@ std::vector<std::pair<std::string,std::string> > unit::amla_icons() const
icon.first=(**i)["image"];
icon.second=(**i)["description"];
for(int j=0;j<(modification_count("advance",(**i)["id"]));j++) {
for(unsigned int j=0;j<(modification_count("advance",(**i)["id"]));j++) {
temp.push_back(icon);
}
@ -1401,7 +1401,7 @@ void unit::apply_modifications()
void unit::remove_temporary_modifications()
{
for(int i = 0; i != NumModificationTypes; ++i) {
for(unsigned int i = 0; i != NumModificationTypes; ++i) {
const std::string& mod = ModificationTypes[i];
const config::child_list& mods = modifications_.get_children(mod);
for(size_t j = 0; j != mods.size(); ++j) {
@ -1439,7 +1439,7 @@ bool unit::is_flying() const
return type().movement_type().is_flying();
}
int team_units(const unit_map& units, int side)
int team_units(const unit_map& units, unsigned int side)
{
int res = 0;
for(unit_map::const_iterator i = units.begin(); i != units.end(); ++i) {
@ -1451,7 +1451,7 @@ int team_units(const unit_map& units, int side)
return res;
}
int team_upkeep(const unit_map& units, int side)
int team_upkeep(const unit_map& units, unsigned int side)
{
int res = 0;
for(unit_map::const_iterator i = units.begin(); i != units.end(); ++i) {
@ -1463,7 +1463,7 @@ int team_upkeep(const unit_map& units, int side)
return res;
}
unit_map::const_iterator team_leader(int side, const unit_map& units)
unit_map::const_iterator team_leader(unsigned int side, const unit_map& units)
{
for(unit_map::const_iterator i = units.begin(); i != units.end(); ++i) {
if(i->second.can_recruit() && i->second.side() == side) {
@ -1533,7 +1533,7 @@ team_data calculate_team_data(const team& tm, int side, const unit_map& units)
return res;
}
std::string get_team_name(int side, const unit_map& units)
std::string get_team_name(unsigned int side, const unit_map& units)
{
for(unit_map::const_iterator i = units.begin(); i != units.end(); ++i) {
if(i->second.can_recruit() && i->second.side() == side) {

View file

@ -58,11 +58,11 @@ public:
bool get_experience(int xp);
bool unrenamable() const; /** < Set to true for some scenario-specific units which should not be renamed */
bool advances() const;
int side() const;
unsigned int side() const;
Uint32 team_rgb() const;
std::vector<Uint32> team_rgb_range() const;
unit_race::GENDER gender() const;
void set_side(int new_side);
void set_side(unsigned int new_side);
fixed_t alpha() const;
void make_recruiter();
bool can_recruit() const;
@ -201,7 +201,7 @@ private:
int experience_;
int maxExperience_, backupMaxExperience_;
int side_;
unsigned int side_;
int moves_;
bool user_end_turn_;
@ -278,9 +278,9 @@ private:
void sort_units(std::vector< unit > &);
int team_units(const unit_map& units, int team_num);
int team_upkeep(const unit_map& units, int team_num);
unit_map::const_iterator team_leader(int side, const unit_map& units);
int team_units(const unit_map& units, unsigned int team_num);
int team_upkeep(const unit_map& units, unsigned int team_num);
unit_map::const_iterator team_leader(unsigned int side, const unit_map& units);
std::string team_name(int side, const unit_map& units);
unit_map::iterator find_visible_unit(unit_map& units,
const gamemap::location loc,
@ -298,7 +298,7 @@ struct team_data
team_data calculate_team_data(const class team& tm, int side, const unit_map& units);
std::string get_team_name(int side, const unit_map& units);
std::string get_team_name(unsigned int side, const unit_map& units);
const std::set<gamemap::location> vacant_villages(const std::set<gamemap::location>& villages, const unit_map& units);

View file

@ -562,14 +562,14 @@ void unit_movement_type::set_parent(const unit_movement_type* parent)
unit_type::unit_type(const unit_type& o)
: variations_(o.variations_), cfg_(o.cfg_), race_(o.race_),
alpha_(o.alpha_), abilities_(o.abilities_),
alpha_(o.alpha_), abilities_(o.abilities_),ability_tooltips_(o.ability_tooltips_),
max_heals_(o.max_heals_), heals_(o.heals_), regenerates_(o.regenerates_),
leadership_(o.leadership_), illuminates_(o.illuminates_),
skirmish_(o.skirmish_), teleport_(o.teleport_),regeneration_(o.regeneration_),
steadfast_bonus_(o.steadfast_bonus_),steadfast_max_(o.steadfast_max_),
steadfast_(o.steadfast_),leadership_percent_(o.leadership_percent_),
regeneration_(o.regeneration_), leadership_(o.leadership_),
leadership_percent_(o.leadership_percent_), illuminates_(o.illuminates_),
skirmish_(o.skirmish_), teleport_(o.teleport_), steadfast_(o.steadfast_),
steadfast_bonus_(o.steadfast_bonus_),steadfast_max_(o.steadfast_max_),
advances_to_(o.advances_to_), experience_needed_(o.experience_needed_),
alignment_(o.alignment_),ability_tooltips_(o.ability_tooltips_),
alignment_(o.alignment_),
movementType_(o.movementType_), possibleTraits_(o.possibleTraits_),
genders_(o.genders_), defensive_animations_(o.defensive_animations_),
teleport_animations_(o.teleport_animations_), extra_animations_(o.extra_animations_),