Skip to content

Commit

Permalink
Tweak AI isSub logic. (#11817)
Browse files Browse the repository at this point in the history
Previously, it was based on getCanNotTarget(), but actually getCanEvade() is the better option since canNotTarget can be set on non-sub units. This also restores the sub purchase logic that was changed in caf296c.

I think this is a safer version of the change, since the above one may have had an effect where AI would start buying subs for defense, when it shouldn't.

Note: I verified all standard A&A maps and all the subs have canEvade set, so this should ensure the AI continues to behave as before on those maps.
  • Loading branch information
asvitkine committed Jul 26, 2023
1 parent 3154454 commit c345ed7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public class ProPurchaseOption {
transportCost = unitAttachment.getTransportCost() * quantity;
carrierCost = unitAttachment.getCarrierCost() * quantity;
isAir = unitAttachment.getIsAir();
isSub = !unitAttachment.getCanNotTarget().isEmpty();
isSub = unitAttachment.getCanEvade();
isDestroyer = unitAttachment.getIsDestroyer();
isTransport = unitAttachment.getTransportCapacity() > 0;
isLandTransport = unitAttachment.isLandTransport();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,9 @@ public ProPurchaseOptionMap(final GamePlayer player, final GameData data) {
ProLogger.debug("Air: " + ppo);
} else if (Matches.unitTypeIsSea().test(unitType)) {
final ProPurchaseOption ppo = new ProPurchaseOption(rule, unitType, player, data);
seaDefenseOptions.add(ppo);
if (!ppo.isSub()) {
seaDefenseOptions.add(ppo);
}
if (ppo.isTransport()) {
seaTransportOptions.add(ppo);
}
Expand Down

0 comments on commit c345ed7

Please sign in to comment.