示例#1
0
	def calculateNewRatings(self, gameInfo, teams, teamRanks):
		'''Implementation for a 2 player game. returns a list of tuples of (player, newRating)'''
		argumentNotNone(gameInfo, "gameInfo")
		self._validateTeamCountAndPlayersCountPerTeam(teams)
		teams, teamRanks = sortByRank(teams, teamRanks)

		winningTeamPlayers = teams[0].asListOfTuples
		#since we know each team has one player, we know the player is the first one
		winningPlayer = winningTeamPlayers[0][0]
		winningPlayerOldRating = winningTeamPlayers[0][1]
		
		losingTeamPlayers = teams[1].asListOfTuples
		losingPlayer = losingTeamPlayers[0][0]
		losingPlayerOldRating = losingTeamPlayers[0][1]
		
		wasDraw = (teamRanks[0] == teamRanks[1])
		results = list()
		results.append(
			(winningPlayer, 
			self._calculateNewRating(
				gameInfo, winningPlayerOldRating, losingPlayerOldRating, PairwiseComparison.DRAW if wasDraw else PairwiseComparison.WIN)
		))
		results.append(
			(losingPlayer,
			self._calculateNewRating(
				gameInfo, losingPlayerOldRating, winningPlayerOldRating, PairwiseComparison.DRAW if wasDraw else PairwiseComparison.LOSE)
		))
		return results
示例#2
0
	def calculateNewRatings(self, gameInfo, teams, teamRanks):
		argumentNotNone(gameInfo, "gameInfo")
		self._validateTeamCountAndPlayersCountPerTeam(teams)
		teams, teamRanks = sortByRank(teams, teamRanks)
		
		factorGraph = TrueSkillFactorGraph(gameInfo, teams, teamRanks)
		factorGraph.buildGraph()
		factorGraph.runSchedule()	
		
		return factorGraph.getUpdatedRatings()
示例#3
0
	def calculateMatchQuality(self, gameInfo, teams):
		argumentNotNone(gameInfo, "gameInfo")
		self._validateTeamCountAndPlayersCountPerTeam(teams)
		player1Rating = teams[0].asListOfTuples[0][1]
		player2Rating = teams[1].asListOfTuples[0][1]
		betaSquared = (gameInfo.beta**2.0)
		player1SigmaSquared = (player1Rating.standardDeviation**2.0)
		player2SigmaSquared = (player2Rating.standardDeviation**2.0)
		sqrtPart = sqrt((2.0*betaSquared) / (2.0*betaSquared + player1SigmaSquared + player2SigmaSquared))
		expPart = e**((-1.0*((player1Rating.mean - player2Rating.mean)**2.0)) / (2.0*(2.0*betaSquared + player1SigmaSquared + player2SigmaSquared)))
		return sqrtPart*expPart
示例#4
0
	def calculateNewRatings(self, gameInfo, teams, teamRanks):
		'''Implementation for a 2 team game. Returns a list of tuples of (player, rating)'''
		argumentNotNone(gameInfo, "gameInfo")
		self._validateTeamCountAndPlayersCountPerTeam(teams)
		teams, teamRanks = sortByRank(teams, teamRanks)
		
		team1 = teams[0]
		team2 = teams[1]
		
		wasDraw = (teamRanks[0] == teamRanks[1])
		
		results = list()
		self._updatePlayerRatings(gameInfo, results, team1, team2, PairwiseComparison.DRAW if wasDraw else PairwiseComparison.WIN)
		self._updatePlayerRatings(gameInfo, results, team2, team1, PairwiseComparison.DRAW if wasDraw else PairwiseComparison.LOSE)
		return results
示例#5
0
	def calculateMatchQuality(self, gameInfo, teams):
		argumentNotNone(gameInfo, "gameInfo")
		self._validateTeamCountAndPlayersCountPerTeam(teams)
		
		team1 = teams[0]
		team2 = teams[1]
		
		totalPlayers = team1.size + team2.size
		betaSquared = gameInfo.beta**2.0
		
		team1MeanSum = team1.meanSum
		team1StdDevSum = team1.standardDeviationSquaredSum
		
		team2MeanSum = team2.meanSum
		team2StdDevSum = team2.standardDeviationSquaredSum
		
		sqrtPart = sqrt((totalPlayers*betaSquared) / (totalPlayers*betaSquared + team1StdDevSum + team2StdDevSum))
		expPart = e**((-1.0*(team1MeanSum - team2MeanSum)**2.0) / (2*(totalPlayers*betaSquared +team1StdDevSum + team2StdDevSum)))
		return sqrtPart * expPart