Skip to content

Commit

Permalink
Improved shuffle
Browse files Browse the repository at this point in the history
  • Loading branch information
jensborch committed Feb 26, 2023
1 parent 07fef2a commit faebbdc
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions persistence/tournament.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,12 +224,16 @@ func (r *tournamentRepository) ShuffleActivePlayersOld(tournamentId string) ([]*

func (r *tournamentRepository) ShuffleActivePlayers(tournamentId string) ([]*model.TournamentPlayer, model.Found) {
if players, found := r.ActivePlayers(tournamentId); found {
shuffles := [5][]*model.TournamentPlayer{}
for i := 0; i < 5; i++ {
const numberOfShuffles = 10
shuffles := [numberOfShuffles][]*model.TournamentPlayer{}
for i := 0; i < numberOfShuffles; i++ {
shuffles[i] = shufflePlayers(players)
}
previous := r.previousGames(tournamentId)
matches := make([]int, 5)
if len(previous) > len(players)/2 {
previous = previous[0 : len(players)/2]
}
matches := make([]int, numberOfShuffles)
for i, shuffle := range shuffles {
matches[i] = comparPairs(playerPairs(shuffle), previous)
}
Expand Down

0 comments on commit faebbdc

Please sign in to comment.