AI move_to_targets CA: do not use dynamic limit for a* search

Using a dynamic limit here is not the right way to do this, among other things for the reasons given in the old comment. The new comment is copied from a bit earlier in the code, where more path finding is done. Path finding is indeed the most expensive part of the evaluation, but which of the two path finding loops takes more time depends on whether there are more goals or more units on the map.

In any case, if we want to improve the efficiency of this part of the code, it should be done by some sort of "smart pre-selection" rather than by limiting the a* search like this.  Also, this second path finding loop can already be skipped by using simple_targeting=yes.

Note that this commit does not change current behavior, it only removes the TODO and commented-out code.
This commit is contained in:
mattsc 2018-12-07 07:34:27 -08:00
parent 6824f9bced
commit 761b110f1f

View File

@ -402,12 +402,9 @@ std::pair<map_location,map_location> move_to_targets_phase::choose_move(std::vec
const move_cost_calculator calc(*u, map_, units_, enemy_dstsrc);
///@todo 1.9: 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, (double) 100.0);
// locStopValue controls how quickly we give up on the A* search, due
// to it seeming futile. Be very cautious about changing this value,
// as it can cause the AI to give up on searches and just do nothing.
const double locStopValue = 500.0;
const pathfind::teleport_map allowed_teleports = pathfind::get_teleport_locations(*u, current_team());
pathfind::plain_route cur_route = pathfind::a_star_search(u->get_location(), best_target->loc, locStopValue, calc, map_.w(), map_.h(), &allowed_teleports);