コード例 #1
0
ファイル: Tools.py プロジェクト: ebayol/dominion_datamining
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
コード例 #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
コード例 #3
0
ファイル: Tools.py プロジェクト: ebayol/dominion_datamining
def detect_bigmoney_strategy(match):
    """defines if one or more players in the match used the bigmoney strategy"""
    game = Match(match)
    is_big_money_flag = True
    for player in game.players:
        deck = player.deck
        for card in deck:
            if not (card in ("province", "gold", "silver", "duchy", "smithy")):
                is_big_money_flag = False
        if is_big_money_flag:
            player.strategy = "bigmoney"
    MongoInterface.update_log(game.ident, game.toDoc())
コード例 #4
0
def detect_bigmoney_strategy(match):
    """defines if one or more players in the match used the bigmoney strategy"""
    game = Match(match)
    is_big_money_flag = True
    for player in game.players:
        deck = player.deck
        for card in deck:
            if not (card in ("province", "gold", "silver", "duchy", "smithy")):
                is_big_money_flag = False
        if is_big_money_flag:
            player.strategy = "bigmoney"
    MongoInterface.update_log(game.ident, game.toDoc())