def _fillExploring(self):
        root = self.treeGameExploring.AddRoot('Tournaments')
        conn = db.getConnection()
        tournaments = Tournament.retriveList(conn)
        #tList = []
        for t in tournaments:
            tVal = t.country.strip() + " - " + str(
                t.refYear) + " - " + "(code: " + str(t.tournamentCode) + ")"
            node = self.treeGameExploring.AppendItem(parent=root,
                                                     text=tVal,
                                                     data=t)
            series = sorted(Series.retrieveList(t, conn),
                            key=lambda series: series.seriesOrder)
            #sList=[]
            for s in series:
                sVal = str(s.seriesOrder) + " - " + str(s.seriesCode)
                node2 = self.treeGameExploring.AppendItem(node, sVal, data=s)
                games = Game.retrieveList(s, conn)
                i = 0
                for g in games:
                    gVal = str(i) + " - " + str(g.groupCode)
                    self.treeGameExploring.AppendItem(node2, gVal, data=g)
                    i += 1

        db.closeConnection(conn)
Exemple #2
0
def getValidGames(seriesInput, arq):
    games = []
    for linha in arq:
        if not arq.line_num == 1 and \
           int(linha[1]) == seriesInput.seriesCode and \
           int(linha[0]) == seriesInput.tournamentCode: #ignores first line and series other than seriesInput
           
            tournament = Tournament.retrieve(linha[0], conn)
            series = Series.retrieve(tournament, linha[1], conn)
            groupCode = linha[2]
            game = Game(series, groupCode)
            games.append(game)
    return games
'''
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)
    "dbname=desafio_sebrae user=mangeli host=localhost password=agoravai")

#recupera lista de torneios
torneios = Tournament.retriveList(conn)

#recupera o codigo do primeiro torneio da lista
codigoTorneio = torneios[0].tournamentCode

# monta um torneio com o codigo anterior
# ATENÇÃO: desnecessário, esse é um exemplo de demonstação. O primeiro item da lista anterior já um objeto com esses valores
torneio = Tournament.retrieve(codigoTorneio, conn)

# dados de um torneio
playerList = Player.retriveList(torneio, conn)

seriesList = Series.retrieveList(torneio, conn)

series = seriesList[0]

#playerGroupList = PlayerGroup.retrieveList(torneio, conn)
playerGroupList = []

gameList = Game.retrieveList(series, conn)

game = gameList[0]

gameRoundList = GameRound.retrieveList(game, conn)

enrollmentList = Enrollment.retrieveList(playerGroupList[1], conn)

roundResultList = GameRoundResult.retrieveList(gameRoundList[0], conn)
Exemple #5
0
 
 
 '''
 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...")
 targets = [(123,272), (123,264), (160,296), (160,303), (166,313), (166,324), (127,281), (127,291)]
 for target in targets:
     arq = csv.reader(open(abspath("data/desafio/raw_data/valid_games.csv"), "r"), delimiter=";")
     t = Tournament.retrieve(target[0], conn)
     games = getValidGames(Series.retrieve(t, target[1], conn), arq)
     values = getMeasureValues(games)
     plotHist(values)
 plt.show()
 '''for linha in arq:
     if (not arq.line_num == 1): #ignores first line
         tournamentsCodes.add(linha[0])
         seriesCodes.add((linha[0], linha[1]))
         
         tournament = Tournament.retrieve(linha[0], conn)
         series = Series.retrieve(tournament, linha[1], conn)
         groupCode = linha[2]
         game = Game(series, groupCode)
         
         games.append(game)
         
'''

import psycopg2

import matplotlib.pyplot as plt
from GameQualityAssessment.code_pac.desafio.model import Tournament, Series, Game, GameRound, GameRoundResult, Enrollment
import numpy as np

conn = psycopg2.connect(
    "dbname=desafio_sebrae user=mangeli host=localhost password=agoravai")

#de um torneio
torneio = Tournament.retriveList(conn)[0]

#de uma fase
fase = Series.retrieveList(torneio, conn)[1]

#de um jogo
jogo = Game.retrieveList(fase, conn)[0]
'''monta os resultados do jogo'''
jogoObjeto = []
jogadores = []
pontos = []
#rodadas
rodadas = sorted(GameRound.retrieveList(jogo, conn),
                 key=lambda rodada: rodada.roundNumber)

for rodada in rodadas:
    #resultados da rodada ordenados
    resultados = sorted(GameRoundResult.retrieveList(rodada, conn),
                        key=lambda resultado: resultado.totalScore,