Author: esr
Date: Thu Oct 23 02:34:43 2008
New Revision: 30321
URL: http://svn.gna.org/viewcvs/wesnoth?rev=30321&view=rev
Log:
suollo's improvement for adding villages vulnerable to enrmy attack to
the list of move targets, from r29531 (previously reverted as an
emergency fix).
Modified:
trunk/src/ai_move.cpp
Modified: trunk/src/ai_move.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/ai_move.cpp?rev=30321&r1=30320&r2=30321&view=diff
==============================================================================
--- trunk/src/ai_move.cpp (original)
+++ trunk/src/ai_move.cpp Thu Oct 23 02:34:43 2008
@@ -95,6 +95,10 @@
std::vector<target> targets;
+ std::map<location,paths> friends_possible_moves;
+ move_map friends_srcdst, friends_dstsrc;
+
calculate_possible_moves(friends_possible_moves,friends_srcdst,friends_dstsrc,false,true);
+
//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_dstsrc);
@@ -125,6 +129,7 @@
}
}
+ double corner_distance = distance_between(map_location(0,0),
map_location(map_.w(),map_.h()));
if(has_leader && current_team().village_value() > 0.0) {
const std::vector<location>& villages = map_.villages();
for(std::vector<location>::const_iterator t =
@@ -134,14 +139,27 @@
bool get_village = true;
for(size_t i = 0; i != teams_.size(); ++i) {
if(!current_team().is_enemy(i+1) &&
teams_[i].owns_village(*t)) {
+ // check if our village is threatened
+ if (is_accessible(*t, enemy_dstsrc))
+ {
+ // Our village is threated by
enemy
+ // We calculate
enemy_power/our_power and multiple village value with that
+ // to get value for adding more
defense
+ const double enemy =
power_projection(*t, enemy_dstsrc)*1.7;
+ const double our =
power_projection(*t, friends_dstsrc);
+ const double value =
current_team().village_value()*our/enemy;
+ add_target(target(*t, value,
target::SUPPORT));
+ }
get_village = false;
break;
}
}
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));
+ double value = current_team().village_value();
+ value *= 1.0 -
static_cast<double>(distance_between(*t,leader->first))/corner_distance;
+ ERR_AI << "found village target... " << *t << "
with value: " << value << " distance: " <<
static_cast<double>(distance_between(*t,leader->first)) << "\n";
+
targets.push_back(target(*t,value,target::VILLAGE));
}
}
}
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits