add autobalance to ingame lobby

Moderator: keyser

Re: add autobalance to ingame lobby

Postby thecore » 15 Nov 2019, 14:38

fa/lua/ui/lobby/trueskill.lua
Code: Select all
function computeQuality(team)
    local skillsMatrix = getPlayerCovarianceMatrix(team)
    local meanVector = getPlayerMeansVector(team)
    local meanVectorTranspose = meanVector:transpose()
    local playerTeamAssignmentsMatrix = createPlayerTeamAssignmentMatrix(team, meanVector.rowCount)
    local  playerTeamAssignmentsMatrixTranspose = playerTeamAssignmentsMatrix:transpose()
    local betaSquared = 250 * 250
    local start = matrixmult(meanVectorTranspose, playerTeamAssignmentsMatrix)
    local aTa = matrixmult(scalarMultiply(playerTeamAssignmentsMatrixTranspose, betaSquared), playerTeamAssignmentsMatrix)
    local tmp = matrixmult(playerTeamAssignmentsMatrixTranspose, skillsMatrix)
    local aTSA =  matrixmult(tmp, playerTeamAssignmentsMatrix)
    local middle = matrixAdd(aTa, aTSA)
    if middle:getDeterminant() == 0 then return -1 end
    local middleInverse = matrixInvert(middle)
    local theend = matrixmult(playerTeamAssignmentsMatrixTranspose, meanVector)
    local part1 = matrixmult(start, middleInverse)
    local part2 = matrixmult(part1, theend)
    local expPartMatrix = scalarMultiply(part2, -0.5)
    local expPart = expPartMatrix:getDeterminant()
    local sqrtPartNumerator = aTa:getDeterminant()
    local sqrtPartDenominator = middle:getDeterminant()
    local sqrtPart = sqrtPartNumerator / sqrtPartDenominator
    local result = math.exp(expPart) * math.sqrt(sqrtPart)
    return round((result * 100), 2)
end
thecore
Crusader
 
Posts: 18
Joined: 11 Dec 2018, 04:46
Has liked: 0 time
Been liked: 0 time
FAF User Name: thecore

Previous

Return to FAF Suggestions

Who is online

Users browsing this forum: No registered users and 0 guests