AI: fix [leader_goal] for sides with multiple leaders
Previously the AI would only move one of the leaders.
This commit is contained in:
parent
78a40c8dcb
commit
a9d9fbaccd
1 changed files with 15 additions and 2 deletions
|
@ -280,8 +280,21 @@ double move_leader_to_goals_phase::evaluate()
|
||||||
return BAD_SCORE;
|
return BAD_SCORE;
|
||||||
}
|
}
|
||||||
|
|
||||||
const unit_map::iterator leader = resources::gameboard->units().find_leader(get_side());
|
const unit_map &units_ = resources::gameboard->units();
|
||||||
if (!leader.valid() || leader->incapacitated()) {
|
const std::vector<unit_map::const_iterator> leaders = units_.find_leaders(get_side());
|
||||||
|
if (leaders.empty()) {
|
||||||
|
return BAD_SCORE;
|
||||||
|
}
|
||||||
|
|
||||||
|
const unit* leader = nullptr;
|
||||||
|
for (const unit_map::const_iterator& l_itor : leaders) {
|
||||||
|
if (!l_itor->incapacitated() && l_itor->movement_left() > 0) {
|
||||||
|
leader = &(*l_itor);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (leader == nullptr) {
|
||||||
WRN_AI_TESTING_AI_DEFAULT << "Leader not found" << std::endl;
|
WRN_AI_TESTING_AI_DEFAULT << "Leader not found" << std::endl;
|
||||||
return BAD_SCORE;
|
return BAD_SCORE;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue