Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ai fix planes without carrier capacity purchase bug #1752

Merged

Conversation

ron-murhammer
Copy link
Member

Fixes this reported bug: https://forums.triplea-game.org/topic/73/iron-war-official-thread/85

For AI sea zones purchases, if it can't afford any sea units but can afford air units, it will buy air units even if there isn't carrier space. It actually realizes there isn't enough carrier room but there is a bug that even though all air units have a 0% chance of being purchased it still selects one of them randomly! Essentially, this is just a rare edge case that has to do with not handling when only air units are available to purchase based on resources in a SZ and none of them have carrier space. This pretty much never happens on 99% of maps since they have cheap sea units like subs or destroyers that would always be available.


ProLogger.trace("Select purchase option for " + type);
double totalEfficiency = 0;
for (final Double efficiency : purchaseEfficiencies.values()) {
totalEfficiency += efficiency;
}
if (totalEfficiency == 0) {
return Optional.empty();
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is essentially the core of the change. Everything else is just updating all the references and clean up.

Copy link
Member

@ssoloff ssoloff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ron-murhammer, I know pretty much nothing about the AI code, so I simply sanity checked this and didn't see anything that looked problematic. Existing unit tests would have been nice, but ProPurchaseAI looks like a beast. 😃

@ron-murhammer ron-murhammer merged commit 9e428fd into master May 25, 2017
@RoiEXLab RoiEXLab deleted the AI_Fix_Planes_Without_CarrierCapacity_Purchase_Bug branch July 3, 2017 10:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants