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

giveaway not being random #251

Closed
kiki0124 opened this issue Jul 17, 2023 · 1 comment
Closed

giveaway not being random #251

kiki0124 opened this issue Jul 17, 2023 · 1 comment

Comments

@kiki0124
Copy link

So if someone with admin role enters a giveaway they have higher chance to win than someone without admin role, from my testing I had about 5 giveaways, each with around 25 participants, 3 admins, 1 winner each giveaway, in 3 of those giveaway one of the people with admin roles won.

@MichailiK
Copy link
Contributor

MichailiK commented Jul 17, 2023

In the code, the winner of a giveaway is determined here:

List<CachedUser> winners = GiveawayUtil.selectWinners(all, giveaway.getWinners());

The selectWinners function calls randDouble:

winlist.add(pullist.remove((int)(randDouble() * pullist.size())));

randDouble uses java.security.SecureRandom to generate a (cryptographically secure) random number.

private static final SecureRandom random = new SecureRandom();
private static synchronized double randDouble()
{
return random.nextDouble();
}

Every user has 1 entry, and a random entry will be picked based on the random number generated by SecureRandom. Additionally, there doesn't seem to be any logic adding more entries to a user, or otherwise favoring people.

It seems unlikely to me that GiveawayBot is rigged in any way, may it be through favoring admins, or anything else.

@jagrosh jagrosh closed this as completed Jul 17, 2023
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

No branches or pull requests

3 participants