Verse Library verse

05 Defining The Algorithm

Calculates the difference between current and maximum team sizes to identify the team needing players.

extracted-snippets/documentation/en-us/uefn/triad-infiltration-3-balancing-teams-asymmetrically-in-verse/05-defining-the-algorithm.verse

# Source URL: https://dev.epicgames.com/documentation/en-us/uefn/triad-infiltration-3-balancing-teams-asymmetrically-in-verse
# Local doc:  epic-docs/documentation/en-us/uefn/triad-infiltration-3-balancing-teams-asymmetrically-in-verse.md
# Section:    Defining the Algorithm
 # Finds the team with the largest difference in their number of players from their
 # maximum number of players.
 FindTeamWithLargestDifference():?team =
     Logger.Print("Attempting to find smallest team")
     var TeamToAssign:?team = false
     var LargestDifference:int = 0
     for:
         CandidateTeam:Teams
         CurrentTeamSize := GetPlayspace().GetTeamCollection().GetAgents[CandidateTeam].Length
         MaximumTeamSize := TeamsAndTotals[CandidateTeam]
     do:
         Logger.Print("Checking a team...")
         Logger.Print("Maximum size Maximum size of team {CandidateTeamIndex + 1} is {MaximumTeamSize}")
         DifferenceFromMaximum := MaximumTeamSize - CurrentTeamSize
         Logger.Print("Difference from minimum is {DifferenceFromMaximum}")
         if(LargestDifference < DifferenceFromMaximum):
             set LargestDifference = DifferenceFromMaximum
             set TeamToAssign = option{CandidateTeam}
             Logger.Print("Found a team under minimum players: {DifferenceFromMaximum}")
     return TeamToAssign
Copy full snippet

Comments

    Sign in to vote, comment, or suggest an edit. Sign in