def checkThru(self): apostasFile = open(self.apostasFilename) nOfLines = 0; nDaAposta = 0 line = apostasFile.readline() self.nDePremios = {}; self.totalDePremios=0 while line: nOfLines += 1 if line[0]=='#': line = apostasFile.readline() continue #print random.randint(0,9), jogo = pprint.extractNumbersInANumberSpacedStrIntoANumberList(line) nDaAposta += 1 #print nDaAposta, 'Conferindo aposta:', jogo nDeCoincs = fCoincs.getNOfCoincidences(self.historyTargetJogo, jogo) if nDeCoincs in self.acertosComPremio: self.totalDePremios+=1 try: self.nDePremios[nDeCoincs] += 1 except KeyError: self.nDePremios[nDeCoincs] = 1 # below, print to screen last two premioTipos if nDeCoincs in self.acertosComPremio[-2:]: #print print self.totalDePremios,'/',nOfLines, 'nDeCoincs', nDeCoincs,'in', print pprint.numberListToStrCommaless(jogo) #, 'against history', self.historyTargetJogo, 'in nDoConcDaAposta', self.nDoConcDaAposta line = apostasFile.readline() #print self.checked = True
def writeJogosToFile(jogos, txtDataFilename): tam = len(jogos) fileOut = open(txtDataFilename,'a') nOfConcurso = 0 for jogo in jogos: line = pprint.numberListToStrCommaless(jogo) nOfConcurso += 1 print 'Writing conc.', nOfConcurso, '==>>', line line += '\n' fileOut.write(line) fileOut.close()
def seeSoma(): aListOfDicts = sa.getAttrs(['jogoCharOrig', 'soma']) nDoConc = 0 somaMin = 1000 somaMax = 0 somaDasSomas = 0 totalSobe = 0; totalDesce = 0; sobeDesceDepth = 0 somaList = []; sobeDesceList = [] for attrDict in aListOfDicts: attrs = attrDict.keys() # the SELECT is ORDERed BY nDoConc nDoConc += 1 print nDoConc, jogoCharOrig = attrDict['jogoCharOrig'] jogoObj = CLClasses.Jogo(jogoCharOrig, 'ms') jogo = jogoObj.jogo # jogoAsEntered print pprint.numberListToStrCommaless(jogo, 2), soma = attrDict['soma'] print soma, shouldBeSoma = sum(jogo) assert(soma == shouldBeSoma) somaDasSomas += soma somaList.append(soma) sobeDesce = 0 if nDoConc > 1: if soma > somaAnt: if sobeDesceAnt <> 1: sobeDesceDepth = 0 else: sobeDesceDepth += 1 sobeDesce = 1 totalSobe += 1 elif soma < somaAnt: if sobeDesceAnt <> -1: sobeDesceDepth = 0 else: sobeDesceDepth += 1 sobeDesce = -1 totalDesce += 1 sobeDesceAnt = sobeDesce sobeDesceList.append(sobeDesce) print sobeDesce, 'ts =', totalSobe, 'td =', totalDesce, 'depth', sobeDesceDepth, if soma > somaMax: somaMax = soma print 'MAX', if soma < somaMin: somaMin = soma print 'min', somaAnt = soma print print 'somaMax', somaMax print 'somaMin', somaMin mostMax = sum(range(55,61)) print 'mostMax', mostMax leastMin = sum(range(1,7)) print 'leastMin', leastMin avg = somaDasSomas / (nDoConc + 0.0) print 'avg', avg #matplotlib.plot(somaList) #print sobeDesceList sobeDesceDict = {} for sd in sobeDesceList: try: sobeDesceDict[sd] += 1 except KeyError: sobeDesceDict[sd] = 1 print sobeDesceDict
def pprintCommaless(self): return pprint.numberListToStrCommaless(self.jogo) # default zfill is 2