def _calculateNewRating(self, gameInfo, selfRating, opponentRating, comparison):
		drawMargin = getDrawMarginFromDrawProbability(gameInfo.drawProbability, gameInfo.beta)
		c = sqrt((selfRating.standardDeviation**2.0) + (opponentRating.standardDeviation**2.0) + 2.0*(gameInfo.beta**2.0))
		winningMean = selfRating.mean
		losingMean = opponentRating.mean
		if comparison == PairwiseComparison.LOSE:
			winningMean = opponentRating.mean
			losingMean = selfRating.mean
		meanDelta = winningMean - losingMean
		v = None
		w = None
		rankMultiplier = None
		if comparison != PairwiseComparison.DRAW:
			v = vExceedsMargin(meanDelta, drawMargin, c)
			w = wExceedsMargin(meanDelta, drawMargin, c)
			rankMultiplier = comparison
		else:
			v = vWithinMargin(meanDelta, drawMargin, c)
			w = wWithinMargin(meanDelta, drawMargin, c)
			rankMultiplier = 1.0
		meanMultiplier = ((selfRating.standardDeviation**2.0) + (gameInfo.dynamicsFactor**2.0)) / c
		varianceWithDynamics = (selfRating.standardDeviation**2) + (gameInfo.dynamicsFactor**2)
		stdDevMultiplier = varianceWithDynamics/(c**2.0)
		newMean = selfRating.mean + (rankMultiplier*meanMultiplier*v)
		newStdDev = sqrt(varianceWithDynamics*(1 - w*stdDevMultiplier))
		return Rating(newMean, newStdDev)
	def _updatePlayerRatings(self, gameInfo, newPlayerRatings, selfTeam, otherTeam, selfToOtherComparison):
		drawMargin = getDrawMarginFromDrawProbability(gameInfo.drawProbability, gameInfo.beta)
		betaSquared = gameInfo.beta**2.0
		tauSquared = gameInfo.dynamicsFactor**2.0

		totalPlayers = selfTeam.size + otherTeam.size
		
		selfTeamMeanSum = selfTeam.meanSum
		otherTeamMeanSum = otherTeam.meanSum
		selfTeamStandardDeviationSum = selfTeam.standardDeviationSquaredSum
		otherTeamStandardDeviationSum = otherTeam.standardDeviationSquaredSum
		
		c = sqrt(selfTeamStandardDeviationSum + otherTeamStandardDeviationSum + totalPlayers*betaSquared)
		winningMean = selfTeamMeanSum
		losingMean = otherTeamMeanSum
		if selfToOtherComparison == PairwiseComparison.LOSE:
			winningMean = otherTeamMeanSum
			losingMean = selfTeamMeanSum
		meanDelta = winningMean - losingMean
		
		v = None
		w = None
		rankMultiplier = None
		if selfToOtherComparison != PairwiseComparison.DRAW:
			v = vExceedsMargin(meanDelta, drawMargin, c)
			w = wExceedsMargin(meanDelta, drawMargin, c)
			rankMultiplier = selfToOtherComparison
		else:
			v = vWithinMargin(meanDelta, drawMargin, c)
			w = wWithinMargin(meanDelta, drawMargin, c)
			rankMultiplier = 1
		
		for playerTuple in selfTeam.asListOfTuples:
			previousPlayerRating = playerTuple[1]
			meanMultiplier = ((previousPlayerRating.standardDeviation**2.0) + tauSquared) / c
			stdDevMultiplier = ((previousPlayerRating.standardDeviation**2.0) + tauSquared) / (c**2.0)
			playerMeanDelta = rankMultiplier*meanMultiplier*v
			newMean = previousPlayerRating.mean + playerMeanDelta
			newStdDev = sqrt(((previousPlayerRating.standardDeviation**2.0) + tauSquared) * (1 - w*stdDevMultiplier))
			newPlayerRatings.append((playerTuple[0], Rating(newMean, newStdDev)))
Exemple #3
0
	def __init__(self, parentGraph, teamRanks):
		super(TeamDifferencesComparisonLayer, self).__init__(parentGraph)
		self._teamRanks = teamRanks
		self._epsilon = getDrawMarginFromDrawProbability(parentGraph.gameInfo.drawProbability, parentGraph.gameInfo.beta)