Author: soliton
Date: Tue Sep 16 14:24:21 2008
New Revision: 29474
URL: http://svn.gna.org/viewcvs/wesnoth?rev=29474&view=rev
Log:
* made the AI ignore invisible units when checking for enemy leaders or
protected locations
* improved AI target logging
Modified:
trunk/src/ai.cpp
trunk/src/ai_move.cpp
trunk/src/ai_village.cpp
Modified: trunk/src/ai.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/ai.cpp?rev=29474&r1=29473&r2=29474&view=diff
==============================================================================
--- trunk/src/ai.cpp (original)
+++ trunk/src/ai.cpp Tue Sep 16 14:24:21 2008
@@ -940,7 +940,9 @@
for(unit_map::const_iterator u = units_.begin(); u !=
units_.end(); ++u) {
const int distance =
distance_between(u->first,item.loc);
- if(current_team().is_enemy(u->second.side()) &&
distance < item.radius) {
+ if(current_team().is_enemy(u->second.side()) &&
distance < item.radius
+ && !u->second.invisible(u->first, units_, teams_)) {
+ LOG_AI << "found threat target... " << u->first
<< "\n";
add_target(target(u->first, item.value *
double(item.radius-distance) /
double(item.radius),target::THREAT));
}
@@ -1198,6 +1200,7 @@
// If this is the only unit in the attack, and the target
// is still alive, then also summon reinforcements
if(choice_it->movements.size() == 1 &&
units_.count(target_loc)) {
+ LOG_AI << "found reinforcement target... " <<
target_loc << "\n";
add_target(target(target_loc,3.0,target::BATTLE_AID));
}
Modified: trunk/src/ai_move.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/ai_move.cpp?rev=29474&r1=29473&r2=29474&view=diff
==============================================================================
--- trunk/src/ai_move.cpp (original)
+++ trunk/src/ai_move.cpp Tue Sep 16 14:24:21 2008
@@ -120,6 +120,7 @@
const double value = threat/double(threats.size());
for(std::set<gamemap::location>::const_iterator i =
threats.begin(); i != threats.end(); ++i) {
+ LOG_AI << "found threat target... " << *i << "
with value: " << value << "\n";
targets.push_back(target(*i,value,target::THREAT));
}
}
@@ -140,6 +141,7 @@
}
if(get_village) {
+ LOG_AI << "found village target... " << *t << "
with value: " << current_team().village_value() << "\n";
targets.push_back(target(*t,current_team().village_value(),target::VILLAGE));
}
}
@@ -151,11 +153,11 @@
unit_map::const_iterator u;
for(u = units_.begin(); u != units_.end(); ++u) {
- //is an enemy leader
- if(u->second.can_recruit() &&
- current_team().is_enemy(u->second.side())) {
-
+ //is a visible enemy leader
+ if (u->second.can_recruit() &&
current_team().is_enemy(u->second.side())
+ && !u->second.invisible(u->first, units_, teams_)) {
assert(map_.on_board(u->first));
+ LOG_AI << "found enemy leader target... " << u->first
<< " with value: " << current_team().leader_value() << "\n";
targets.push_back(target(u->first,current_team().leader_value(),target::LEADER));
}
@@ -163,7 +165,7 @@
for(std::vector<team::target>::iterator j =
team_targets.begin();
j != team_targets.end(); ++j) {
if(u->second.matches_filter(&(j->criteria),u->first)) {
- LOG_AI << "found explicit target..." <<
j->value << "\n";
+ LOG_AI << "found explicit target... " <<
u->first << " with value: " << j->value << "\n";
targets.push_back(target(u->first,j->value,target::EXPLICIT));
}
}
@@ -431,6 +433,7 @@
if(avoided_locations().count(tg->loc) > 0) {
continue;
}
+ LOG_AI << "Considering target at: " << tg->loc <<"\n";
raise_user_interact();
@@ -710,6 +713,7 @@
for(std::set<location>::const_iterator j =
mass_locations.begin(); j != mass_locations.end(); ++j) {
if(*j != best_loc &&
distance_between(*j,best_loc) < 3) {
+ LOG_AI << "found mass-to-attack
target... " << *j << " with value: " << value*4.0 << "\n";
targets.push_back(target(*j,value*4.0,target::MASS));
}
}
@@ -741,6 +745,7 @@
//there are enemies ahead.
Rally troops around us to
//try to take the target
if(is_dangerous) {
+ LOG_AI << "found
reinforcement target... " << its.first->first << " with value: " << value*2.0
<< "\n";
targets.push_back(target(its.first->first,value*2.0,target::BATTLE_AID));
}
Modified: trunk/src/ai_village.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/ai_village.cpp?rev=29474&r1=29473&r2=29474&view=diff
==============================================================================
--- trunk/src/ai_village.cpp (original)
+++ trunk/src/ai_village.cpp Tue Sep 16 14:24:21 2008
@@ -232,6 +232,7 @@
if(new_unit != units_.end() &&
power_projection(i->first,enemy_dstsrc) >= new_unit->second.hitpoints()/4) {
+ LOG_AI << "found support target... " <<
new_unit->first << "\n";
add_target(target(new_unit->first,1.0,target::SUPPORT));
}
}
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits