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

Faster pollution #343

Merged
merged 3 commits into from
Jan 16, 2020
Merged

Faster pollution #343

merged 3 commits into from
Jan 16, 2020

Conversation

arvid220u
Copy link
Contributor

@arvid220u arvid220u commented Jan 16, 2020

This should fix #342.

  • Make engine calculate pollution on the fly
  • Add schema field actualPollution
  • Modify client to use that field instead

The first change is dramatic — a game that used to take more than 1 hour now takes 3 minutes.

LocalPollutionEffect pE = localPollutions.get(robotID);
for (MapLocation affectedLoc : getAllLocationsWithinRadiusSquared(pE.loc, pE.radiusSquared)) {
this.localAdditivePollution[locationToIndex(affectedLoc)] -= pE.additiveEffect;
this.localMultiplicativePollution[locationToIndex(affectedLoc)] /= pE.multiplicativeEffect;
Copy link
Contributor

@stefangimmillaro stefangimmillaro Jan 16, 2020

Choose a reason for hiding this comment

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

anything preventing this from divide by 0?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah, the multiplicative effect is always either 0.8 or 1.

@arvid220u
Copy link
Contributor Author

In fact, when running this in the client, I am not noticing a speedup when removing the pollution calculation, indicating that that is not what makes the client slow. Since it will be a pain to update the schema and ensure backwards compatibility, I suggest we just don't do that

@arvid220u arvid220u merged commit 497c18c into master Jan 16, 2020
@arvid220u arvid220u deleted the fasterpollution branch January 17, 2020 07:00
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.

Performance of pollution code is subpar
2 participants