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

random: don't bias towards earlier users #97

Merged
merged 2 commits into from Feb 4, 2019
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.
+1 −1
Diff settings

Always

Just for now

Prev

missing parens

  • Loading branch information...
jeffkaufman committed Feb 4, 2019
commit 96d8baed656c318f8f1121608e52cc124886dac9
Copy path View file
@@ -117,7 +117,7 @@ def determine_if_winner():
rnd = random.random()
points_so_far = 0
for user, user_points in util.get_user_points().items():
if rnd < 0.00001 * user_points + points_so_far:
if rnd < 0.00001 * (user_points + points_so_far):
raise Exception('%s wins!' % user)
points_so_far += user_points
This conversation was marked as resolved by jeffkaufman

This comment has been minimized.

@pavellishin

pavellishin Feb 4, 2019

Collaborator

Doesn't this need to be user_points * 0.00001? Otherwise, the second user will be out of the [0, 1) range, and they're nearly guaranteed to win (as long as the first user has at least one point.)

This comment has been minimized.

@jeffkaufman

jeffkaufman Feb 4, 2019

Author Owner

Good catch! Fixed with 96d8bae


ProTip! Use n and p to navigate between commits in a pull request.