Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define TEAMS_ALREADY_BALANCED print("balanceTeam: Teams are already balanced.");
- #define TEAMS_NOW_BALANCED print("balanceTeam: Teams successfully balanced.");
- teamBalance() {
- new t_1 = Iter_Count(team_1), t_2 = Iter_Count(team_2), diff = t_1 - t_2;
- if(diff == 1 || diff == -1 || diff == 0) return TEAMS_ALREADY_BALANCED;
- else if(diff > 0) {
- do {
- new remove = Iter_Random(t_1);
- Iter_Add(t_2, remove);
- Iter_Remove(t_1, remove);
- diff--;
- } while(diff > 0);
- } else {
- do {
- new remove = Iter_Random(t_2);
- Iter_Add(t_1, remove);
- Iter_Remove(t_2, remove);
- diff--;
- } while(diff > 0);
- }
- return TEAMS_NOW_BALANCED;
- }
Advertisement
Add Comment
Please, Sign In to add comment