def cambioTutor(parent, configuracion): liGen = [(None, None)] # # Tutor liGen.append(( _("Engine") + ":", configuracion.ayudaCambioTutor() )) # # Decimas de segundo a pensar el tutor liGen.append(( _("Duration of engine analysis (secs)") + ":", float(configuracion.tiempoTutor / 1000.0) )) li = [( _("Maximum"), 0)] for x in ( 1, 3, 5, 10, 15, 20, 30, 40, 50, 75, 100, 150, 200 ): li.append((str(x), x)) config = FormLayout.Combobox(_("Number of moves evaluated by engine(MultiPV)"), li) liGen.append(( config, configuracion.tutorMultiPV )) liGen.append(( None, _("Sensitivity") )) liGen.append((FormLayout.Spinbox(_("Minimum difference in points"), 0, 1000, 70), configuracion.tutorDifPts )) liGen.append((FormLayout.Spinbox(_("Minimum difference in %"), 0, 1000, 70), configuracion.tutorDifPorc )) # Editamos resultado = FormLayout.fedit(liGen, title=_("Tutor change"), parent=parent, anchoMinimo=460, icon=Iconos.Opciones()) if resultado: claveMotor, tiempo, multiPV, difpts, difporc = resultado[1] configuracion.tutor = configuracion.buscaTutor(claveMotor) configuracion.tiempoTutor = int(tiempo*1000) configuracion.tutorMultiPV = multiPV configuracion.tutorDifPts = difpts configuracion.tutorDifPorc = difporc configuracion.graba() return True else: return False
def cambiarJuego(self): mateg = self.controlMate.ultimoNivel() ult_nivel = mateg.nivel + 1 ult_bloque = mateg.numBloqueSinHacer() + 1 if mateg.siTerminado(): ult_nivel += 1 ult_bloque = 1 liGen = [(None, None)] config = FormLayout.Spinbox(_("Level"), 1, ult_nivel, 50) liGen.append((config, ult_nivel)) config = FormLayout.Spinbox(_("Block"), 1, 10, 50) liGen.append((config, ult_bloque)) resultado = FormLayout.fedit(liGen, title=_("Level"), parent=self.pantalla, icon=Iconos.Jugar()) if resultado: nv, bl = resultado[1] nv -= 1 bl -= 1 self.controlMate.ponNivel(nv) self.ponRotuloNivel() self.refresh() self.jugar(bl)
def configurar(self): segundos, puntos, maxerror = self.resistance.actual() separador = FormLayout.separador liGen = [separador] config = FormLayout.Spinbox(_("Time in seconds"), 1, 99999, 80) liGen.append((config, segundos)) liGen.append(separador) config = FormLayout.Spinbox(_("Max lost points in total"), 10, 99999, 80) liGen.append((config, puntos)) liGen.append(separador) config = FormLayout.Spinbox( _("Max lost points in a single move") + ":\n" + _("0 = not consider this limit"), 0, 1000, 80) liGen.append((config, maxerror)) resultado = FormLayout.fedit(liGen, title=_("Config"), parent=self, icon=Iconos.Configurar()) if resultado: accion, liResp = resultado segundos, puntos, maxerror = liResp self.resistance.cambiaconfiguration(segundos, puntos, maxerror) self.set_textAyuda() self.grid.refresh() return liResp[0]
def importarLeeParam(self, titulo, dicData): liGen = [FormLayout.separador] liGen.append(( None, _("Select a maximum number of moves (plies)<br> to consider from each game" ))) liGen.append((FormLayout.Spinbox(_("Depth"), 3, 99, 50), dicData.get("DEPTH", 30))) liGen.append(FormLayout.separador) li = [(_("Only white best moves"), True), (_("Only black best moves"), False)] config = FormLayout.Combobox(_("Moves"), li) liGen.append((config, dicData.get("SIWHITE", True))) liGen.append(FormLayout.separador) liGen.append( (FormLayout.Spinbox(_("Minimum moves must have each line"), 0, 99, 50), dicData.get("MINMOVES", 0))) resultado = FormLayout.fedit(liGen, title=titulo, parent=self, anchoMinimo=360, icon=Iconos.PuntoNaranja()) if resultado: accion, liResp = resultado depth, siWhite, minMoves = liResp dicData["DEPTH"] = depth dicData["SIWHITE"] = siWhite dicData["MINMOVES"] = minMoves self.configuracion.escVariables("WBG_MOVES", dicData) return dicData return None
def formBlundersBrilliancies(alm, configuracion): liBlunders = [SEPARADOR] liBlunders.append(( FormLayout.Editbox(_("Is considered wrong move when the loss of points is greater than"), tipo=int, ancho=50), alm.kblunders)) liBlunders.append(SEPARADOR) def fileNext(base, ext): return Util.fileNext(configuracion.dirPersonalTraining, base, ext) path_pgn = fileNext("Blunders", "pgn") liBlunders.append((None, _("Generate a training file with these moves"))) config = FormLayout.Editbox(_("Tactics name"), rx="[^\\\:/|?*^%><()]*") liBlunders.append((config, "")) config = FormLayout.Fichero(_("PGN Format"), "%s (*.pgn)" % _("PGN Format"), True, anchoMinimo=280, ficheroDefecto=path_pgn) liBlunders.append((config, "")) liBlunders.append((_("Also add complete game to PGN") + ":", False)) liBlunders.append(SEPARADOR) eti = '"%s"' % _("Find best move") liBlunders.append((_X(_("Add to the training %1 with the name"), eti) + ":", "")) liBrilliancies = [SEPARADOR] liBrilliancies.append((FormLayout.Spinbox(_("Minimum depth"), 3, 30, 50), alm.dpbrilliancies)) liBrilliancies.append((FormLayout.Spinbox(_("Minimum gain points"), 30, 30000, 50), alm.ptbrilliancies)) liBrilliancies.append(SEPARADOR) path_fns = fileNext("Brilliancies", "fns") path_pgn = fileNext("Brilliancies", "pgn") liBrilliancies.append((None, _("Generate a training file with these moves"))) config = FormLayout.Fichero(_("List of FENs"), "%s (*.fns)" % _("List of FENs"), True, anchoMinimo=280, ficheroDefecto=path_fns) liBrilliancies.append((config, "")) config = FormLayout.Fichero(_("PGN Format"), "%s (*.pgn)" % _("PGN Format"), True, anchoMinimo=280, ficheroDefecto=path_pgn) liBrilliancies.append((config, "")) liBrilliancies.append((_("Also add complete game to PGN"), False)) liBrilliancies.append(SEPARADOR) eti = '"%s"' % _("Find best move") liBrilliancies.append((_X(_("Add to the training %1 with the name"), eti) + ":", "")) return liBlunders, liBrilliancies
def configurar(self): # Datos li_gen = [(None, None)] # # Motor mt = self.configuration.tutor_inicial if self.engine is None else self.engine li_combo = [mt] for name, key in self.configuration.comboMotoresMultiPV10(): li_combo.append((key, name)) li_gen.append((_("Engine") + ":", li_combo)) # # Segundos a pensar el tutor config = FormLayout.Spinbox(_("Duration of engine analysis (secs)"), 1, 99, 50) li_gen.append((config, self.segundos)) # Pruebas config = FormLayout.Spinbox(_("N. of tests"), 1, 40, 40) li_gen.append((config, self.pruebas)) # Fichero config = FormLayout.Fichero(_("File"), "%s (*.fns);;%s PGN (*.pgn)" % (_("List of FENs"), _("File")), False, anchoMinimo=280) li_gen.append((config, self.fns)) # Editamos resultado = FormLayout.fedit(li_gen, title=_("Configuration"), parent=self, icon=Iconos.Opciones()) if resultado: accion, li_resp = resultado self.engine = li_resp[0] self.segundos = li_resp[1] self.pruebas = li_resp[2] self.fns = li_resp[3] param = UtilSQL.DictSQL(self.configuration.ficheroDailyTest, tabla="parametros") param["ENGINE"] = self.engine param["SEGUNDOS"] = self.segundos param["PRUEBAS"] = self.pruebas param["FNS"] = self.fns param.close()
def reindexar(self, depth=None): if depth is None or self.wb_database.is_temporary: # if not QTUtil2.pregunta(self, _("Do you want to rebuild stats?")): # return li_gen = [(None, None)] li_gen.append((None, _("Select the number of moves <br> for each game to be considered"))) li_gen.append((None, None)) config = FormLayout.Spinbox(_("Depth"), 0, 255, 50) li_gen.append((config, self.dbGames.depth_stat())) resultado = FormLayout.fedit(li_gen, title=_("Rebuild"), parent=self, icon=Iconos.Reindexar()) if resultado is None: return None accion, li_resp = resultado depth = li_resp[0] self.RECCOUNT = 0 bpTmp = QTUtil2.BarraProgreso1(self, _("Rebuilding")) bpTmp.mostrar() def dispatch(recno, reccount): if reccount != self.RECCOUNT: self.RECCOUNT = reccount bpTmp.ponTotal(reccount) bpTmp.pon(recno) return not bpTmp.is_canceled() self.dbGames.rebuild_stat(dispatch, depth) bpTmp.cerrar() self.start()
def importarPGN(self, partida): previo = self.configuracion.leeVariables("OPENINGLINES") carpeta = previo.get("CARPETAPGN", "") ficheroPGN = QTUtil2.leeFichero(self, carpeta, "%s (*.pgn)" % _("PGN Format"), titulo=_("File to import")) if not ficheroPGN: return previo["CARPETAPGN"] = os.path.dirname(ficheroPGN) self.configuracion.escVariables("OPENINGLINES", previo) liGen = [(None, None)] liGen.append((None, _("Select a maximum number of moves (plies)<br> to consider from each game"))) liGen.append((FormLayout.Spinbox(_("Depth"), 3, 999, 50), 30)) liGen.append((None, None)) resultado = FormLayout.fedit(liGen, title=os.path.basename(ficheroPGN), parent=self, anchoMinimo=460, icon=Iconos.PuntoNaranja()) if resultado: accion, liResp = resultado depth = liResp[0] self.dbop.importarPGN(self, partida, ficheroPGN, depth) self.glines.refresh() self.glines.gotop()
def importarPGN(self, game): previo = self.configuracion.leeVariables("OPENINGLINES") carpeta = previo.get("CARPETAPGN", "") ficheroPGN = QTUtil2.leeFichero(self, carpeta, "%s (*.pgn)" % _("PGN Format"), titulo=_("File to import")) if not ficheroPGN: return previo["CARPETAPGN"] = os.path.dirname(ficheroPGN) liGen = [(None, None)] liGen.append((None, _("Select a maximum number of moves (plies)<br> to consider from each game"))) liGen.append((FormLayout.Spinbox(_("Depth"), 3, 999, 50), previo.get("IPGN_DEPTH", 30))) liGen.append((None, None)) liVariations = ((_("All"), "A"), (_("None"), "N"), (_("White"), "W"), (_("Black"), "B")) config = FormLayout.Combobox(_("Include variations"), liVariations) liGen.append((config, previo.get("IPGN_VARIATIONSMODE", "A"))) liGen.append((None, None)) resultado = FormLayout.fedit( liGen, title=os.path.basename(ficheroPGN), parent=self, anchoMinimo=460, icon=Iconos.PuntoNaranja() ) if resultado: accion, liResp = resultado previo["IPGN_DEPTH"] = depth = liResp[0] previo["IPGN_VARIATIONSMODE"] = variations = liResp[1] self.dbop.importarPGN(self, game, ficheroPGN, depth, variations) self.glines.refresh() self.glines.gotop() self.configuracion.escVariables("OPENINGLINES", previo)
def reindexar(self): if not QTUtil2.pregunta(self, _("Do you want to rebuild stats?")): return # Select depth liGen = [(None, None)] liGen.append((None, _("Select the number of moves <br> for each game to be considered"))) liGen.append((None, None)) config = FormLayout.Spinbox(_("Depth"), 3, 255, 50) liGen.append((config, self.dbGames.depthStat())) resultado = FormLayout.fedit(liGen, title=_("Rebuild"), parent=self, icon=Iconos.Reindexar()) if resultado is None: return None accion, liResp = resultado depth = liResp[0] self.RECCOUNT = 0 bpTmp = QTUtil2.BarraProgreso1(self, _("Rebuilding")) bpTmp.mostrar() def dispatch(recno, reccount): if reccount != self.RECCOUNT: self.RECCOUNT = reccount bpTmp.ponTotal(reccount) bpTmp.pon(recno) return not bpTmp.siCancelado() self.dbGames.recrearSTAT(dispatch, depth) bpTmp.cerrar() self.inicio()
def tg_append_pgn(self): previo = VarGen.configuracion.leeVariables("WBG_MOVES") carpeta = previo.get("CARPETAPGN", "") ficheroPGN = QTUtil2.leeFichero(self, carpeta, "%s (*.pgn)" % _("PGN Format"), titulo=_("File to import")) if not ficheroPGN: return previo["CARPETAPGN"] = os.path.dirname(ficheroPGN) VarGen.configuracion.escVariables("WBG_MOVES", previo) liGen = [(None, None)] liGen.append(( None, _("Select a maximum number of moves (plies)<br> to consider from each game") )) liGen.append(( FormLayout.Spinbox(_("Depth"), 3, 999, 50), 30 )) liGen.append((None, None)) resultado = FormLayout.fedit(liGen, title=os.path.basename(ficheroPGN), parent=self, anchoMinimo=460, icon=Iconos.PuntoNaranja()) if resultado: accion, liResp = resultado depth = liResp[0] return self.bookGuide.grabarPGN(self, ficheroPGN, depth) return False
def tg_append_polyglot(self): previo = VarGen.configuracion.leeVariables("WBG_MOVES") carpeta = previo.get("CARPETABIN", "") ficheroBIN = QTUtil2.leeFichero(self, carpeta, "%s (*.bin)" % _("Polyglot book"), titulo=_("File to import")) if not ficheroBIN: return previo["CARPETABIN"] = os.path.dirname(ficheroBIN) VarGen.configuracion.escVariables("WBG_MOVES", previo) liGen = [(None, None)] liGen.append(( None, _("Select a maximum number of moves (plies)<br> to consider from each game") )) liGen.append(( FormLayout.Spinbox(_("Depth"), 3, 99, 50), 30 )) liGen.append((None, None)) liGen.append(( _("Only white best moves"), False )) liGen.append((None, None)) liGen.append(( _("Only black best moves"), False )) liGen.append((None, None)) resultado = FormLayout.fedit(liGen, title=os.path.basename(ficheroBIN), parent=self, anchoMinimo=360, icon=Iconos.PuntoNaranja()) if resultado: accion, liResp = resultado depth, whiteBest, blackBest = liResp return self.bookGuide.grabarPolyglot(self, ficheroBIN, depth, whiteBest, blackBest) return False
def numPosicion(wParent, titulo, nFEN, pos): liGen = [FormLayout.separador] label = "%s (1..%d)" % (_("Select position"), nFEN) liGen.append((FormLayout.Spinbox(label, 1, nFEN, 50), pos)) liGen.append(FormLayout.separador) li = [(_("Sequential"), "s"), (_("Random"), "r"), (_("Random with same sequence based on position"), "rk")] liGen.append((FormLayout.Combobox(_("Type"), li), "s")) liGen.append(FormLayout.separador) liGen.append((_("Jump to the next after solve") + ":", False)) resultado = FormLayout.fedit(liGen, title=titulo, parent=wParent, anchoMinimo=200, icon=Iconos.Entrenamiento()) if resultado: posicion, tipo, jump = resultado[1] return posicion, tipo, jump else: return None
def __init__(self, owner, regSVG, xml=None, nombre=None): QtGui.QDialog.__init__(self, owner) self.setWindowTitle(_("Image")) self.setWindowFlags(QtCore.Qt.WindowCloseButtonHint | QtCore.Qt.Dialog | QtCore.Qt.WindowTitleHint) self.configuracion = VarGen.configuracion if not regSVG: regSVG = TabVisual.PSVG() regSVG.xml = xml if nombre: regSVG.nombre = nombre liAcciones = [(_("Save"), Iconos.Aceptar(), "grabar"), None, (_("Cancel"), Iconos.Cancelar(), "reject"), None, ] tb = Controles.TB(self, liAcciones) # Tablero confTablero = owner.tablero.confTablero self.tablero = Tablero.Tablero(self, confTablero, siDirector=False) self.tablero.crea() self.tablero.copiaPosicionDe(owner.tablero) # Datos generales liGen = [] # nombre del svg que se usara en los menus del tutorial config = FormLayout.Editbox(_("Name"), ancho=120) liGen.append((config, regSVG.nombre)) # ( "opacidad", "n", 1.0 ), config = FormLayout.Dial(_("Degree of transparency"), 0, 99) liGen.append((config, 100 - int(regSVG.opacidad * 100))) # ( "psize", "n", 100 ), config = FormLayout.Spinbox(_("Size") + " %", 1, 1600, 50) liGen.append((config, regSVG.psize)) # orden config = FormLayout.Combobox(_("Order concerning other items"), QTUtil2.listaOrdenes()) liGen.append((config, regSVG.posicion.orden)) self.form = FormLayout.FormWidget(liGen, dispatch=self.cambios) # Layout layout = Colocacion.H().control(self.form).relleno().control(self.tablero) layout1 = Colocacion.V().control(tb).otro(layout) self.setLayout(layout1) # Ejemplos liMovs = ["b4c4", "e2e2", "e4g7"] self.liEjemplos = [] for a1h8 in liMovs: regSVG.a1h8 = a1h8 regSVG.siMovible = True svg = self.tablero.creaSVG(regSVG, siEditando=True) self.liEjemplos.append(svg)
def empezar(self): regBase = self.liIntentos[0] if self.liIntentos else {} liGen = [(None, None)] liGen.append((FormLayout.Spinbox(_("Level"), 0, self.partida.numJugadas(), 40), regBase.get("LEVEL", 0))) liGen.append((None, None)) liGen.append((None, _("User play with") + ":")) liGen.append((_("White"), "w" in regBase.get("COLOR", "bw"))) liGen.append((_("Black"), "b" in regBase.get("COLOR", "bw"))) liGen.append((None, None)) liGen.append((_("Show clock"), True)) resultado = FormLayout.fedit(liGen, title=_("New try"), anchoMinimo=200, parent=self, icon=Iconos.TutorialesCrear()) if resultado is None: return accion, liResp = resultado level = liResp[0] white = liResp[1] black = liResp[2] if not (white or black): return siClock = liResp[3] w = WLearnPuente(self, self.partida, level, white, black, siClock) w.exec_()
def configurar(self): # Datos li_gen = [(None, None)] # # Motor mt = self.configuration.tutor_inicial if self.engine is None else self.engine li_combo = [mt] for name, key in self.configuration.comboMotoresMultiPV10(): li_combo.append((key, name)) li_gen.append((_("Engine") + ":", li_combo)) # # Segundos a pensar el tutor config = FormLayout.Spinbox(_("Duration of engine analysis (secs)"), 1, 99, 50) li_gen.append((config, self.seconds)) # Minutos config = FormLayout.Spinbox(_("Observation time in minutes"), 0, 99, 50) li_gen.append((config, self.min_min)) config = FormLayout.Spinbox( _("Total time (observation + resolution) in minutes"), 0, 99, 50) li_gen.append((config, self.min_max)) # Editamos resultado = FormLayout.fedit(li_gen, title=_("Configuration"), parent=self, icon=Iconos.Opciones()) if resultado: accion, liResp = resultado self.engine = liResp[0] self.seconds = liResp[1] self.min_min = liResp[2] self.min_max = liResp[3] param = UtilSQL.DictSQL(self.configuration.ficheroPotencia, tabla="parametros") param["ENGINE"] = self.engine param["SEGUNDOS"] = self.seconds param["MIN_MIN"] = self.min_min param["MIN_MAX"] = self.min_max param.close()
def configurar(self): # Datos liGen = [(None, None)] # # Motor mt = self.configuracion.tutorInicial if self.motor is None else self.motor liCombo = [mt] for nombre, clave in self.configuracion.comboMotoresMultiPV10(): liCombo.append((clave, nombre)) liGen.append((_("Engine") + ":", liCombo)) # # Segundos a pensar el tutor config = FormLayout.Spinbox(_("Duration of engine analysis (secs)"), 1, 99, 50) liGen.append((config, self.segundos)) # Minutos config = FormLayout.Spinbox(_("Minimum minutes"), 0, 99, 50) liGen.append((config, self.min_min)) config = FormLayout.Spinbox(_("Maximum minutes"), 0, 99, 50) liGen.append((config, self.min_max)) # Editamos resultado = FormLayout.fedit(liGen, title=_("Configuration"), parent=self, icon=Iconos.Opciones()) if resultado: accion, liResp = resultado self.motor = liResp[0] self.segundos = liResp[1] self.min_min = liResp[2] self.min_max = liResp[3] param = Util.DicSQL(self.configuracion.ficheroPotencia, tabla="parametros") param["MOTOR"] = self.motor param["SEGUNDOS"] = self.segundos param["MIN_MIN"] = self.min_min param["MIN_MAX"] = self.min_max param.close()
def dameMinutosExtra(main_window): liGen = [(None, None)] config = FormLayout.Spinbox(_("Extra minutes for the player"), 1, 99, 50) liGen.append((config, 5)) resultado = FormLayout.fedit(liGen, title=_("Time"), parent=main_window, icon=Iconos.MoverTiempo()) if resultado: accion, liResp = resultado return liResp[0] return None
def configurar(self): segundos, puntos = self.boxing.actual() liGen = [(None, None)] config = FormLayout.Spinbox(_("Time in seconds"), 1, 99999, 80) liGen.append((config, segundos)) config = FormLayout.Spinbox(_("Points"), 10, 99999, 80) liGen.append((config, puntos)) resultado = FormLayout.fedit(liGen, title=_("Config"), parent=self, icon=Iconos.Configurar()) if resultado: accion, liResp = resultado segundos = liResp[0] puntos = liResp[1] self.boxing.cambiaConfiguracion(segundos, puntos) self.ponTextoAyuda() self.grid.refresh() return liResp[0]
def form_variations(alm): li_var = [SEPARADOR] li_var.append((_("Add analysis to variations") + ":", alm.include_variations)) li_var.append(SEPARADOR) li_var.append((FormLayout.Spinbox(_("Minimum points lost"), 0, 1000, 60), alm.limit_include_variations)) li_var.append(SEPARADOR) li_var.append((_("Only add better variation") + ":", alm.best_variation)) li_var.append(SEPARADOR) li_var.append((_("Include info about engine") + ":", alm.info_variation)) li_var.append(SEPARADOR) li_var.append(("%s %s/%s/%s:" % (_("Format"), _("Points"), _("Depth"), _("Time")), alm.si_pdt)) li_var.append(SEPARADOR) li_var.append((_("Only one move of each variation") + ":", alm.one_move_variation)) return li_var
def empezar(self): regBase = self.liIntentos[0] if self.liIntentos else {} li_gen = [(None, None)] dic = self.configuration.read_variables("MEMORIZING_GAME") li_gen.append((FormLayout.Spinbox(_("Level"), 0, len(self.game), 40), regBase.get("LEVEL", 0))) li_gen.append((None, None)) li_gen.append((None, _("User play with") + ":")) li_gen.append((_("White"), "w" in regBase.get("COLOR", "bw"))) li_gen.append((_("Black"), "b" in regBase.get("COLOR", "bw"))) li_gen.append((None, None)) li_gen.append((_("Show clock"), dic.get("CLOCK", True))) resultado = FormLayout.fedit(li_gen, title=_("New try"), anchoMinimo=200, parent=self, icon=Iconos.TutorialesCrear()) if resultado is None: return accion, liResp = resultado level = liResp[0] white = liResp[1] black = liResp[2] if not (white or black): return siClock = liResp[3] dic["CLOCK"] = siClock self.configuration.write_variables("MEMORIZING_GAME", dic) w = WLearnPuente(self, self.game, level, white, black, siClock) w.exec_()
def importarPGO(self, partida): li = [(uno.name[:-4], uno.path) for uno in Util.listdir(self.configuracion.carpeta) if uno.name.endswith(".pgo")] if not li: QTUtil2.mensError(self, _("There is no one")) return liGen = [(None, None)] config = FormLayout.Combobox(_("Personal Opening Guide"), li) liGen.append((config, li[0][0])) liGen.append(( None, _("Select a maximum number of moves (plies)<br> to consider from each game" ))) liGen.append((FormLayout.Spinbox(_("Depth"), 3, 999, 50), 30)) liGen.append((None, None)) resultado = FormLayout.fedit(liGen, title=_("Personal Opening Guide"), parent=self, anchoMinimo=460, icon=Iconos.BookGuide()) if resultado: accion, liResp = resultado pgo, depth = liResp self.dbop.importarPGO(partida, pgo, depth) self.glines.refresh() self.glines.gotop() QTUtil2.mensaje(self, _("Imported"))
def trainNewEngines(self): training = self.dbop.trainingEngines() color = "WHITE" basepv = self.dbop.basePV mandatory = basepv.count(" ") + 1 if len(basepv) > 0 else 0 control = 10 lost_points = 20 engine_control = self.configuracion.tutor.clave engine_time = 5.0 num_engines = 20 key_engine = "alaric" ext_engines = [] auto_analysis = True ask_movesdifferent = False times = [500, 1000, 2000, 4000, 8000] books = ["", "", "", "", ""] if training is not None: color = training["COLOR"] mandatory = training.get("MANDATORY", mandatory) control = training.get("CONTROL", control) lost_points = training.get("LOST_POINTS", lost_points) engine_control = training.get("ENGINE_CONTROL", engine_control) engine_time = training.get("ENGINE_TIME", engine_time) num_engines = training.get("NUM_ENGINES", num_engines) key_engine = training.get("KEY_ENGINE", key_engine) ext_engines = training.get("EXT_ENGINES", ext_engines) auto_analysis = training.get("AUTO_ANALYSIS", auto_analysis) ask_movesdifferent = training.get("ASK_MOVESDIFFERENT", ask_movesdifferent) times = training.get("TIMES", times) books = training.get("BOOKS", books) separador = FormLayout.separador liGen = [separador] liJ = [(_("White"), "WHITE"), (_("Black"), "BLACK")] config = FormLayout.Combobox(_("Play with"), liJ) liGen.append((config, color)) liGen.append((_("Mandatory moves") + ":", mandatory)) liGen.append(separador) liGen.append((_("Moves until the control") + ":", control)) liGen.append(separador) liGen.append( (_("Maximum number of lost centipawns to pass control") + ":", lost_points)) liGen.append(separador) dicRivales = self.configuracion.dicRivales dicRivales = EnginesBunch.filtra(dicRivales) config = FormLayout.Spinbox(_("Number of engines"), 0, len(dicRivales), 50) liGen.append((config, num_engines)) likeys = [(dicRivales[x].nombre, x) for x in dicRivales] likeys.sort(key=lambda x: x[1]) config = FormLayout.Combobox(_("Bunch of engines"), likeys) liGen.append((config, key_engine)) liGen.append(separador) config = FormLayout.Combobox(_("Engine that does the control"), self.configuracion.comboMotoresCompleto()) liGen.append((config, engine_control)) liGen.append( (_("Duration of analysis (secs)") + ":", float(engine_time))) liGen.append(separador) liGen.append((_("Automatic analysis") + ":", auto_analysis)) liGen.append(separador) liGen.append( (_("Ask when the moves are different from the line") + ":", ask_movesdifferent)) liMotoresExternos = self.configuracion.listaMotoresExternos( ordenados=False) if liMotoresExternos: liExt = [separador] for cm in liMotoresExternos: liExt.append((cm.nombre, cm.alias in ext_engines)) else: liExt = None liLevels = [separador] listaLibros = Books.ListaLibros() listaLibros.recuperaVar(self.configuracion.ficheroBooks) listaLibros.comprueba() libooks = [(bookx.nombre, bookx) for bookx in listaLibros.lista] libooks.insert(0, ("--", None)) for level in range(5): n = level + 1 title = "%s %d" % (_("Level"), n) liLevels.append((None, title)) tm = times[level] / 1000.0 if len(times) > level else 0.0 liLevels.append((_("Time engines think in seconds") + ":", tm)) bk = books[level] if len(books) > level else "" book = listaLibros.buscaLibro(bk) if bk else None config = FormLayout.Combobox(_("Book"), libooks) liLevels.append((config, book)) lista = [] lista.append((liGen, _("Basic data"), "")) if liExt: lista.append((liExt, _("External engines"), "")) lista.append((liLevels, _("Levels"), "")) resultado = FormLayout.fedit(lista, title=_("With engines"), parent=self, anchoMinimo=360, icon=Iconos.Study()) if resultado is None: return accion, liResp = resultado selMotoresExt = [] if liMotoresExternos: liGen, liExt, liLevels = liResp for x in range(len(liMotoresExternos)): if liExt[x]: selMotoresExt.append(liMotoresExternos[x].alias) else: liGen, liLevels = liResp reg = {} (reg["COLOR"], reg["MANDATORY"], reg["CONTROL"], reg["LOST_POINTS"], reg["NUM_ENGINES"], reg["KEY_ENGINE"], reg["ENGINE_CONTROL"], reg["ENGINE_TIME"], reg["AUTO_ANALYSIS"], reg["ASK_MOVESDIFFERENT"]) = liGen reg["EXT_ENGINES"] = selMotoresExt if (len(selMotoresExt) + reg["NUM_ENGINES"]) == 0: reg["NUM_ENGINES"] = 1 times = [] books = [] for x in range(5): tm = int(liLevels[x * 2] * 1000) bk = liLevels[x * 2 + 1] if tm: times.append(tm) books.append(bk.nombre if bk else "") if len(times) == 0: times.append(500) books.append(None) reg["TIMES"] = times reg["BOOKS"] = books self.dbop.createTrainingEngines(reg, self.procesador) QTUtil2.mensaje(self, _("Created"))
def gmCrear(self): if self.torneo.numEngines() < 2: QTUtil2.mensError(self, _("You must create at least two engines")) return dicValores = self.configuracion.leeVariables("crear_torneo") get = dicValores.get liGen = [(None, None)] config = FormLayout.Spinbox(_("Rounds"), 1, 999, 50) liGen.append((config, get("ROUNDS", 1))) liGen.append((None, None)) config = FormLayout.Spinbox(_("Total minutes"), 1, 999, 50) liGen.append((config, get("MINUTES", 10))) config = FormLayout.Spinbox(_("Seconds added per move"), 0, 999, 50) liGen.append((config, get("SECONDS", 0))) liGen.append((None, _("Engines"))) liEngines = self.torneo.liEngines() for pos, en in enumerate(liEngines): liGen.append((en.alias, get(en.huella(), True))) liGen.append((None, None)) liGen.append((_("Select all"), False)) reg = Util.Almacen() reg.form = None def dispatch(valor): if reg.form is None: reg.form = valor reg.liEngines = [] leng = len(liEngines) for x in range(leng): reg.liEngines.append(valor.getWidget(x + 3)) reg.selectall = valor.getWidget(leng + 3) reg.valorall = False else: QTUtil.refreshGUI() select = reg.selectall.isChecked() if select != reg.valorall: for uno in reg.liEngines: uno.setChecked(select) reg.valorall = select QTUtil.refreshGUI() resultado = FormLayout.fedit(liGen, title=_("Games"), parent=self, icon=Iconos.Torneos(), dispatch=dispatch) if resultado is None: return accion, liResp = resultado dicValores["ROUNDS"] = rounds = liResp[0] dicValores["MINUTES"] = minutos = liResp[1] dicValores["SECONDS"] = segundos = liResp[2] liSel = [] for num in range(self.torneo.numEngines()): en = liEngines[num] dicValores[en.huella()] = si = liResp[3 + num] if si: liSel.append(en.huella()) self.configuracion.escVariables("crear_torneo", dicValores) nSel = len(liSel) if nSel < 2: QTUtil2.mensError(self, _("You must create at least two engines")) return for r in range(rounds): for x in range(0, nSel - 1): for y in range(x + 1, nSel): self.torneo.nuevoGame(liSel[x], liSel[y], minutos, segundos) self.torneo.nuevoGame(liSel[y], liSel[x], minutos, segundos) self.gridGames.refresh() self.gridGames.gobottom() self.borraResult()
def __init__(self, owner, regMarker, xml=None, nombre=None): QtGui.QDialog.__init__(self, owner) self.setWindowTitle(_("Marker")) self.setWindowFlags(QtCore.Qt.Dialog | QtCore.Qt.WindowTitleHint) self.configuracion = VarGen.configuracion if not regMarker: regMarker = TabVisual.PMarker() regMarker.xml = xml if nombre: regMarker.nombre = nombre liAcciones = [ (_("Save"), Iconos.Aceptar(), self.grabar), None, (_("Cancel"), Iconos.Cancelar(), self.reject), None, ] tb = Controles.TBrutina(self, liAcciones) # Tablero confTablero = owner.tablero.confTablero self.tablero = Tablero.TableroVisual(self, confTablero) self.tablero.crea() self.tablero.copiaPosicionDe(owner.tablero) # Datos generales liGen = [] # nombre del svg que se usara en los menus del tutorial config = FormLayout.Editbox(_("Name"), ancho=120) liGen.append((config, regMarker.nombre)) # ( "opacidad", "n", 1.0 ), config = FormLayout.Dial(_("Degree of transparency"), 0, 99) liGen.append((config, 100 - int(regMarker.opacidad * 100))) # ( "psize", "n", 100 ), config = FormLayout.Spinbox(_("Size") + " %", 1, 1600, 50) liGen.append((config, regMarker.psize)) # ( "poscelda", "n", 1 ), li = ( ("%s-%s" % (_("Top"), _("Left")), 0), ("%s-%s" % (_("Top"), _("Right")), 1), ("%s-%s" % (_("Bottom"), _("Left")), 2), ("%s-%s" % (_("Bottom"), _("Right")), 3), ) config = FormLayout.Combobox(_("Position in the square"), li) liGen.append((config, regMarker.poscelda)) # orden config = FormLayout.Combobox(_("Order concerning other items"), QTUtil2.listaOrdenes()) liGen.append((config, regMarker.posicion.orden)) self.form = FormLayout.FormWidget(liGen, dispatch=self.cambios) # Layout layout = Colocacion.H().control(self.form).relleno().control( self.tablero) layout1 = Colocacion.V().control(tb).otro(layout) self.setLayout(layout1) # Ejemplos liMovs = ["b4c4", "e2e2", "e4g7"] self.liEjemplos = [] for a1h8 in liMovs: regMarker.a1h8 = a1h8 regMarker.siMovible = True marker = self.tablero.creaMarker(regMarker, siEditando=True) self.liEjemplos.append(marker)
def __init__(self, owner, regFlecha, siNombre): QtGui.QDialog.__init__(self, owner) self.setWindowTitle(_("Arrow")) self.setWindowFlags(QtCore.Qt.Dialog | QtCore.Qt.WindowTitleHint) self.siNombre = siNombre if not regFlecha: regFlecha = TabVisual.PFlecha() liAcciones = [ (_("Save"), Iconos.Aceptar(), "grabar"), None, (_("Cancel"), Iconos.Cancelar(), "reject"), None, ] tb = Controles.TB(self, liAcciones) # Tablero confTablero = owner.tablero.confTablero.copia( owner.tablero.confTablero.id()) confTablero.anchoPieza(32) self.tablero = Tablero.TableroVisual(self, confTablero) self.tablero.crea() self.tablero.copiaPosicionDe(owner.tablero) # Datos generales liGen = [] if siNombre: # nombre de la flecha que se usara en los menus del tutorial config = FormLayout.Editbox(_("Name"), ancho=120) liGen.append((config, regFlecha.nombre)) # ( "forma", "t", "a" ), # a = abierta -> , c = cerrada la cabeza, p = poligono cuadrado, liFormas = ( (_("Opened"), "a"), (_("Head closed"), "c"), (_("Polygon 1"), "1"), (_("Polygon 2"), "2"), (_("Polygon 3"), "3"), ) config = FormLayout.Combobox(_("Form"), liFormas) liGen.append((config, regFlecha.forma)) # ( "tipo", "n", Qt.SolidLine ), #1=SolidLine, 2=DashLine, 3=DotLine, 4=DashDotLine, 5=DashDotDotLine config = FormLayout.Combobox(_("Line Type"), QTUtil2.tiposDeLineas()) liGen.append((config, regFlecha.tipo)) # liGen.append( (None,None) ) # ( "color", "n", 0 ), config = FormLayout.Colorbox(_("Color"), 80, 20) liGen.append((config, regFlecha.color)) # ( "colorinterior", "n", -1 ), # si es cerrada config = FormLayout.Colorbox(_("Internal color"), 80, 20, siChecked=True) liGen.append((config, regFlecha.colorinterior)) # ( "opacidad", "n", 1.0 ), config = FormLayout.Dial(_("Degree of transparency"), 0, 99) liGen.append((config, 100 - int(regFlecha.opacidad * 100))) # liGen.append( (None,None) ) # ( "redondeos", "l", False ), liGen.append((_("Rounded edges"), regFlecha.redondeos)) # ( "grosor", "n", 1 ), # ancho del trazo config = FormLayout.Spinbox(_("Thickness"), 1, 20, 50) liGen.append((config, regFlecha.grosor)) # liGen.append( (None,None) ) # ( "altocabeza", "n", 1 ), # altura de la cabeza config = FormLayout.Spinbox(_("Head height"), 0, 100, 50) liGen.append((config, regFlecha.altocabeza)) # ( "ancho", "n", 10 ), # ancho de la base de la flecha si es un poligono config = FormLayout.Spinbox(_("Base width"), 1, 100, 50) liGen.append((config, regFlecha.ancho)) # ( "vuelo", "n", 5 ), # vuelo de la flecha respecto al ancho de la base config = FormLayout.Spinbox( _("Additional width of the base of the head"), 1, 100, 50) liGen.append((config, regFlecha.vuelo)) # ( "descuelgue", "n", 2 ), # vuelo hacia arriba config = FormLayout.Spinbox(_("Height of the base angle of the head"), -100, 100, 50) liGen.append((config, regFlecha.descuelgue)) # liGen.append( (None,None) ) # ( "destino", "t", "c" ), # c = centro, m = minimo config = FormLayout.Combobox(_("Target position"), tiposDestino()) liGen.append((config, regFlecha.destino)) # liGen.append( (None,None) ) # orden config = FormLayout.Combobox(_("Order concerning other items"), QTUtil2.listaOrdenes()) liGen.append((config, regFlecha.posicion.orden)) self.form = FormLayout.FormWidget(liGen, dispatch=self.cambios) # Layout layout = Colocacion.H().control(self.form).relleno().control( self.tablero) layout1 = Colocacion.V().control(tb).otro(layout) self.setLayout(layout1) # Ejemplos liMovs = ["d2d6", "a8h8", "h5b7"] self.liEjemplos = [] for a1h8 in liMovs: regFlecha.a1h8 = a1h8 regFlecha.siMovible = True flecha = self.tablero.creaFlecha(regFlecha) self.liEjemplos.append(flecha)
def __init__(self, owner, regMarco): QtWidgets.QDialog.__init__(self, owner) self.setWindowTitle(_("Box")) self.setWindowFlags(QtCore.Qt.Dialog | QtCore.Qt.WindowTitleHint) if not regMarco: regMarco = TabVisual.PMarco() liAcciones = [ (_("Save"), Iconos.Aceptar(), "grabar"), None, (_("Cancel"), Iconos.Cancelar(), "reject"), None, ] tb = Controles.TB(self, liAcciones) # Tablero confTablero = owner.tablero.confTablero self.tablero = Tablero.Tablero(self, confTablero, siDirector=False) self.tablero.crea() self.tablero.copiaPosicionDe(owner.tablero) # Datos generales liGen = [] # nombre del marco que se usara en los menus del tutorial config = FormLayout.Editbox(_("Name"), ancho=120) liGen.append((config, regMarco.nombre)) # ( "tipo", "n", Qt.SolidLine ), #1=SolidLine, 2=DashLine, 3=DotLine, 4=DashDotLine, 5=DashDotDotLine config = FormLayout.Combobox(_("Line Type"), QTUtil2.tiposDeLineas()) liGen.append((config, regMarco.tipo)) # ( "color", "n", 0 ), config = FormLayout.Colorbox(_("Color"), 80, 20) liGen.append((config, regMarco.color)) # ( "colorinterior", "n", -1 ), config = FormLayout.Colorbox(_("Internal color"), 80, 20, siChecked=True) liGen.append((config, regMarco.colorinterior)) # ( "opacidad", "n", 1.0 ), config = FormLayout.Dial(_("Degree of transparency"), 0, 99) liGen.append((config, 100 - int(regMarco.opacidad * 100))) # ( "grosor", "n", 1 ), # ancho del trazo config = FormLayout.Spinbox(_("Thickness"), 1, 20, 50) liGen.append((config, regMarco.grosor)) # ( "redEsquina", "n", 0 ), config = FormLayout.Spinbox(_("Rounded corners"), 0, 100, 50) liGen.append((config, regMarco.redEsquina)) # orden config = FormLayout.Combobox(_("Order concerning other items"), QTUtil2.listaOrdenes()) liGen.append((config, regMarco.posicion.orden)) self.form = FormLayout.FormWidget(liGen, dispatch=self.cambios) # Layout layout = Colocacion.H().control(self.form).relleno().control( self.tablero) layout1 = Colocacion.V().control(tb).otro(layout) self.setLayout(layout1) # Ejemplos liMovs = ["b4c4", "e2e2", "e4g7"] self.liEjemplos = [] for a1h8 in liMovs: regMarco.a1h8 = a1h8 regMarco.siMovible = True marco = self.tablero.creaMarco(regMarco) self.liEjemplos.append(marco)
def paramAnalisis(parent, configuracion, siModoAmpliado, siTodosMotores=False): alm = leeDicParametros(configuracion) # Datos liGen = [SEPARADOR] # # Tutor if siTodosMotores: li = configuracion.ayudaCambioCompleto(alm.motor) else: li = configuracion.ayudaCambioTutor() li[0] = alm.motor liGen.append((_("Engine") + ":", li)) # # Time liGen.append(SEPARADOR) config = FormLayout.Editbox(_("Duration of engine analysis (secs)"), 40, tipo=float) liGen.append((config, alm.tiempo / 1000.0)) # Depth liDepths = [("--", 0)] for x in range(1, 51): liDepths.append((str(x), x)) config = FormLayout.Combobox(_("Depth"), liDepths) liGen.append((config, alm.depth)) # Time+Depth liGen.append(("%s+%s:" % (_("Time"), _("Depth")), alm.timedepth)) # MultiPV liGen.append(SEPARADOR) li = [(_("Default"), "PD"), (_("Maximum"), "MX")] for x in (1, 3, 5, 10, 15, 20, 30, 40, 50, 75, 100, 150, 200): li.append((str(x), str(x))) config = FormLayout.Combobox( _("Number of moves evaluated by engine(MultiPV)"), li) liGen.append((config, alm.multiPV)) # Priority liGen.append(SEPARADOR) li = [(_("Normal"), EngineThread.PRIORITY_NORMAL), (_("Low"), EngineThread.PRIORITY_LOW), (_("Very low"), EngineThread.PRIORITY_VERYLOW), (_("High"), EngineThread.PRIORITY_HIGH), (_("Very high"), EngineThread.PRIORITY_VERYHIGH)] config = FormLayout.Combobox(_("Process priority"), li) liGen.append((config, alm.priority)) # Completo if siModoAmpliado: liGen.append(SEPARADOR) liJ = [(_("White"), "BLANCAS"), (_("Black"), "NEGRAS"), (_("White & Black"), "AMBOS")] config = FormLayout.Combobox(_("Analyze only color"), liJ) liGen.append((config, "AMBOS")) config = FormLayout.Editbox("<div align=\"right\">" + _("Moves") + "<br>" + _("By example:") + " -5,8-12,14,19-", rx="[0-9,\-,\,]*") liGen.append((config, "")) fvar = configuracion.ficheroBooks listaLibros = Books.ListaLibros() listaLibros.recuperaVar(fvar) # Comprobamos que todos esten accesibles listaLibros.comprueba() li = [("--", None)] defecto = listaLibros.lista[0] if alm.libro else None for libro in listaLibros.lista: if alm.libro == libro.nombre: defecto = libro li.append((libro.nombre, libro)) config = FormLayout.Combobox( _("Do not scan the opening moves based on book"), li) liGen.append((config, defecto)) liGen.append(SEPARADOR) liGen.append( (_("To redo any existing prior analyses (if they exist)") + ":", alm.siBorrarPrevio)) liGen.append( (_("Start from the end of the game") + ":", alm.desdeelfinal)) liGen.append(SEPARADOR) liGen.append((_("Show graphics") + ":", alm.showGraphs)) liVar = [SEPARADOR] liVar.append((_("Add analysis to variants") + ":", alm.masvariantes)) liVar.append(SEPARADOR) liVar.append((FormLayout.Spinbox(_("Minimum points lost"), 0, 1000, 60), alm.limitemasvariantes)) liVar.append(SEPARADOR) liVar.append((_("Only add better variant") + ":", alm.mejorvariante)) liVar.append(SEPARADOR) liVar.append((_("Include info about engine") + ":", alm.infovariante)) liVar.append(SEPARADOR) liVar.append( ("%s %s/%s/%s:" % (_("Format"), _("Points"), _("Depth"), _("Time")), alm.siPDT)) liVar.append(SEPARADOR) liVar.append( (_("Only one move of each variant") + ":", alm.unmovevariante)) liBlunders, liBrilliancies = formBlundersBrilliancies( alm, configuracion) liST = [SEPARADOR] liST.append((_("Activate") + ":", alm.stability)) liST.append(SEPARADOR) liST.append( (FormLayout.Spinbox(_("Last depths to control same best move"), 2, 10, 40), alm.st_depths)) liST.append(SEPARADOR) liST.append( (FormLayout.Spinbox(_("Maximum difference among last evaluations"), 0, 99999, 60), alm.st_centipawns)) liST.append(SEPARADOR) liST.append((FormLayout.Spinbox(_("Additional time limit"), 0, 99999, 60), alm.st_timelimit)) lista = [] lista.append((liGen, _("General options"), "")) lista.append((liVar, _("Variants"), "")) lista.append((liBlunders, _("Wrong moves"), "")) lista.append((liBrilliancies, _("Brilliancies"), "")) lista.append((liST, _("Stability control"), "")) else: lista = liGen reg = Util.Almacen() reg.form = None def dispatchR(valor): if reg.form is None: if isinstance(valor, FormLayout.FormTabWidget): reg.form = valor reg.wtime = valor.getWidget(0, 1) reg.wdepth = valor.getWidget(0, 2) reg.wdt = valor.getWidget(0, 3) elif isinstance(valor, FormLayout.FormWidget): reg.form = valor reg.wtime = valor.getWidget(1) reg.wdepth = valor.getWidget(2) reg.wdt = valor.getWidget(3) else: sender = reg.form.sender() if not reg.wdt.isChecked(): if sender == reg.wtime: if reg.wtime.textoFloat() > 0: reg.wdepth.setCurrentIndex(0) elif sender == reg.wdepth: if reg.wdepth.currentIndex() > 0: reg.wtime.ponFloat(0.0) elif sender == reg.wdt: if reg.wtime.textoFloat() > 0: reg.wdepth.setCurrentIndex(0) elif reg.wdepth.currentIndex() > 0: reg.wtime.ponFloat(0.0) QTUtil.refreshGUI() resultado = FormLayout.fedit(lista, title=_("Analysis Configuration"), parent=parent, anchoMinimo=460, icon=Iconos.Opciones(), dispatch=dispatchR) if resultado: accion, liResp = resultado if siModoAmpliado: liGen, liVar, liBlunders, liBrilliancies, liST = liResp else: liGen = liResp alm.motor = liGen[0] alm.tiempo = int(liGen[1] * 1000) alm.depth = liGen[2] alm.timedepth = liGen[3] alm.multiPV = liGen[4] alm.priority = liGen[5] if siModoAmpliado: color = liGen[6] alm.blancas = color != "NEGRAS" alm.negras = color != "BLANCAS" alm.jugadas = liGen[7] alm.libroAperturas = liGen[8] alm.libro = alm.libroAperturas.nombre if alm.libroAperturas else None alm.siBorrarPrevio = liGen[9] alm.desdeelfinal = liGen[10] alm.showGraphs = liGen[11] (alm.masvariantes, alm.limitemasvariantes, alm.mejorvariante, alm.infovariante, alm.siPDT, alm.unmovevariante) = liVar (alm.kblunders, alm.tacticblunders, alm.pgnblunders, alm.oriblunders, alm.bmtblunders) = liBlunders (alm.dpbrilliancies, alm.ptbrilliancies, alm.fnsbrilliancies, alm.pgnbrilliancies, alm.oribrilliancies, alm.bmtbrilliancies) = liBrilliancies (alm.stability, alm.st_depths, alm.st_centipawns, alm.st_timelimit) = liST dic = {} for x in dir(alm): if not x.startswith("__"): dic[x.upper()] = getattr(alm, x) Util.guardaVar(configuracion.ficheroAnalisis, dic) return alm else: return None
def createGuide(self): name = os.path.basename(self.dbGames.nomFichero)[:-4] maxdepth = self.dbGames.depthStat() depth = maxdepth minGames = min(self.dbGames.all_reccount() * 10 / 100, 5) pointview = 2 inicio = 0 mov = self.movActivo() while True: liGen = [(None, None)] liGen.append((_("Name") + ":", name)) liGen.append((FormLayout.Spinbox(_("Depth"), 2, maxdepth, 50), depth)) liGen.append((None, None)) liGen.append((FormLayout.Spinbox(_("Minimum games"), 1, 99, 50), minGames)) liGen.append((None, None)) liPointV = [ pointview, (0, _("White")), (1, _("Black")), (2, "%s + %s" % (_("White"), _("Draw"))), (3, "%s + %s" % (_("Black"), _("Draw"))), ] liGen.append((_("Point of view") + ":", liPointV)) liGen.append((None, None)) if mov: liInicio = [ inicio, (0, _("The beginning")), (1, _("Current move")), ] liGen.append((_("Start from") + ":", liInicio)) resultado = FormLayout.fedit(liGen, title=_("Create new guide"), parent=self, anchoMinimo=460, icon=Iconos.TutorialesCrear()) if resultado is None: return accion, liResp = resultado name = liResp[0].strip() if not name: return depth = liResp[1] minGames = liResp[2] pointview = liResp[3] if mov: inicio = liResp[4] ok = True for una in self.bookGuide.getTodas(): if una.strip().upper() == name.upper(): QTUtil2.mensError(self, _("The name is repeated")) ok = False continue if ok: break # Grabamos um = QTUtil2.unMomento(self) # Read stats siWhite = pointview % 2 == 0 siDraw = pointview > 1 pv = "" if mov: if inicio > 0: pv = self.pvBase + " " + mov["pvmove"] pv = pv.strip() fichPVs = self.dbGames.flistAllpvs(depth, minGames, siWhite, siDraw, pv) # Write to bookGuide self.bookGuide.grabarFichSTAT(name, fichPVs) # BookGuide self.wmoves.inicializa() um.final()
def opciones(parent, configuracion): separador = (None, None) # Datos generales liGen = [separador] # # Nombre del jugador liGen.append((_("Player's name") + ":", configuracion.jugador)) # # Estilo liGen.append((_("Window style") + ":", configuracion.estilos())) liTraducciones = configuracion.listaTraducciones() trActual = configuracion.traductor if configuracion.traductor else "en" li = [trActual] for k, trad, porc, author in liTraducciones: rotulo = "%s" % trad if int(porc) < 90: rotulo += " (%s%%)"%porc li.append((k, rotulo)) liGen.append((_("Language") + ":", li)) liGen.append(separador) liGen.append((_("Check for updates at startup") + ":", configuracion.checkforupdate)) # Engines liEng = [separador] liMedidas = [configuracion.centipawns, (True, "%s = 100 %s -> 64, 19, -19, +23, -120, +130" % (_("One pawn"), _("points"))), (False, "%s = 1.00 %s -> 0.64, 0.19, -0.19, +0.23, -1.20, +1.30" % (_("One pawn"), _("points")))] liEng.append((_("By showing scores from the engines") + ":", liMedidas)) liEng.append(separador) liEng.append((_("OS 64bits BMI2 compatible") + ":", configuracion.bmi2)) liEng.append(separador) liEng.append((_("Do not work in background when possible") + ":", configuracion.notbackground)) # Aspect liAsp = [] liAsp.append((_("By default") + ":", False)) liAsp.append(separador) ## font general liAsp.append((FormLayout.FontCombobox(_("Font")), configuracion.familia)) liAsp.append(separador) ## Menus liAsp.append((None, _("Menus") + ":")) liAsp.append((FormLayout.Spinbox(_("Font size"), 5, 64, 60), configuracion.puntosMenu)) liAsp.append((_("Bold") + ":", configuracion.boldMenu)) ## Toolbars liAsp.append(separador) liAsp.append((None, _("Toolbars") + ":")) liAsp.append((FormLayout.Spinbox(_("Font size"), 5, 64, 60), configuracion.puntosTB)) liAsp.append((_("Bold") + ":", configuracion.boldTB)) li = ( (_("Only display the icon"), QtCore.Qt.ToolButtonIconOnly), (_("Only display the text"), QtCore.Qt.ToolButtonTextOnly), (_("The text appears beside the icon"), QtCore.Qt.ToolButtonTextBesideIcon), (_("The text appears under the icon"), QtCore.Qt.ToolButtonTextUnderIcon) ) config = FormLayout.Combobox(_("Icons"), li) liAsp.append((config, configuracion.iconsTB)) ## PGN table liAsp.append(separador) liAsp.append((None, _("PGN table") + ":")) liAsp.append((FormLayout.Spinbox(_("Width"), 283, 1000, 70), configuracion.anchoPGN)) liAsp.append((FormLayout.Spinbox(_("Height of each row"), 18, 99, 40), configuracion.altoFilaPGN)) liAsp.append((FormLayout.Spinbox(_("Font size"), 10, 99, 40), configuracion.puntosPGN)) liAsp.append((_("PGN always in English") + ":", configuracion.siNomPiezasEN)) liAsp.append((_("PGN with figurines") + ":", configuracion.figurinesPGN)) liAsp.append(separador) liAsp.append((FormLayout.Spinbox(_("Font size of information labels"), 8, 30, 40), configuracion.tamFontRotulos)) # Sonidos liSon = [separador] liSon.append(separador) # Si a_adimos sonido tras cada jugada liSon.append((_("Beep after opponent's move") + ":", configuracion.siSuenaBeep)) liSon.append(separador) liSon.append((None, _("Sound on in") + ":")) liSon.append((_("Results") + ":", configuracion.siSuenaResultados)) liSon.append((_("Rival moves") + ":", configuracion.siSuenaJugada)) liSon.append(separador) liSon.append((_("Activate sounds with our moves") + ":", configuracion.siSuenaNuestro)) liSon.append(separador) # Tutor liTT = [separador] liTT.append((_("Engine") + ":", configuracion.ayudaCambioTutor())) liTT.append((_("Duration of tutor analysis (secs)") + ":", float(configuracion.tiempoTutor / 1000.0))) li = [(_("Maximum"), 0)] for x in (1, 3, 5, 10, 15, 20, 30, 40, 50, 75, 100, 150, 200): li.append((str(x), x)) config = FormLayout.Combobox(_("Number of moves evaluated by engine(MultiPV)"), li) liTT.append((config, configuracion.tutorMultiPV)) liTT.append(separador) liTT.append((_("Tutor enabled"), configuracion.tutorActivoPorDefecto)) liTT.append(separador) liTT.append((None, _("Sensitivity"))) liTT.append((FormLayout.Spinbox(_("Minimum difference in points"), 0, 1000, 70), configuracion.tutorDifPts)) liTT.append((FormLayout.Spinbox(_("Minimum difference in %"), 0, 1000, 70), configuracion.tutorDifPorc)) # Modo no competitivo liNC = [separador] liNC.append((FormLayout.Spinbox(_("Lucas-Elo"), 0, 3200, 70), configuracion.eloNC)) liNC.append((FormLayout.Spinbox(_("Tourney-Elo"), 0, 3200, 70), configuracion.micheloNC)) liNC.append((FormLayout.Spinbox(_("Fics-Elo"), 0, 3200, 70), configuracion.ficsNC)) liNC.append((FormLayout.Spinbox(_("Fide-Elo"), 0, 3200, 70), configuracion.fideNC)) # Salvado automatico liSA = [separador] config = FormLayout.Fichero(_("Autosave to a PGN file"), "pgn", True) liSA.append((config, configuracion.salvarFichero)) liSA.append((_("Won games") + ":", configuracion.salvarGanados)) liSA.append((_("Lost/Drawn games") + ":", configuracion.salvarPerdidos)) liSA.append((_("Unfinished games") + ":", configuracion.salvarAbandonados)) liSA.append(separador) liSA.append((_("Save as variant tutor's suggestion") + ":", configuracion.guardarVariantesTutor)) liSA.append(separador) config = FormLayout.Fichero(_("Autosave to a CSV file moves played"), "csv", True) liSA.append((config, configuracion.salvarCSV)) # Boards liT = [separador] # Mostrando el tutor # kTutorH, kTutorH2_1, kTutorH1_2, kTutorV liPosTutor = [configuracion.vistaTutor, (kTutorH, _("Horizontal")), (kTutorH2_1, _("Horizontal") + " 2+1"), (kTutorH1_2, _("Horizontal") + " 1+2"), (kTutorV, _("Vertical"))] liT.append((_("Tutor boards position") + ":", liPosTutor)) liT.append(separador) liT.append((_("Visual effects") + ":", configuracion.efectosVisuales)) drap = {1: 100, 2: 150, 3: 200, 4: 250, 5: 300, 6: 350, 7: 400, 8: 450, 9: 500} drapV = {} for x in drap: drapV[drap[x]] = x liT.append((FormLayout.Dial("%s (%s=1)" % (_("Speed"), _("Default")), 1, len(drap), siporc=False), drapV.get(configuracion.rapidezMovPiezas, 100))) liT.append(separador) liMouseSH = [configuracion.siAtajosRaton, (False, _("Type fixed: you must always indicate origin and destination")), (True, _("Type predictive: program tries to guess your intention"))] liT.append((_("Mouse shortcuts") + ":", liMouseSH)) liT.append((_("Show candidates") + ":", configuracion.showCandidates)) liT.append((_("Show arrows of variants") + ":", configuracion.showVariantes)) liT.append(separador) liT.append((_("Show cursor when engine is thinking") + ":", configuracion.cursorThinking)) liT.append(separador) liT.append((_("Enable captured material window by default") + ":", configuracion.siActivarCapturas)) liMat = [configuracion.tipoMaterial, ("D", _("Difference material")), ("C", _("Captured material at beginning")), ("M", _("Material advantage"))] liT.append((_("Show material") + ":", liMat)) liT.append(separador) liT.append((_("Enable information panel by default") + ":", configuracion.siActivarInformacion)) liT.append(separador) liT.append((_X(_("Enable %1"), _("DGT board")) + ":", configuracion.siDGT)) liT.append(separador) # liT.append((FormLayout.Dial(_("Opacity of tool icon"), 1, 9, siporc=False), configuracion.opacityToolBoard)) liT.append((_("Show configuration icon"), configuracion.opacityToolBoard > 6)) liPos = [configuracion.positionToolBoard, ("B", _("Bottom")), ("T", _("Top"))] liT.append((_("Configuration icon position" + ":"), liPos)) liT.append(separador) lista = [] lista.append((liGen, _("General"), "")) lista.append((liSon, _("Sounds"), "")) lista.append((liTT, _("Tutor"), "")) lista.append((liT, _("Boards"), "")) lista.append((liEng, _("Engines"), "")) lista.append((liAsp, _("Appearance"), "")) lista.append((liSA, _("Autosave"), "")) lista.append((liNC, _("Non competitive mode"), "")) # Editamos resultado = FormLayout.fedit(lista, title=_("Configuration"), parent=parent, anchoMinimo=640, icon=Iconos.Opciones()) if resultado: accion, resp = resultado liGen, liSon, liTT, liT, liEng, liAsp, liSA, liNC = resp (configuracion.jugador, configuracion.estilo, configuracion.traductor, configuracion.checkforupdate) = liGen porDefecto = liAsp[0] if porDefecto: liAsp = "", 11, False, 11, False, QtCore.Qt.ToolButtonTextUnderIcon, 283, 22, 10, False, True, 10 else: del liAsp[0] (configuracion.familia, configuracion.puntosMenu, configuracion.boldMenu, configuracion.puntosTB, configuracion.boldTB, configuracion.iconsTB, configuracion.anchoPGN, configuracion.altoFilaPGN, configuracion.puntosPGN, configuracion.siNomPiezasEN, configuracion.figurinesPGN, configuracion.tamFontRotulos) = liAsp if configuracion.familia == "System": configuracion.familia = "" (configuracion.siSuenaBeep, configuracion.siSuenaResultados, configuracion.siSuenaJugada, configuracion.siSuenaNuestro) = liSon (configuracion.tutor.clave, tiempoTutor, configuracion.tutorMultiPV, configuracion.tutorActivoPorDefecto, configuracion.tutorDifPts, configuracion.tutorDifPorc) = liTT configuracion.tiempoTutor = int(tiempoTutor * 1000) (configuracion.eloNC, configuracion.micheloNC, configuracion.ficsNC, configuracion.fideNC) = liNC (configuracion.centipawns, configuracion.bmi2, configuracion.notbackground) = liEng (configuracion.vistaTutor, configuracion.efectosVisuales, rapidezMovPiezas, configuracion.siAtajosRaton, configuracion.showCandidates, configuracion.showVariantes, configuracion.cursorThinking, configuracion.siActivarCapturas, configuracion.tipoMaterial, configuracion.siActivarInformacion, siDGT, toolIcon, configuracion.positionToolBoard) = liT configuracion.opacityToolBoard = 10 if toolIcon else 1 configuracion.rapidezMovPiezas = drap[rapidezMovPiezas] if configuracion.siDGT != siDGT: if siDGT: DGT.ponON() configuracion.siDGT = siDGT (configuracion.salvarFichero, configuracion.salvarGanados, configuracion.salvarPerdidos, configuracion.salvarAbandonados, configuracion.guardarVariantesTutor, configuracion.salvarCSV) = liSA configuracion.salvarCSV = Util.dirRelativo(configuracion.salvarCSV) return True else: return False