Page 1 of 6

Posted: Fri Apr 13, 2007 2:15 pm
by Ksero
There have been several accounts of people being unable to join either side when autobalance is on. So I made a replication of the autobalance algorithm in Python, to experiment.
The most relevant parts:

Code: Select all

def GetRankThreshold(pilotSkills):
    """ See fedsrv/fsmission.cpp, line 1290
    """
    highest = max(pilotSkills)
    average = sum(pilotSkills) / len(pilotSkills)
    threshold = highest + (average * average) / (highest + average)
    return threshold

# note: teams is a global list of lists of integers, where the integers are pilot ranks
# eg. teams = [ [1,2], [10,15] ] means that there's two teams, one horribly stacked

def CheckPositionRequest(nPlayerRank, wantedteam, verbose = False):
    """ Called when a pilot wants to join a team. Returns False if join is blocked. See fedsrv/fsmission.cpp, line 4077
    wantedteam is an index for the teams-list
    """
    nRankThreshold = GetRankThreshold(concat(teams))
    teamskills = map(sum, teams)
    
    nRequestedSideRank = teamskills[wantedteam]
    nLowestTeamRank, nHighestTeamRank = min(teamskills), max(teamskills)

    nNewSideRank = nRequestedSideRank + nPlayerRank

    #Prevent joining a team if it will put it over the threshold
    if nNewSideRank - nLowestTeamRank > nRankThreshold:
    #fixed: if nNewSideRank - nLowestTeamRank > nRankThreshold and nRequestedSideRank != nLowestTeamRank:
        if verbose:
            print "joining team %d would unbalance sides Rank=%d, NewSideRank=%d, RequestedSideRank=%d, LowestTeamRank=%d, RankThreshold=%d" % \
                 (wantedteam, nPlayerRank,nNewSideRank,nRequestedSideRank,nLowestTeamRank,nRankThreshold)
        return False

    # Prevent joining a team if a newbie is trying to newbstack
    if nPlayerRank <= 8 and nRequestedSideRank == nLowestTeamRank:
    #fixed: if nPlayerRank <= 8 and nRequestedSideRank == nLowestTeamRank and not nLowestTeamRank == nHighestTeamRank: 
        nDifference = nHighestTeamRank - nRequestedSideRank
        if verbose:
            print "joining team %d blocked (newbstack) Rank=%d, Difference=%d, RequestedSideRank=%d, HighestTeamRank=%d, RankThreshold=%d" % \
                (wantedteam, nPlayerRank,nDifference,nRequestedSideRank,nHighestTeamRank,nRankThreshold)
        return False
    return True
If this little toy deviates from the actual implementation in a significant way, please tell me how. I've mostly used two teams, since that's the most common case when playing.

