Hm actually I don't need to convert trueskill entirely, just the part that compute game balance, and that doesn't requires the factor graph, so it can be quickly done..
If someone want to know what is precisely needed, it's all the functions used here :
- Code: Select all
def calculateMatchQuality(self, gameInfo, teams) :
# // We need to create the A matrix which is the player team assigments.
teamAssignmentsList = teams
skillsMatrix = self.getPlayerCovarianceMatrix(teamAssignmentsList)
meanVector = self.getPlayerMeansVector(teamAssignmentsList)
meanVectorTranspose = meanVector.getTranspose()
playerTeamAssignmentsMatrix = self.createPlayerTeamAssignmentMatrix(teamAssignmentsList, meanVector.getRowCount())
playerTeamAssignmentsMatrixTranspose = playerTeamAssignmentsMatrix.getTranspose()
betaSquared = square(gameInfo.getBeta())
start = Matrix.multiply(meanVectorTranspose, playerTeamAssignmentsMatrix)
aTa = Matrix.multiply(Matrix.scalarMultiply(betaSquared,
playerTeamAssignmentsMatrixTranspose),
playerTeamAssignmentsMatrix)
aTSA = Matrix.multiply(
Matrix.multiply(playerTeamAssignmentsMatrixTranspose, skillsMatrix),
playerTeamAssignmentsMatrix)
middle = Matrix.add(aTa, aTSA)
middleInverse = middle.getInverse()
end = Matrix.multiply(playerTeamAssignmentsMatrixTranspose, meanVector)
expPartMatrix = Matrix.scalarMultiply(-0.5, (Matrix.multiply(Matrix.multiply(start, middleInverse), end)))
expPart = expPartMatrix.getDeterminant()
sqrtPartNumerator = aTa.getDeterminant()
sqrtPartDenominator = middle.getDeterminant()
sqrtPart = sqrtPartNumerator / sqrtPartDenominator
result = exp(expPart) * sqrt(sqrtPart)
return result
So, basically, coding some matrices functions in lua.