Default AI: fix two bugs in the goto candidate action
Both bugs had the same effect: if a unit could not get to its goal location, goto moves by all other units during the same turn were abandoned. However, there were two separate causes for: 1. The goal location was unreachable. This was due to a typo in the code. 2. The goal was theoretically reachable, but blocked by allies. In this case, it could happen that the unit did not move, resulting in the CA being blacklisted.
This commit is contained in:
parent
0ccfbc1525
commit
76a8a98574
2 changed files with 12 additions and 1 deletions
|
@ -290,6 +290,8 @@ Version 1.13.4+dev:
|
|||
* Recognize hotkey release events
|
||||
* Allow changing keybindings for scrolling the map.
|
||||
* Fix the move-to-targets candidate action of the default AI ignoring tunnels
|
||||
* Fix two rare bugs in the goto candidate action that resulted in goto moves
|
||||
by other units being skipped after a unit could not get to its goal.
|
||||
* Replace wmlxgettext tool with new python3 implementation by Nobun:
|
||||
https://github.com/AncientLich/wmlxgettext-unoff/
|
||||
|
||||
|
|
|
@ -113,7 +113,7 @@ double goto_phase::evaluate()
|
|||
if(closest_distance != -1) {
|
||||
move_ = check_move_action(ui->get_location(), closest_move.first);
|
||||
} else {
|
||||
return BAD_SCORE;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -135,6 +135,15 @@ void goto_phase::execute()
|
|||
if (!move_->is_ok()){
|
||||
LOG_AI_TESTING_AI_DEFAULT << get_name() << "::execute not ok" << std::endl;
|
||||
}
|
||||
|
||||
// In some situations, a theoretically possible path is blocked by allies,
|
||||
// resulting in the unit not moving. In this case, we remove all remaining
|
||||
// movement from the unit in order to prevent blacklisting of the CA.
|
||||
if (!move_->is_gamestate_changed()){
|
||||
LOG_AI_TESTING_AI_DEFAULT << get_name() << "::execute did not move unit; removing moves instead" << std::endl;
|
||||
stopunit_result_ptr stopunit = check_stopunit_action(move_->get_unit_location(), true, false);
|
||||
stopunit->execute();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue