From f6e6a7b7767f18824950326fba20b59872f2a2e2 Mon Sep 17 00:00:00 2001 From: Tom Etminan Date: Thu, 7 Oct 2021 17:09:30 +0100 Subject: [PATCH] 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. --- js/packages/cli/src/fair-launch-cli.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/packages/cli/src/fair-launch-cli.ts b/js/packages/cli/src/fair-launch-cli.ts index 881b6fe..7ce263a 100755 --- a/js/packages/cli/src/fair-launch-cli.ts +++ b/js/packages/cli/src/fair-launch-cli.ts @@ -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--;