Ejemplo n.º 1
0
def generate_simplified_player(match):
    """generate a simplified player based on the match
    and save on the database"""
    game = Match(match)
    for player in game.players:
        splayer = SimplifiedPlayer({"name": player.playerName, "elo": 1000})
        splayer.save()
Ejemplo n.º 2
0
def elo_calculator(match):
    """generate the ELO of the match"""

    ELO_FACTOR = 32
    ELO_PONDERATION = 400

    game = Match(match)
    playersOldElo = {}
    eloPool = 0
    # collect the base data to calculate the elo
    for player in game.players:
        temp = MongoInterface.get_player(player.playerName).get("elo")
        playersOldElo[player.playerName] = temp
        eloPool += temp
    # calculate each players elo
    for player in game.players:

        splayer = SimplifiedPlayer(MongoInterface.get_player(player.playerName))

        oldElo = playersOldElo[player.playerName]

        if player.playerName in game.winners:
            newElo = oldElo + (
                (ELO_FACTOR * (1 - (math.pow(10, oldElo / ELO_PONDERATION) / eloPool))) / len(game.winners)
            )
        else:
            newElo = oldElo + ((ELO_FACTOR * (0 - (math.pow(10, oldElo / ELO_PONDERATION) / eloPool))))

        splayer.elo = newElo
        splayer.save()
        player.elo = newElo
    MongoInterface.update_log(game.ident, game.toDoc())
    return newElo
Ejemplo n.º 3
0
def elo_calculator(match):
    """generate the ELO of the match"""

    ELO_FACTOR = 32
    ELO_PONDERATION = 400

    game = Match(match)
    playersOldElo = {}
    eloPool = 0
    #collect the base data to calculate the elo
    for player in game.players:
        temp = MongoInterface.get_player(player.playerName).get('elo')
        playersOldElo[player.playerName] = temp
        eloPool += temp
    #calculate each players elo
    for player in game.players:

        splayer = SimplifiedPlayer(MongoInterface.get_player(
            player.playerName))

        oldElo = playersOldElo[player.playerName]

        if player.playerName in game.winners:
            newElo = oldElo + ((ELO_FACTOR * (1 - (math.pow(
                10, oldElo / ELO_PONDERATION) / eloPool))) / len(game.winners))
        else:
            newElo = oldElo + (
                (ELO_FACTOR *
                 (0 - (math.pow(10, oldElo / ELO_PONDERATION) / eloPool))))

        splayer.elo = newElo
        splayer.save()
        player.elo = newElo
    MongoInterface.update_log(game.ident, game.toDoc())
    return newElo
Ejemplo n.º 4
0
def generate_simplified_player(match):
    """generate a simplified player based on the match
    and save on the database"""
    game = Match(match)
    for player in game.players:
        splayer = SimplifiedPlayer({"name": player.playerName, "elo": 1000})
        splayer.save()