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

Fix KeyError bug with possible_output in ResourcesAI.py #668

Merged
merged 1 commit into from May 17, 2016

Conversation

LGM-Doyle
Copy link
Contributor

The reporting function is able to reference undefined resource keys in possible_output. I changed the references to .get().

@Cjkjvfnby
Copy link
Contributor

May be find real reason and fix? .get will sillently hide this issue

@LGM-Doyle
Copy link
Contributor Author

The real reason is that it is trying to report on values that have not been set, as stated.

I could use defaultdict and set the default to (0,0). That is probably the better solution.

Thoughts?

@Vezzra Vezzra added category:bug The Issue/PR describes or solves a perceived malfunction within the game. component:AI The Issue/PR deals with the Python AI decision making code or affects it. labels May 16, 2016
@Vezzra Vezzra added this to the Release v0.4.6 milestone May 16, 2016
@LGM-Doyle LGM-Doyle force-pushed the refactor_ResourcesAI_py_fix branch from 7d8fb5b to 78babf2 Compare May 17, 2016 19:33
@LGM-Doyle
Copy link
Contributor Author

@Cjkjvfnby, I apologize.

You are entirely correct, my previous PR was hasty because I was concerned about breaking master and people's games.

This PR fixes the problem.

In detail, the problem was that planets that have their focus set by the growth, production or research specials, then do not have both industry and research foci set in calculate_planet_infos() and hence can't be included in the report of min/max research/industry setting.

The solution is to only report on the available results.

@Cjkjvfnby
Copy link
Contributor

@LGM-Doyle, no need to apologize. It is normal working process.

@Cjkjvfnby Cjkjvfnby merged commit 2fdc197 into freeorion:master May 17, 2016
@LGM-Doyle LGM-Doyle deleted the refactor_ResourcesAI_py_fix branch May 17, 2016 20:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category:bug The Issue/PR describes or solves a perceived malfunction within the game. component:AI The Issue/PR deals with the Python AI decision making code or affects it.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants