makes lottery fair (#652)

previous lottery gave first & last members of the chosen array around half the probability of winning vs. other participants since 0.5-1.5 rounds to 1 but only <0.5 rounds to zero.
This commit is contained in:
Tom Etminan 2021-10-07 17:09:30 +01:00 committed by GitHub
parent f4fbe26bd0
commit f6e6a7b776
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 1 deletions

View File

@ -2388,7 +2388,7 @@ program
console.log('Doing lottery for', numWinnersRemaining);
while (numWinnersRemaining > 0) {
const rand = Math.round(Math.random() * (chosen.length - 1));
const rand = Math.floor(Math.random() * (chosen.length));
if (chosen[rand].chosen != true && chosen[rand].eligible) {
chosen[rand].chosen = true;
numWinnersRemaining--;