def cambiarUno(self, recno, nuevoPGN, pvNue, dicS_PGN): siNuevo = recno is None resNue = dicS_PGN.get("Result", "*") br = self.dbf.baseRegistro() br.XPV = pv2xpv(pvNue) br.FEN = dicS_PGN["FEN"] br.EVENT = dicS_PGN.get("Event", "") br.SITE = dicS_PGN.get("Site", "") br.DATE = dicS_PGN.get("Date", "") br.WHITE = dicS_PGN.get("White", "") br.BLACK = dicS_PGN.get("Black", "") br.RESULT = resNue br.PLIES = "%3d" % (pvNue.strip().count(" ") + 1, ) br.PGN = Util.var2blob(nuevoPGN) siRepetido = False if siNuevo: try: self.dbf.insertar(br, okCommit=True, okCursorClose=True) self.xReccountTotal += 1 except: siRepetido = True else: try: self.dbf.modificarReg(recno, br) except: siRepetido = True return not siRepetido
def cambiarUno(self, recno, nuevoPGN, pvNue, dicS_PGN): siNuevo = recno is None resNue = dicS_PGN.get("Result", "*") br = self.dbf.baseRegistro() br.XPV = pv2xpv(pvNue) br.FEN = dicS_PGN["FEN"] br.EVENT = dicS_PGN.get("Event", "") br.SITE = dicS_PGN.get("Site", "") br.DATE = dicS_PGN.get("Date", "") br.WHITE = dicS_PGN.get("White", "") br.BLACK = dicS_PGN.get("Black", "") br.RESULT = resNue br.PLIES = "%3d" % (pvNue.strip().count(" ") + 1,) br.PGN = Util.var2blob(nuevoPGN) siRepetido = False if siNuevo: try: self.dbf.insertar(br, okCommit=True, okCursorClose=True) self.xReccountTotal += 1 except: siRepetido = True else: try: self.dbf.modificarReg(recno, br) except: siRepetido = True return not siRepetido
def mejor(work, pvPrevio, depth, cp): if depth > maxDepth: return if work.games() >= minGames: liChildren = work.children() if not liChildren: return mv = liChildren[0] mx = mv.gamesParcial(siWhite, siDraw) li = [] for uno in liChildren: unomx = uno.gamesParcial(siWhite, siDraw) if unomx > mx: mx = unomx li = [uno] elif unomx == mx: li.append(uno) for uno in li: wm = uno.move pv = (pvPrevio + " " + uno.move).strip() if pv != "a1a1": cpN = cp.copia() cpN.moverPV(wm) f.write("%s|%s|%s\n" % (pv2xpv(pv), wm, cpN.fen())) todos(uno, pv, depth + 1, cpN)
def mejor(work, pvPrevio, depth, cp): if depth > maxDepth: return if work.games() >= minGames: liChildren = work.children() if not liChildren: return mv = liChildren[0] mx = mv.gamesParcial(siWhite, siDraw) li = [] for uno in liChildren: unomx = uno.gamesParcial(siWhite, siDraw) if unomx > mx: mx = unomx li = [uno] elif unomx == mx: li.append(uno) for uno in li: wm = uno.move pv = (pvPrevio + " " + uno.move).strip() if pv != "a1a1": cpN = cp.copia() cpN.moverPV(wm) f.write("%s|%s|%s\n" % (pv2xpv(pv), wm, cpN.fen() )) todos(uno, pv, depth + 1, cpN)
def masMaderaUno(self, dic, partida, xblancas, xnegras, tpResult): pk = "" for jg in partida.liJugadas: pk += jg.movimiento() + " " event = dic.get("Event", "-") oponente = dic["White"] + "-" + dic["Black"] date = dic.get("Date", "-").replace("?", "").strip(".") eco = dic.get("Eco", "-") result = dic.get("Result", "-") color = "W" if xblancas else "B" if tpResult: siEmpate = "2" in result siGanaBlancas = not siEmpate and result.startswith("1") siGanaNegras = not siEmpate and result.startswith("0") if tpResult == 1: if not ((xblancas and siGanaBlancas) or (xnegras and siGanaNegras)): return else: if not (siEmpate or (xblancas and siGanaBlancas) or (xnegras and siGanaNegras)): return self.write( "%s|%s|%s|%s|%s|%s|%s\n" % (pv2xpv(pk.strip()), event, oponente, date, eco, result, color))
def filterPV(self, pv, condicionAdicional=None): xpv = pv2xpv(pv) condicion = 'XPV LIKE "%s%%"' % xpv if xpv else "" if self.dbSTATplayer and self.dbSTAT == self.dbSTATplayer: playerBusq, siSta, siEnd, playerORI = self.player playerORI = playerORI.upper().strip().replace("*", "%") if siSta or siEnd: condicionAdicional = 'upper(WHITE) like "%s" or upper(BLACK) like "%s"' % (playerORI, playerORI) else: condicionAdicional = 'upper(WHITE) == "%s" or upper(BLACK) == "%s"' % (playerORI, playerORI) if condicionAdicional: if condicion: condicion += " AND (%s)" % condicionAdicional else: condicion = condicionAdicional self.dbf.ponCondicion(condicion) self.dbf.leerBuffer(segundos=self.segundosBuffer) self.dbf.gotop()
def todos(work, pvPrevio, depth, cp): if depth > maxDepth: return if work.games() >= minGames: liChildren = work.children() if not liChildren: return for uno in liChildren: if uno.games() >= minGames: wm = uno.move pv = (pvPrevio + " " + uno.move).strip() if pv != "a1a1": cpN = cp.copia() cpN.moverPV(wm) f.write("%s|%s|%s\n" % (pv2xpv(pv), wm, cpN.fen())) fm2 = cpN.fenM2() if fm2 not in stFenM2: # Para que no se repitan los movimientos de los transpositions stFenM2.add(fm2) mejor(uno, pv, depth + 1, cpN)
def todos(work, pvPrevio, depth, cp): if depth > maxDepth: return if work.games() >= minGames: liChildren = work.children() if not liChildren: return for uno in liChildren: if uno.games() >= minGames: wm = uno.move pv = (pvPrevio + " " + uno.move).strip() if pv != "a1a1": cpN = cp.copia() cpN.moverPV(wm) f.write("%s|%s|%s\n" % (pv2xpv(pv), wm, cpN.fen() )) fm2 = cpN.fenM2() if fm2 not in stFenM2: # Para que no se repitan los movimientos de los transpositions stFenM2.add(fm2) mejor(uno, pv, depth + 1, cpN)
def append(self, pv, event, site, date, white, black, result, fen, pgn, okCommit): br = self.dbf.baseRegistro() br.XPV = pv2xpv(pv) br.FEN = fen br.EVENT = event br.SITE = site br.DATE = date br.WHITE = white br.BLACK = black br.RESULT = result br.PGN = Util.var2blob(pgn) br.PLIES = "%3d" % (pv.strip().count(" ") + 1,) siRepetido = False try: self.dbf.insertar(br, okCommit=okCommit, okCursorClose=okCommit) self.xReccountTotal += 1 except: siRepetido = True return not siRepetido
def inicia(): cp = ControlPosicion.ControlPosicion() cp.posInicial() work = self.root pvActual = "" for pv in pvBase.split(" "): cp.moverPV(pv) pvActual += " " + pv f.write("%s|%s|%s\n" % (pv2xpv(pvActual.strip()), pv, cp.fen() )) liChildren = work.children() work = None for uno in liChildren: if uno.move == pv: work = uno break if work is None: work = self.root break return cp, work
def inicia(): cp = ControlPosicion.ControlPosicion() cp.posInicial() work = self.root pvActual = "" for pv in pvBase.split(" "): cp.moverPV(pv) pvActual += " " + pv f.write("%s|%s|%s\n" % (pv2xpv(pvActual.strip()), pv, cp.fen())) liChildren = work.children() work = None for uno in liChildren: if uno.move == pv: work = uno break if work is None: work = self.root break return cp, work
def append(self, pv, event, site, date, white, black, result, fen, pgn, okCommit): br = self.dbf.baseRegistro() br.XPV = pv2xpv(pv) br.FEN = fen br.EVENT = event br.SITE = site br.DATE = date br.WHITE = white br.BLACK = black br.RESULT = result br.PGN = Util.var2blob(pgn) br.PLIES = "%3d" % (pv.strip().count(" ") + 1, ) siRepetido = False try: self.dbf.insertar(br, okCommit=okCommit, okCursorClose=okCommit) self.xReccountTotal += 1 except: siRepetido = True return not siRepetido
def filterPV(self, pv, condicionAdicional=None): xpv = pv2xpv(pv) condicion = 'XPV LIKE "%s%%"' % xpv if xpv else "" if self.dbSTATplayer and self.dbSTAT == self.dbSTATplayer: playerBusq, siSta, siEnd, playerORI = self.player playerORI = playerORI.upper().strip().replace("*", "%") if siSta or siEnd: condicionAdicional = 'upper(WHITE) like "%s" or upper(BLACK) like "%s"' % ( playerORI, playerORI) else: condicionAdicional = 'upper(WHITE) == "%s" or upper(BLACK) == "%s"' % ( playerORI, playerORI) if condicionAdicional: if condicion: condicion += " AND (%s)" % condicionAdicional else: condicion = condicionAdicional self.dbf.ponCondicion(condicion) self.dbf.leerBuffer(segundos=self.segundosBuffer) self.dbf.gotop()
def cambiarUno(self, recno, nuevoPGN, pvNue, dicS_PGN): siNuevo = recno is None if not siNuevo: self.dbf.goto(recno) reg = self.dbf.reg pvAnt = xpv2pv(reg.XPV) resAnt = reg.RESULT resNue = dicS_PGN.get("Result", "*") br = self.dbf.baseRegistro() br.XPV = pv2xpv(pvNue) br.EVENT = dicS_PGN.get("Event", "") br.SITE = dicS_PGN.get("Site", "") br.DATE = dicS_PGN.get("Date", "") br.WHITE = dicS_PGN.get("White", "") br.BLACK = dicS_PGN.get("Black", "") br.RESULT = resNue br.PLIES = "%3d" % (pvNue.strip().count(" ") + 1,) br.ECO = dicS_PGN.get("ECO", "") br.WHITEELO = dicS_PGN.get("WhiteElo", "") br.BLACKELO = dicS_PGN.get("BlackElo", "") br.PGN = Util.var2blob(nuevoPGN) siRepetido = False if siNuevo: try: self.dbf.insertar(br, okCommit=True, okCursorClose=True) self.appendSTAT(pvNue, resNue, +1, br.WHITE, br.BLACK) except: siRepetido = True else: try: self.dbf.modificarReg(recno, br) if pvAnt != pvNue or resAnt != resNue: self.appendSTAT(pvAnt, resAnt, -1, reg.WHITE, reg.BLACK) self.appendSTAT(pvNue, resNue, +1, br.WHITE, br.BLACK) except: siRepetido = True return not siRepetido
def cambiarUno(self, recno, nuevoPGN, pvNue, dicS_PGN): siNuevo = recno is None if not siNuevo: self.dbf.goto(recno) reg = self.dbf.reg pvAnt = xpv2pv(reg.XPV) resAnt = reg.RESULT resNue = dicS_PGN.get("Result", "*") br = self.dbf.baseRegistro() br.XPV = pv2xpv(pvNue) br.EVENT = dicS_PGN.get("Event", "") br.SITE = dicS_PGN.get("Site", "") br.DATE = dicS_PGN.get("Date", "") br.WHITE = dicS_PGN.get("White", "") br.BLACK = dicS_PGN.get("Black", "") br.RESULT = resNue br.PLIES = "%3d" % (pvNue.strip().count(" ") + 1, ) br.ECO = dicS_PGN.get("ECO", "") br.WHITEELO = dicS_PGN.get("WhiteElo", "") br.BLACKELO = dicS_PGN.get("BlackElo", "") br.PGN = Util.var2blob(nuevoPGN) siRepetido = False if siNuevo: try: self.dbf.insertar(br, okCommit=True, okCursorClose=True) self.appendSTAT(pvNue, resNue, +1, br.WHITE, br.BLACK) except: siRepetido = True else: try: self.dbf.modificarReg(recno, br) if pvAnt != pvNue or resAnt != resNue: self.appendSTAT(pvAnt, resAnt, -1, reg.WHITE, reg.BLACK) self.appendSTAT(pvNue, resNue, +1, br.WHITE, br.BLACK) except: siRepetido = True return not siRepetido
def append(self, pv, event, site, date, white, black, result, eco, whiteelo, blackelo, pgn, okCommit): br = self.dbf.baseRegistro() br.XPV = pv2xpv(pv) br.EVENT = event br.SITE = site br.DATE = date br.WHITE = white br.BLACK = black br.RESULT = result br.PLIES = "%3d" % (pv.strip().count(" ") + 1,) br.ECO = eco br.WHITEELO = whiteelo br.BLACKELO = blackelo br.PGN = Util.var2blob(pgn) siRepetido = False try: self.dbf.insertar(br, okCommit=okCommit, okCursorClose=okCommit) self.appendSTAT(pv, result, +1, white, black) except: siRepetido = True return not siRepetido
def masMaderaUno(self, dic, partida, xblancas, xnegras, tpResult): pk = "" for jg in partida.liJugadas: pk += jg.movimiento() + " " event = dic.get("Event", "-") oponente = dic["White"] + "-" + dic["Black"] date = dic.get("Date", "-").replace("?", "").strip(".") eco = dic.get("Eco", "-") result = dic.get("Result", "-") color = "W" if xblancas else "B" if tpResult: siEmpate = "2" in result siGanaBlancas = not siEmpate and result.startswith("1") siGanaNegras = not siEmpate and result.startswith("0") if tpResult == 1: if not ((xblancas and siGanaBlancas) or (xnegras and siGanaNegras) ): return else: if not ( siEmpate or (xblancas and siGanaBlancas) or (xnegras and siGanaNegras) ): return self.write("%s|%s|%s|%s|%s|%s|%s\n" % (pv2xpv(pk.strip()), event, oponente, date, eco, result, color))
def append(self, pv, event, site, date, white, black, result, eco, whiteelo, blackelo, pgn, okCommit): br = self.dbf.baseRegistro() br.XPV = pv2xpv(pv) br.EVENT = event br.SITE = site br.DATE = date br.WHITE = white br.BLACK = black br.RESULT = result br.PLIES = "%3d" % (pv.strip().count(" ") + 1, ) br.ECO = eco br.WHITEELO = whiteelo br.BLACKELO = blackelo br.PGN = Util.var2blob(pgn) siRepetido = False try: self.dbf.insertar(br, okCommit=okCommit, okCursorClose=okCommit) self.appendSTAT(pv, result, +1, white, black) except: siRepetido = True return not siRepetido