def dramaAnalizerLocal(game):
    conn = dataBaseAdapter.getConnection()
    game_aux = DesafioGame(game)

    #valPoints = DramaByPointsUp2First(game=game_aux, ignored=1).getMeasureValue()
    #valPosition = DramaByPositionUp2First(game=game_aux, ignored=1).setIgnored(1).getMeasureValue()
    valPath = DramaByPaths(game=game_aux, ignored=1).getMeasureValue()
    game.storeMeasure(DramaByPointsUp2First(game=game_aux, ignored=1), conn)
    game.storeMeasure(DramaByPositionUp2First(game=game_aux, ignored=1), conn)
    game.storeMeasure(DramaByPaths(game=game_aux, ignored=1), conn)
    dataBaseAdapter.closeConnection(conn)
    with counter.get_lock():
        counter.value += 1
    return valPath  #(game, valPoints, valPosition, valPath)

if __name__ == "__main__":
    from GameQualityAssessment.code_pac.measures import DramaByPaths, DramaByPositionUp2First, DramaByPointsUp2First
    from GameQualityAssessment.code_pac.gamePlots import GamePlots
    import matplotlib.pyplot as plt
    import numpy as np

    the_list = ESmodel.Game.retrieveList()
    values = []
    for game in the_list:
        g = LaLigaGame(game)
        values.append([
            DramaByPaths(game=g, ignored=0).getMeasureValue(),
            DramaByPointsUp2First(game=g, ignored=0).getMeasureValue(),
            DramaByPositionUp2First(game=g, ignored=0).getMeasureValue()
        ])
    print(values[:])
    print(np.transpose(values))
    #p = GamePlots(game)
    #p.byPosition(ignored=0)
    plt.figure()
    plt.hist(np.transpose(values).reshape((len(values), 3)),
             normed=False,
             bins=5,
             range=[0, 1],
             color=['red', 'green', 'blue'],
             label=['Path', 'Points', 'Position'])
    plt.legend()
    plt.show()
import numpy as np
from openpyxl import Workbook
from GameQualityAssessment.project_path import make_absolute_path as abspath
from GameQualityAssessment.code_pac.measures import DramaByPaths, DramaByPositionUp2First, DramaByPointsUp2First

if __name__ == '__main__':
    wb = Workbook()
    planilha = wb.active
    planilha.append(['ano','Drama by Path', 'Drama by Points', 'Drama by position'])
    games = Game.retrieveList()
    for game in games:
        genGame = BrasileiroGame(game)
        
        dramaPath = DramaByPaths(game=genGame, ignored=0).getMeasureValue() 
        dramaPoints = DramaByPointsUp2First(game=genGame, ignored=0, normScores=True).getMeasureValue()
        dramaPosition = DramaByPositionUp2First(game=genGame, ignored=0).getMeasureValue()
        planilha.append([game.year, dramaPath, dramaPoints, dramaPosition])
        
        
        winner = genGame.getWinner()
        nPlayers = len(genGame.getPlayers())
        nRounds = genGame.getNumberRounds()
        winnerPath = []
        for i in range(1, nRounds + 1):
            gameRound = genGame.getRound(i)[1]
            for r in gameRound:
                if r.playerCode == winner:
                    winnerPath.append(gameRound.index(r)+1)
                    break
        plt.figure(game.year)
        plt.plot(np.arange(1,nRounds+1), winnerPath, '-b', linewidth=1.5)
示例#4
0
def calculaDramaPorPosicao(game):
    obj = model.DiceGame(game)
    value = DramaByPositionUp2First(game=obj, ignored=0)
    return value.getMeasureValue()