From a536b3fac3a1e3ebbf8b93a24f08049998ea5657 Mon Sep 17 00:00:00 2001 From: Ali El Gariani Date: Sat, 10 Oct 2009 22:46:12 +0000 Subject: [PATCH] Commit experimental bugfix for default AI in RCA AI (exerimental targeting) Fix a very old bug making the AI rates targets as if they were all reachable in 1 turn. AI should now prefer targets reachable in 2 turns against one needing 3 (if same value). Note that it only affects targets needing more than 1 turn to reach. This also make "complex targetting" works and should make the AI pick the best unit to reach the best target (probably begin by sending scouts grab undefended villages) --- src/ai/testing/ca_testing_move_to_targets.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/ai/testing/ca_testing_move_to_targets.cpp b/src/ai/testing/ca_testing_move_to_targets.cpp index 28c41f74832..f47f533e85c 100644 --- a/src/ai/testing/ca_testing_move_to_targets.cpp +++ b/src/ai/testing/ca_testing_move_to_targets.cpp @@ -211,7 +211,7 @@ double testing_move_to_targets_phase::rate_target(const target& tg, const unit_m if(move_cost > 0) { // if this unit can move to that location this turn, it has a very very low cost typedef std::multimap::const_iterator multimapItor; - std::pair locRange = dstsrc.equal_range(u->first); + std::pair locRange = dstsrc.equal_range(tg.loc); while (locRange.first != locRange.second) { if (locRange.first->second == u->first) { move_cost = 0; @@ -392,7 +392,14 @@ std::pair testing_move_to_targets_phase::choose_move( raise_user_interact(); const move_cost_calculator calc(u->second, map_, units_, enemy_dstsrc); - const double locStopValue = std::min(best_target->value / best_rating, 100.0); + + //TODO : lower this value for perf, + // but best_rating is too big for scout and support + // which give a too small locStopValue + // so keep costy A* for the moment. + //const double locStopValue = std::min(best_target->value / best_rating, 100.0); + + const double locStopValue = 500.0; plain_route cur_route = a_star_search(u->first, best_target->loc, locStopValue, &calc, map_.w(), map_.h()); if(cur_route.steps.empty()) {