I have found a few different cases when pilots are unable to join any of the teams:A newbie tries to join when all teams have the same HELO scoreA pilot who has a higher rank than nRankThreshold tries to join (fix: always allow people to join the team with the lowest score)These cases are relatively easy to fix (see the #fixed: comments in the code). However, there's another more hairy case. Newbies who can't join one team for newbie-stacking, and can't join the other team for balance reasons. Example:
QUOTE No teams accepting! Pilot skill: 8. Threshold: 26
Teams:
Team 0: 20 pilots. Sum of skills: 223.
Team 1: 20 pilots. Sum of skills: 198.
Reasons:
joining team 0 would unbalance sides Rank=8, NewSideRank=231, RequestedSideRank=223, LowestTeamRank=198, RankThreshold=26
joining team 1 blocked (newbstack) Rank=8, Difference=25, RequestedSideRank=198, HighestTeamRank=223, RankThreshold=26

testcase: (8, [[6, 15, 7, 14, 12, 3, 9, 11, 3, 14, 13, 16, 11, 10, 1, 24, 10, 16, 17, 11], [6, 1, 12, 10, 1, 17, 1, 9, 12, 4, 23, 17, 6, 11, 12, 13, 13, 9, 9, 12]]),[/quote]
In this situation, where should we direct the (8)? I seem to remember that there has been proposals to always let newbies join the underdog team. And that seems to be how it works before launching the game...?
Or should the (8) join Team 0, to try and lessen the stack? And how can we detect that? Should we look at the average skill of the teams, and see if it moves towards balance or not (a bit of hand-waving there, I know...) ? Maybe we should just always let newbies join a "stacked" team?

Note: I didn't participate in the discussions during the design of the auto-balance systems. I apologize if I'm just beating a dead horse.

EDIT:
Another thing I find questionable is this line from CFSMission::GetRankThreshold

Code: Select all

    iAverageRank = iAverageRank / plistShip->n();
The function first loops over all ships in plistShip, checking for each ship if it's piloted. However here, when calculating the average, it divides by the number of ships, regardless of whether those ships were piloted or not. Though I'm not sure if this makes a big difference for the autobalance algorithm.

Posted: Fri Apr 13, 2007 2:44 pm
by Greator_SST
...not a dead horse at all. It's just a horse that is no longer allowed to see the light of day. Why is there a threshold value at all? Isn't the first solution to allow any and all to join the team that is down in points and not allow any joiners to the team that is up in points? Maybe the people who implemented this alteration could lay out the rationale whereby the team up in points is still allowed to add players?

Posted: Fri Apr 13, 2007 2:49 pm
by Pook
To answer Greator's questions - there should NOT be a threshold... I believe it was added in an attempt to appease certain "lobbyists".

Here's how autobalance should work, as posted from my post in the dev lounge:

It should actually be very simple... the next player to join must join the team with the lower ranksum. No thresholds and other such things. The only additional bit would be a "minimum" and "maximum" rank for the purposes of calculating the ranksum.

For example: if the minimum/maximum was 5/25, then anyone with a rank lower than 5 would be counted as 5 when doing the sum... and anyone higher than 25 would be treated as 25. If you want to be able to control the "number of players" imbalance level, you can simply adjust these min/max values.

For example: at a setting of 5/25, you can literally get 5 players to 1 if it were all vets vs all newbies. So, set it at 8/24 and the maximum imbalance is 3 to 1. 8/22 and the maximum imbalance is only 2 to 1.

That's it. Very simple, and no "Player can't join" bugs or deadlock conditions.

Here's an example of it in action.

The following players join in this order: 12,15,19,12,15,13,17,22,5,0,16,12,18

It would look like this:

Team A:12 (12)
Team B: (0)

Team A:12 (12)
Team B:15 (15)

Team A:12, 19 (31)
Team B:15 (15)

Team A:12, 19 (31)
Team B:15, 12 (27)

Team A:12, 19 (31)
Team B:15, 12, 15 (42)

Team A:12, 19, 13 (44)
Team B:15, 12, 15 (42)

Team A:12, 19, 13 (44)
Team B:15, 12, 15, 17 (59)

Team A:12, 19, 13, 22 (66)
Team B:15, 12, 15, 17 (59)

Team A:12, 19, 13, 22 (66)
Team B:15, 12, 15, 17, 5 (64)

Team A:12, 19, 13, 22, 0 (71) *Note here the 0 is counted as 5.
Team B:15, 12, 15, 17, 5 (64)

Team A:12, 19, 13, 22, 0 (71) *Note here the 0 is counted as 5.
Team B:15, 12, 15, 17, 5, 16 (80)

Team A:12, 19, 13, 22, 0, 12 (83) *Note here the 0 is counted as 5.
Team B:15, 12, 15, 17, 5, 16 (80)

Team A:12, 19, 13, 22, 0, 12 (83) *Note here the 0 is counted as 5.
Team B:15, 12, 15, 17, 5, 16, 18 (98)

The next player to join would go to Team A, and so forth.

Posted: Fri Apr 13, 2007 3:00 pm
by Ksero
I'm not sure I understand you, Pook... I don't see how that would limit the number-of-players imbalance. Take 5/25 as an example.
A (25) joins team A. Five (5)s join team B. Teams are even, from the balance-system's point of view. Another (25) joins team A. Another five (5)s join team B. Which brings the number-of-players imbalance to 2 - 10.

Posted: Fri Apr 13, 2007 3:07 pm
by ShadowFox_
What pook is saying is lets say you have a (1) newb... he counts as 5 points... which makes sense because he's still a warm body that can potentially do something. He's also saying if your a 28 you get counted as a 25... which makes sense... since while your rank may be increasing due to your immense stackage people generally in the 25 on up are topped at skill growth.

Posted: Fri Apr 13, 2007 3:30 pm
by Pook
Ksero wrote:QUOTE (Ksero @ Apr 13 2007, 10:00 AM) I'm not sure I understand you, Pook... I don't see how that would limit the number-of-players imbalance. Take 5/25 as an example.
A (25) joins team A. Five (5)s join team B. Teams are even, from the balance-system's point of view. Another (25) joins team A. Another five (5)s join team B. Which brings the number-of-players imbalance to 2 - 10.
Sorry Ksero, I meant to say "to 1" after those, I'll edit them real quick.

My Point is that you can control the "how many newbies a weedman is worth" type of scenario... If we wanted to include a limiter that also says that no matter what, the maximum total imbalance is 3, we can do that too. The problem there is... doing that puts you back into the situation where you can have players who cannot join a team.

For example:

Team A: 20
Team B: 0,0,0

So, a (18) comes along. He can't join A, because it's higher rated. He can't join B, because they're already up 3. That's why i think it's better to leave out such maximum imbalance values and just let the system work itself out. Let's face it, if all the vets sit in NOAT and wait to stack, it will get harder and harder as people join for them to get on the stacked team. (Assuming there is not an unlimited supply of newbies to build up the other side /mrgreen.gif" style="vertical-align:middle" emoid=":D" border="0" alt="mrgreen.gif" />). They'll end up sitting in the lobby.

In case I'm saying that poorly - if you have a lobby with 10 vets and 10 newbies... there's no way all the vets could stack against the newbies. If the ratio is managed at 3 to 1, the best you could do would be 10 newbies on one team and 3 vets on the other... and you're out of newbies. The remaining vets now have no choice but to join the newbie side... or I suppose wait for more newbies. /mrgreen.gif" style="vertical-align:middle" emoid=":D" border="0" alt="mrgreen.gif" />

Posted: Fri Apr 13, 2007 3:52 pm
by Ksero
That system would be way better than the current one!

The team skill sums in the game lobby (the numbers in brackets on the yellow and blue buttons) should reflect this adjusted number (ie. (0)'s should then count as 5 (or whatever the minimum is), so it's easy to see what the server thinks about the balance. Also, I don't think that there's a need to adjust the top players' skills downwards.

How about just starting all newbs as (2)'s ? As Shadow says, they're still a warm, living body... even (0)'s are of some use...

Posted: Fri Apr 13, 2007 4:01 pm
by Greator_SST
...completely agree, just let autobalance work regardless of player imbalance. Put together a comm modifer if you must since people say that that's a significant part of a team's success, but understand, that's gonna hurt a guy like aarm even more.

When I sign onto Allegiance, I want to play a game (two out of three times a futile exercise). I don't want to sit around for 20 minutes while stacks form and are flushed, comms log off in frustration over getting a team and everyone goes NOAT because there are better things to do with their time. I would have no problem double-clicking on a game server and being placed directly on a team with no other choice. If it's random, then at least I know I'll have the same amount of good players beside me as the other team. Sometimes I'll end up on the winning team, sometimes not, sometimes I'll have a good comm, sometimes not. And while something like autojoin is a question that we could all debate, I think that autobalance should be the only option in starting an Allegiance game.

Posted: Fri Apr 13, 2007 4:13 pm
by Rhapsody
I dont see any real need for minimim/maximum treshold. Use the KISS /wub.gif" style="vertical-align:middle" emoid=":iluv:" border="0" alt="wub.gif" />

Posted: Fri Apr 13, 2007 4:14 pm
by Ksero
Would be even better... Imagine, commanders might start to yell for (0)'s to come and stack their teams /mrgreen.gif" style="vertical-align:middle" emoid=":D" border="0" alt="mrgreen.gif" />