Skip to content

Commit d01cc4e

Browse files
Randomize the start order for tournaments
1 parent 3775971 commit d01cc4e

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

utils/starttournaments.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -531,6 +531,7 @@ async function startTournament(users: UserLastSeen[], tournament: Tournament) {
531531
playersFull2[i].games = [];
532532
}
533533
const divisions: { [division: number]: {numGames: number, numCompleted: number, processed: boolean} } = {};
534+
const randomStart = Math.random() < 0.5 ? 0 : 1;
534535
for (let division = 1; division <= numDivisions; division++) {
535536
divisions[division] = {numGames: 0, numCompleted: 0, processed: false};
536537
for (let i = 0; i < (division <= numBigDivisions ? divisionSizeSmall + 1 : divisionSizeSmall); i++) {
@@ -540,7 +541,7 @@ async function startTournament(users: UserLastSeen[], tournament: Tournament) {
540541
const player2 = player0 + j;
541542
const gameId = uuid();
542543
const gamePlayers: User[] = [];
543-
if ((i + j) % 2 === 1) {
544+
if ((i + j + randomStart) % 2 === 1) {
544545
gamePlayers.push(allGamePlayers[player1]);
545546
gamePlayers.push(allGamePlayers[player2]);
546547
} else {

0 commit comments

Comments
 (0)