def _gameSetValues(self, game, acItem):
        seriesItem = self.treeGameExploring.GetItemParent(acItem)
        tournamentItem = self.treeGameExploring.GetItemParent(seriesItem)
        self.valTournament.SetLabel(
            self.treeGameExploring.GetItemText(tournamentItem))
        self.valSeries.SetLabel(self.treeGameExploring.GetItemText(seriesItem))
        self.valGame.SetLabel(self.treeGameExploring.GetItemText(acItem))
        self.valQTYGame.SetLabel("1")
        #fill measures single game
        self.lstMeasures.DeleteAllItems()
        self.txtOverallEvaluation.SetValue('')
        conn = dataBaseAdapter.getConnection()
        measures = self.treeGameExploring.GetItemData(
            acItem).retrieveMeasureList(conn)
        #fillLst
        overallValue = 0
        index = 0
        for m in measures:
            self.lstMeasures.InsertItem(index, str(m['measurecode']))
            self.lstMeasures.SetItem(index, 1, m['measuredescription'])
            self.lstMeasures.SetItem(index, 2, str(m['measureversion']))
            self.lstMeasures.SetItem(index, 3, str(m['measurevalue']))
            #byPath-2 uncertainty-3 leadChang-4
            if m['measurecode'] == 2 or \
                m['measurecode'] == 3 or \
                m['measurecode'] == 4:
                overallValue += m['measurevalue']
            index += 1
        #self._fillComboGraphType()
        #overall drama_by_path + uncertainty + lead_change over 3
        self.txtOverallEvaluation.SetValue(str(overallValue / 3))

        self._fillGraphPanel()
        dataBaseAdapter.closeConnection(conn)
def procDataLines(dataLine, contador, tamanho, l):
    #db.setValues('desafio_simples', 'mangeli', 'localhost', 'agoravai', 5432)
    conn = db.getConnection()

    tournament = model.Tournament(int(dataLine[5]), dataLine[2],
                                  int(dataLine[1]), dataLine[0])
    tournament.store(conn)

    player = model.Player(tournament, int(dataLine[8]), dataLine[14],
                          dataLine[13], dataLine[16])
    player.store(conn)

    series = model.Series(tournament, int(dataLine[6]), int(dataLine[3]))
    series.store(conn)

    game = model.Game(series, int(dataLine[7]))
    game.store(conn)

    enrollment = model.Enrollment(player, int(dataLine[7]), int(dataLine[6]),
                                  dataLine[20])
    enrollment.store(conn)

    gameRound = model.GameRound(game, int(dataLine[9]), int(dataLine[4]))
    gameRound.store(conn)

    roundResult = model.GameRoundResult(gameRound, enrollment, dataLine[18],
                                        dataLine[19], dataLine[11])
    roundResult.store(conn)

    with contador.get_lock():
        contador.value += 1
    l.acquire()
    #print str((contador.value / tamanho.value) * 100), " %", "                                \r",
    l.release()
    conn.close()
예제 #3
0
    def _setGameStruct(self):
        connection = dataBaseAdapter.getConnection()
        self._players = []
        self._gameData = []

        gameRounds = sorted(desafio_model.GameRound.retrieveList(
            self._game, connection),
                            key=lambda gameRound: gameRound.roundOrder)
        for gameRound in gameRounds:
            totalScores = sorted(desafio_model.GameRoundResult.retrieveList(
                gameRound, connection),
                                 key=lambda result: result.totalScore,
                                 reverse=True)
            scores = []
            for t in totalScores:
                scores.append(
                    ItemTuple(t.playerCode, t.roundScore, t.totalScore))
                if not t.playerCode in self._players:
                    self._players.append(t.playerCode)

            self._gameData.append((gameRound.roundOrder, scores))
        dataBaseAdapter.closeConnection(connection)
예제 #4
0
def storeUncertainty(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()
    #valLeadChange = LeadChange(game=game_aux, ignored=1).getMeasureValue()
    try:
        valUncertainty = UncertaintyPDD(game=game_aux, ignored=1,
                                        minScore=50).getMeasureValue()
    except:
        print('Error:', game.tournamentCode, ' ', game.seriesCode, ' ',
              game.groupCode)

    #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)
    game.storeMeasure(UncertaintyPDD(game=game_aux, ignored=1, minScore=50),
                      conn)
    dataBaseAdapter.closeConnection(conn)
    with counter.get_lock():
        counter.value += 1
    return valUncertainty  #(game, valPoints, valPosition, valPath)
예제 #5
0
'''
Created on 11/06/2015

@author: mangeli
'''
from __future__ import division
from GameQualityAssessment.code_pac.measures import DramaByPointsUp2First, DramaByPositionUp2First
from time import sleep
from multiprocessing import Value, Process, Pool
from GameQualityAssessment.code_pac.model import DesafioGame
import GameQualityAssessment.code_pac.dataBaseAdapter as dataBaseAdapter
from GameQualityAssessment.code_pac.desafio.model import Game, Tournament, Series

conn = dataBaseAdapter.getConnection()
jogos = []
for torneio in Tournament.retriveList(conn):
    for serie in Series.retrieveList(torneio, conn):
        for jogo in Game.retrieveList(serie, conn):
            jogos.append(jogo)
#print jogos[:]
for jogo in jogos:
    if not isinstance(jogo, Game):
        print ('merda')
    
    game_aux = DesafioGame(jogo)
    print ('i')
    valPoints = DramaByPointsUp2First(game_aux).getMeasureValue()
    jogo.storeMeasure(DramaByPointsUp2First(jogo), conn)
    def _fillLstMeasures(self, games):
        self.lstMeasures.DeleteAllItems()
        self.txtOverallEvaluation.SetValue('')
        if not type(games) == list:
            raise TypeError('First arg has to be a list of games')

        #get measures
        #fistMeasure
        connection = dataBaseAdapter.getConnection()
        if type(games) == list:
            measuresControl = self.treeGameExploring.GetItemData(
                games[0]).retrieveMeasureList(connection)
        nMeasures = len(measuresControl)

        # initializing measuresSum
        measuresValues = {}
        for m in measuresControl:
            #measuresValues.append(m['measurecode'])
            measuresValues[m['measurecode']] = []

        #sum values
        dlg = wx.ProgressDialog("Wait", "Loading Values...", len(games), self)
        pulseCount = 1
        for g in games:
            if pulseCount % 15 == 0:
                #dlg.UpdatePulse()
                dlg.Update(pulseCount)
            pulseCount += 1

            gMeasures = self.treeGameExploring.GetItemData(
                g).retrieveMeasureList(connection)
            if not len(gMeasures) == nMeasures:
                raise Exception('There is an error in measures stored.')
            for m in gMeasures:
                measuresValues[m['measurecode']].append(m['measurevalue'])

        #average
        measuresAvg = {}
        for m in measuresControl:
            #measuresAvg.append(m['measurecode'])
            measuresAvg[m['measurecode']] = sum(
                measuresValues[m['measurecode']]) / len(games)

        #fillLst
        index = 0
        for m in measuresControl:
            self.lstMeasures.InsertItem(index, str(m['measurecode']))
            self.lstMeasures.SetItem(index, 1, m['measuredescription'])
            self.lstMeasures.SetItem(index, 2, str(m['measureversion']))
            self.lstMeasures.SetItem(index, 3,
                                     str(measuresAvg[m['measurecode']]))
            index += 1

        #overall drama_by_path + uncertainty + lead_change over 3
        overallEvaluation = (measuresAvg[2] + measuresAvg[3] +
                             measuresAvg[4]) / 3

        self.txtOverallEvaluation.SetValue(str(overallEvaluation))

        dataBaseAdapter.closeConnection(connection)
        dlg.Destroy()
        self.treeGameExploring.SetFocus()
        self.valuesContainer = measuresValues
예제 #7
0
        preAdd={'game' : game}
        for m in dramaMeasures:
                if m.get('measuredescription') == 'Drama by points':
                    preAdd['dramapoints'] = m.get('measurevalue')
                
                elif m.get('measuredescription') == 'Drama by position':
                    preAdd['dramaposition'] = m.get('measurevalue')
    
                elif m.get('measuredescription') == 'Drama by paths':
                    preAdd['dramapaths'] = m.get('measurevalue')
        measures.append(preAdd)
    return measures
    
if __name__ == '__main__':
    #db.setValues('desafio_simples', 'mangeli', 'localhost', 'agoravai', 5432)
    conn = db.getConnection()
    dbCursor = db.getCursor(conn)
    
    #reading valid games
    print ("Reading valid games csv...")
    
    
    '''
    tournamentsCodes = set()    #set of tournamentcodes with valid games
    seriesCodes = set()         #set of series ([tournamentCode, seriesCode]) with valid games
    games =[]                   #list of all valid games
    detailedGames=[]            #list of all valid games and its drama measure values
    '''
       
    #retrieving drama information from db
    print ("Retrieving drama information from db...")