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

drop rate fixes #287

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

drop rate fixes #287

wants to merge 1 commit into from

Conversation

pimittens
Copy link

Description

The probability was very slightly off when calculating drop chances. The previous code generated a random integer between 0 (inclusive) and 999,999 (exclusive), when both bounds should have been inclusive. This is based on the assumption that a drop chance of 100,000 should correspond to 10%. Previously there were 999,999 possible values that could be generated (all of the integers from 0 to 999,998), and 100,000 of them were less than 100,000 (all of the integers from 0 to 99,999), so since every integer is equally likely to be generated this gave a 100,000 / 999,999 probability of dropping the item, which is very slightly more than 0.1. This difference is small enough to be negligible, which is probably why it wasn't caught. Increasing the upper bound of the randomly generated number by 1 fixes this.

Additionally, the code which determined the quantity of items dropped when the maximum quantity was greater than 1 always gave a number less than the maximum, and didn't work at all if the max and min were equal. Adding 1 to the bound of the randomly generated number fixes this as well, as shown by the unit test. Also removed the de.Maximum != 1 check since this is not necessary with the fix.

Checklist before requesting a review

  • [ x] I have performed a self-review of my code
  • [x ] I have tested my changes
  • [x ] I have added unit tests that prove my changes work

The probability was very slightly off when calculating drop chances, and there was an error in instances where the maximum number of items dropped was greater than 1.
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.

1 participant