Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function TeamAssignment( Players , MMR , Option)
- #Option 1 does a swapping algorithm to balance teams
- #Option 2 does a fully random assignment
- #Option 3 does a quasi-random assignment based on player number
- if Option == 1
- iP = sortperm(MMR)
- nTeam1 = iP[[1,2,5,7,9]];
- nTeam2 = iP[[2,4,6,8,10]];
- m1 = mean( MMR[nTeam1] )
- m2 = mean( MMR[nTeam2] )
- d = m2-m1
- done = false
- while !done
- Team1 = nTeam1
- Team2 = nTeam2
- Md = abs.( (MMR[Team1] .- MMR[Team2]') + d )
- ind = vcat( ind2sub( Md , indmin( Md )) ... )
- nTeam1[ind[1]] = Team2[ind[2]]
- nTeam2[ind[2]] = Team1[ind[1]]
- d1 = mean( MMR[nTeam2] ) - mean( MMR[nTeam1] )
- if abs(d1) >= abs(d)
- done = true
- end
- d = d1
- end
- Team1 = Players[Team1]
- Team2 = Players[Team2]
- elseif Option == 2
- Players = MMR_Sort( Players, rand(10) );
- Team1 = Players[1:5];
- Team2 = Players[6:10];
- elseif Option == 3
- Players = sort(Players);
- Team1 = Players[1:5];
- Team2 = Players[6:10];
- end
- return Team1 , Team2
- end
- function MMR_Sort(Players,MMR)
- Ind = sortperm(MMR);
- return Players[Ind];
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement