def pgnLabelsAdded(self): d = {} if self.nAjustarFuerza != kAjustarMejor: pers = Personalidades.Personalidades(None, self.configuracion) label = pers.label(self.nAjustarFuerza) if label: d["Strength"] = label return d
def __init__(self, wParent, configuracion, dic, siGestorSolo): super(WCambioRival, self).__init__(wParent) if not dic: dic = {} self.setWindowTitle(_("Change opponent")) self.setWindowIcon(Iconos.Motor()) self.setWindowFlags(QtCore.Qt.WindowCloseButtonHint | QtCore.Qt.Dialog | QtCore.Qt.WindowTitleHint) self.configuracion = configuracion self.personalidades = Personalidades.Personalidades(self, configuracion) # Toolbar li_acciones = [ (_("Accept"), Iconos.Aceptar(), "aceptar"), None, (_("Cancel"), Iconos.Cancelar(), "cancelar"), None, ] tb = Controles.TB(self, li_acciones) # Blancas o negras self.rbBlancas = Controles.RB(self, _("White")).activa() self.rbNegras = Controles.RB(self, _("Black")) # Motores self.motores = SelectEngines.SelectEngines(configuracion) liDepths = [("--", 0)] for x in range(1, 31): liDepths.append((str(x), x)) # # Rival self.rival = configuracion.x_rival_inicial self.rivalTipo = SelectEngines.INTERNO self.btRival = Controles.PB(self, "", self.cambiaRival, plano=False) self.edRtiempo = Controles.ED(self).tipoFloat().anchoMaximo(50) self.cbRdepth = Controles.CB(self, liDepths, 0).capturaCambiado(self.cambiadoDepth) lbTiempoSegundosR = Controles.LB2P(self, _("Time")) lbNivel = Controles.LB2P(self, _("Depth")) # # Ajustar rival liAjustes = self.personalidades.listaAjustes(True) self.cbAjustarRival = Controles.CB(self, liAjustes, ADJUST_BETTER).capturaCambiado(self.ajustesCambiado) lbAjustarRival = Controles.LB2P(self, _("Set strength")) self.btAjustarRival = Controles.PB(self, "", self.cambiaPersonalidades, plano=False).ponIcono( Iconos.Nuevo(), tamIcon=16 ) self.btAjustarRival.ponToolTip(_("Personalities")) # Layout # Color hbox = Colocacion.H().relleno().control(self.rbBlancas).espacio(30).control(self.rbNegras).relleno() gbColor = Controles.GB(self, _("Play with"), hbox) # #Color hAC = Colocacion.H().control(gbColor) # Motores # Rival ly = Colocacion.G() ly.controlc(self.btRival, 0, 0, 1, 4) ly.controld(lbTiempoSegundosR, 1, 0).controld(self.edRtiempo, 1, 1) ly.controld(lbNivel, 1, 2).control(self.cbRdepth, 1, 3) lyH = Colocacion.H().control(lbAjustarRival).control(self.cbAjustarRival).control(self.btAjustarRival).relleno() ly.otroc(lyH, 2, 0, 1, 4) gbR = Controles.GB(self, _("Opponent"), ly) lyResto = Colocacion.V() lyResto.otro(hAC).espacio(3) lyResto.control(gbR).espacio(1) lyResto.margen(8) layout = Colocacion.V().control(tb).otro(lyResto).relleno().margen(3) self.setLayout(layout) self.dic = dic self.recuperaDic() self.ajustesCambiado() self.ponRival()
def __init__(self, procesador, titulo, save_at_end): QTVarios.WDialogo.__init__(self, procesador.main_window, titulo, Iconos.Libre(), "entMaquina") font = Controles.TipoLetra(puntos=procesador.configuracion.x_menu_points) self.save_at_end = save_at_end self.setFont(font) self.configuracion = procesador.configuracion self.procesador = procesador self.personalidades = Personalidades.Personalidades(self, self.configuracion) self.motores = SelectEngines.SelectEngines(self.configuracion) # Toolbar li_acciones = [ (_("Accept"), Iconos.Aceptar(), self.aceptar), None, (_("Cancel"), Iconos.Cancelar(), self.cancelar), None, (_("Configurations"), Iconos.Configurar(), self.configuraciones), None, ] tb = QTVarios.LCTB(self, li_acciones) # Tab tab = Controles.Tab() tab.dispatchChange(self.cambiada_tab) self.tab_advanced = 4 # está en la posición 4 self.tab_advanced_active = ( False ) # Para no tener que leer las opciones uci to_sq que no sean necesarias, afecta a gridNumDatos def nueva_tab(layout, titulo): ly = Colocacion.V() ly.otro(layout) ly.relleno() w = QtWidgets.QWidget(self) w.setLayout(ly) w.setFont(font) tab.nuevaTab(w, titulo) def nuevoG(): ly_g = Colocacion.G() ly_g.filaActual = 0 ly_g.setMargin(10) return ly_g gbStyle = """ QGroupBox { font: bold 16px; background-color: #F2F2EC;/*qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #E0E0E0, stop: 1 #FFFFFF);*/ border: 1px solid gray; border-radius: 3px; padding: 18px; margin-top: 5ex; /* leave space at the top for the title */ } QGroupBox::title { subcontrol-origin: margin; subcontrol-position: top left; /* position at the top center */ padding: 8px; border: 1px solid gray; } """ def _label(ly_g, txt, xlayout, rutinaCHB=None, siCheck: object = False): groupbox = Controles.GB(self, txt, xlayout) if rutinaCHB: groupbox.conectar(rutinaCHB) elif siCheck: groupbox.setCheckable(True) groupbox.setChecked(False) groupbox.setStyleSheet(gbStyle) groupbox.setMinimumWidth(640) groupbox.setFont(font) ly_g.controlc(groupbox, ly_g.filaActual, 0) ly_g.filaActual += 1 return groupbox # ################################################################################################################################## # TAB General # ################################################################################################################################## lyG = nuevoG() # # Motores # ## Rival self.rival = self.procesador.XTutor().confMotor self.rivalTipo = SelectEngines.INTERNO self.btRival = Controles.PB(self, "", self.cambiaRival, plano=False).ponFuente(font).altoFijo(48) lbTiempoSegundosR = Controles.LB2P(self, _("Fixed time in seconds")).ponFuente(font) self.edRtiempo = ( Controles.ED(self).tipoFloat().anchoMaximo(50).ponFuente(font).capturaCambiado(self.cambiadoTiempo) ) bt_cancelar_tiempo = Controles.PB(self, "", rutina=self.cancelar_tiempo).ponIcono(Iconos.S_Cancelar()) ly_tiempo = Colocacion.H().control(self.edRtiempo).control(bt_cancelar_tiempo).relleno(1) lb_depth = Controles.LB2P(self, _("Fixed depth")).ponFuente(font) self.edRdepth = Controles.ED(self).tipoInt().anchoMaximo(50).ponFuente(font).capturaCambiado(self.cambiadoDepth) bt_cancelar_depth = Controles.PB(self, "", rutina=self.cancelar_depth).ponIcono(Iconos.S_Cancelar()) ly_depth = Colocacion.H().control(self.edRdepth).control(bt_cancelar_depth).relleno(1) ly = Colocacion.G() ly.controld(lbTiempoSegundosR, 0, 0).otro(ly_tiempo, 0, 1) ly.controld(lb_depth, 1, 0).otro(ly_depth, 1, 1) self.gb_thinks = Controles.GB(self, _("Limits of engine thinking"), ly) self.gb_thinks.setStyleSheet( """ QGroupBox { font: bold %d; background-color: #F2F2EC;/*qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #E0E0E0, stop: 1 #FFFFFF);*/ border: 1px solid gray; border-radius: 3px; padding: 18px; margin-top: 5ex; /* leave space at the top for the title */ } QGroupBox::title { subcontrol-position: top center; /* position at the top center */ padding: 8px; border: 1px solid gray; } """ % procesador.configuracion.x_menu_points ) lyV = Colocacion.V().espacio(20).control(self.btRival).espacio(20).control(self.gb_thinks) _label(lyG, _("Opponent"), lyV) # # Color self.rbBlancas = Controles.RB(self, "").activa() self.rbBlancas.setIcon(Iconos.PeonBlanco()) self.rbBlancas.setIconSize(QtCore.QSize(32, 32)) self.rbNegras = Controles.RB(self, "") self.rbNegras.setIcon(Iconos.PeonNegro()) self.rbNegras.setIconSize(QtCore.QSize(32, 32)) self.rbRandom = Controles.RB(self, _("Random")) self.rbRandom.setFont(Controles.TipoLetra(puntos=16)) hbox = ( Colocacion.H() .relleno() .control(self.rbBlancas) .espacio(30) .control(self.rbNegras) .espacio(30) .control(self.rbRandom) .relleno() ) _label(lyG, _("Side you play with"), hbox) nueva_tab(lyG, _("Basic configuration")) # ################################################################################################################################## # TAB Ayudas # ################################################################################################################################## self.chbSummary = Controles.CHB( self, _("Save a summary when the game is finished in the main comment"), False ).ponFuente(font) self.chbTakeback = Controles.CHB( self, _("Option takeback activated"), True ).ponFuente(font) # # Tutor lbAyudas = Controles.LB2P(self, _("Available hints")).ponFuente(font) liAyudas = [(_("Maximum"), 999)] for i in range(1, 21): liAyudas.append((str(i), i)) for i in range(25, 51, 5): liAyudas.append((str(i), i)) self.cbAyudas = Controles.CB(self, liAyudas, 999).ponFuente(font) self.chbChance = Controles.CHB(self, _("Second chance"), True).ponFuente(font) btTutorChange = ( Controles.PB(self, _("Tutor change"), self.tutorChange, plano=False) .ponIcono(Iconos.Tutor(), tamIcon=16) .ponFuente(font) ) liThinks = [(_("Nothing"), -1), (_("Score"), 0)] for i in range(1, 5): liThinks.append(("%d %s" % (i, _("ply") if i == 1 else _("plies")), i)) liThinks.append((_("All"), 9999)) lbThoughtTt = Controles.LB(self, _("It is showed") + ":").ponFuente(font) self.cbThoughtTt = Controles.CB(self, liThinks, -1).ponFuente(font) self.chbContinueTt = Controles.CHB(self, _("The tutor thinks while you think"), True).ponFuente(font) lbBoxHeight = Controles.LB2P(self, _("Box height")).ponFuente(font) self.sbBoxHeight = Controles.SB(self, 7, 0, 999).tamMaximo(50).ponFuente(font) lbArrows = Controles.LB2P(self, _("Arrows with the best moves")).ponFuente(font) self.sbArrowsTt = Controles.SB(self, 3, 0, 999).tamMaximo(50).ponFuente(font) lyT1 = Colocacion.H().control(lbAyudas).control(self.cbAyudas).relleno() lyT1.control(self.chbChance).relleno().control(btTutorChange) lyT2 = Colocacion.H().control(self.chbContinueTt).relleno() lyT2.control(lbBoxHeight).control(self.sbBoxHeight).relleno() lyT3 = Colocacion.H().control(lbThoughtTt).control(self.cbThoughtTt).relleno() lyT3.control(lbArrows).control(self.sbArrowsTt) ly = Colocacion.V().otro(lyT1).espacio(16).otro(lyT2).otro(lyT3).relleno() self.gbTutor = Controles.GB(self, _("Activate the tutor's help"), ly) self.gbTutor.setCheckable(True) self.gbTutor.setStyleSheet(gbStyle) lb = Controles.LB(self, _("It is showed") + ":").ponFuente(font) self.cbThoughtOp = Controles.CB(self, liThinks, -1).ponFuente(font) lbArrows = Controles.LB2P(self, _("Arrows to show")).ponFuente(font) self.sbArrows = Controles.SB(self, 7, 0, 999).tamMaximo(50).ponFuente(font) ly = Colocacion.H().control(lb).control(self.cbThoughtOp).relleno() ly.control(lbArrows).control(self.sbArrows).relleno() gbThoughtOp = Controles.GB(self, _("Opponent's thought information"), ly) gbThoughtOp.setStyleSheet(gbStyle) ly = Colocacion.V().espacio(16).control(self.gbTutor).control(gbThoughtOp) ly.espacio(16).control(self.chbSummary).control(self.chbTakeback).margen(6) nueva_tab(ly, _("Help configuration")) # ################################################################################################################################## # TAB Tiempo # ################################################################################################################################## lyG = nuevoG() self.lbMinutos = Controles.LB(self, _("Total minutes") + ":").ponFuente(font) self.edMinutos = Controles.ED(self).tipoFloat(10.0).ponFuente(font).anchoFijo(50) self.edSegundos, self.lbSegundos = QTUtil2.spinBoxLB( self, 6, -999, 999, maxTam=54, etiqueta=_("Seconds added per move"), fuente=font ) self.edMinExtra, self.lbMinExtra = QTUtil2.spinBoxLB( self, 0, -999, 999, maxTam=70, etiqueta=_("Extra minutes for the player"), fuente=font ) self.edZeitnot, self.lbZeitnot = QTUtil2.spinBoxLB( self, 0, -999, 999, maxTam=54, etiqueta=_("Zeitnot: alarm sounds when remaining seconds"), fuente=font ) lyH = Colocacion.H() lyH.control(self.lbMinutos).control(self.edMinutos).espacio(30) lyH.control(self.lbSegundos).control(self.edSegundos).relleno() lyH2 = Colocacion.H() lyH2.control(self.lbMinExtra).control(self.edMinExtra).relleno() lyH3 = Colocacion.H() lyH3.control(self.lbZeitnot).control(self.edZeitnot).relleno() ly = Colocacion.V().otro(lyH).otro(lyH2).otro(lyH3) self.chbTiempo = _label(lyG, _("Activate the time control"), ly, siCheck=True) nueva_tab(lyG, _("Time")) # ################################################################################################################################## # TAB Initial moves # ################################################################################################################################## lyG = nuevoG() # Posicion self.btPosicion = ( Controles.PB(self, " " * 5 + _("Change") + " " * 5, self.posicionEditar).ponPlano(False).ponFuente(font) ) self.fen = "" self.btPosicionQuitar = Controles.PB(self, "", self.posicionQuitar).ponIcono(Iconos.Motor_No()).ponFuente(font) self.btPosicionPegar = ( Controles.PB(self, "", self.posicionPegar).ponIcono(Iconos.Pegar16()).ponToolTip(_("Paste FEN position")) ).ponFuente(font) hbox = ( Colocacion.H() .relleno() .control(self.btPosicionQuitar) .control(self.btPosicion) .control(self.btPosicionPegar) .relleno() ) _label(lyG, _("Start position"), hbox) # Aperturas self.btApertura = ( Controles.PB(self, " " * 5 + _("Undetermined") + " " * 5, self.editarApertura) .ponPlano(False) .ponFuente(font) ) self.bloqueApertura = None self.btAperturasFavoritas = Controles.PB(self, "", self.aperturasFavoritas).ponIcono(Iconos.Favoritos()) self.btAperturasQuitar = Controles.PB(self, "", self.aperturasQuitar).ponIcono(Iconos.Motor_No()) hbox = ( Colocacion.H() .relleno() .control(self.btAperturasQuitar) .control(self.btApertura) .control(self.btAperturasFavoritas) .relleno() ) _label(lyG, _("Opening"), hbox) # Libros fvar = self.configuracion.ficheroBooks self.listaLibros = Books.ListaLibros() self.listaLibros.restore_pickle(fvar) self.listaLibros.comprueba() li_books = [(x.name, x) for x in self.listaLibros.lista] libInicial = li_books[0][1] if li_books else None li_resp_book = [ (_("Selected by the player"), "su"), (_("Uniform random"), "au"), (_("Proportional random"), "ap"), (_("Always the highest percentage"), "mp"), ] ## Rival self.cbBooksR = QTUtil2.comboBoxLB(self, li_books, libInicial).ponFuente(font) self.btNuevoBookR = Controles.PB(self, "", self.nuevoBook, plano=True).ponIcono(Iconos.Mas(), tamIcon=16) self.cbBooksRR = QTUtil2.comboBoxLB(self, li_resp_book, "mp").ponFuente(font) self.lbDepthBookR = Controles.LB2P(self, _("Max depth")).ponFuente(font) self.edDepthBookR = Controles.ED(self).ponFuente(font).tipoInt(0).anchoFijo(30) hbox = ( Colocacion.H() .control(self.cbBooksR) .control(self.btNuevoBookR) .relleno() .control(self.cbBooksRR) .relleno() .control(self.lbDepthBookR) .control(self.edDepthBookR) ) self.chbBookR = _label(lyG, "%s: %s" % (_("Activate book"), _("Opponent")), hbox, siCheck=True) ## Player self.cbBooksP = QTUtil2.comboBoxLB(self, li_books, libInicial).ponFuente(font) self.btNuevoBookP = Controles.PB(self, "", self.nuevoBook, plano=True).ponIcono(Iconos.Mas(), tamIcon=16) self.lbDepthBookP = Controles.LB2P(self, _("Max depth")).ponFuente(font) self.edDepthBookP = Controles.ED(self).ponFuente(font).tipoInt(0).anchoFijo(30) hbox = ( Colocacion.H() .control(self.cbBooksP) .control(self.btNuevoBookP) .relleno() .control(self.lbDepthBookP) .control(self.edDepthBookP) ) self.chbBookP = _label( lyG, "%s: %s" % (_("Activate book"), self.configuracion.nom_player()), hbox, siCheck=True ) nueva_tab(lyG, _("Initial moves")) # ################################################################################################################################## # TAB avanzada # ################################################################################################################################## lyG = nuevoG() liAjustes = self.personalidades.listaAjustes(True) self.cbAjustarRival = ( Controles.CB(self, liAjustes, ADJUST_BETTER).capturaCambiado(self.ajustesCambiado).ponFuente(font) ) lbAjustarRival = Controles.LB2P(self, _("Set strength")).ponFuente(font) self.btAjustarRival = ( Controles.PB(self, _("Personality"), self.cambiaPersonalidades, plano=True) .ponIcono(Iconos.Mas(), tamIcon=16) .ponFuente(font) ) # ## Resign lbResign = Controles.LB2P(self, _("Resign/draw by engine")).ponFuente(font) liResign = ( (_("Very early"), -100), (_("Early"), -300), (_("Average"), -500), (_("Late"), -800), (_("Very late"), -1000), (_("Never"), -9999999), ) self.cbResign = Controles.CB(self, liResign, -800).ponFuente(font) self.lb_path_engine = Controles.LB(self, "").ponWrap() o_columns = Columnas.ListaColumnas() o_columns.nueva("OPTION", _("UCI option"), 240, centered=True) o_columns.nueva("VALUE", _("Value"), 200, centered=True, edicion=Delegados.MultiEditor(self)) self.grid_uci = Grid.Grid(self, o_columns, siEditable=True) self.grid_uci.ponFuente(font) self.register_grid(self.grid_uci) lyH2 = ( Colocacion.H().control(lbAjustarRival).control(self.cbAjustarRival).control(self.btAjustarRival).relleno() ) lyH3 = Colocacion.H().control(lbResign).control(self.cbResign).relleno() ly = Colocacion.V().otro(lyH2).otro(lyH3).espacio(16).control(self.lb_path_engine).control(self.grid_uci) _label(lyG, _("Opponent"), ly) nueva_tab(lyG, _("Advanced")) layout = Colocacion.V().control(tb).control(tab).relleno().margen(3) self.setLayout(layout) self.liAperturasFavoritas = [] self.btAperturasFavoritas.hide() dic = Util.restore_pickle(self.configuracion.ficheroEntMaquina) if not dic: dic = {} self.restore_dic(dic) self.ajustesCambiado() # self.ayudasCambiado() self.ponRival() self.restore_video()
def __init__(self, procesador, titulo): QTVarios.WDialogo.__init__(self, procesador.pantalla, titulo, Iconos.Libre(), "entMaquina") self.configuracion = procesador.configuracion self.procesador = procesador self.personalidades = Personalidades.Personalidades( self, self.configuracion) self.motores = Motores.Motores(self.configuracion) # Toolbar liAcciones = [ (_("Accept"), Iconos.Aceptar(), self.aceptar), None, (_("Cancel"), Iconos.Cancelar(), self.cancelar), None, (_("Configurations"), Iconos.Configurar(), self.configuraciones), None, ] tb = Controles.TBrutina(self, liAcciones) # Tab tab = Controles.Tab() def nuevoG(): lyG = Colocacion.G() lyG.filaActual = 0 return lyG gbStyle = """ QGroupBox { font: bold 16px; background-color: #F2F2EC;/*qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #E0E0E0, stop: 1 #FFFFFF);*/ border: 1px solid gray; border-radius: 3px; margin-top: 5ex; /* leave space at the top for the title */ } QGroupBox::title { subcontrol-origin: margin; subcontrol-position: top center; /* position at the top center */ padding: 0 3px; } """ def _label(lyG, txt, ly, rutinaCHB=None, siCheck=False): gb = Controles.GB(self, txt, ly) if rutinaCHB: gb.conectar(rutinaCHB) elif siCheck: gb.setCheckable(True) gb.setChecked(False) gb.setStyleSheet(gbStyle) lyG.controlc(gb, lyG.filaActual, 0) lyG.filaActual += 1 return gb # TAB General lyG = nuevoG() # Blancas o negras self.rbBlancas = Controles.RB(self, "").activa() self.rbBlancas.setIcon( QTVarios.fsvg2ico("Pieces/Chessicons/wp.svg", 64)) self.rbNegras = Controles.RB(self, "") self.rbNegras.setIcon(QTVarios.fsvg2ico("Pieces/Chessicons/bp.svg", 64)) self.rbRandom = Controles.RB(self, _("Random")) hbox = Colocacion.H().relleno().control( self.rbBlancas).espacio(30).control( self.rbNegras).espacio(30).control(self.rbRandom).relleno() _label(lyG, _("Select color"), hbox) # Motores liDepths = [("--", 0)] for x in range(1, 31): liDepths.append((str(x), x)) # # Rival self.rival = self.configuracion.rivalInicial self.rivalTipo = Motores.INTERNO self.btRival = Controles.PB(self, "", self.cambiaRival, plano=False) self.edRtiempo = Controles.ED(self).tipoFloat().anchoMaximo(50) self.cbRdepth = Controles.CB(self, liDepths, 0).capturaCambiado(self.cambiadoDepth) lbTiempoSegundosR = Controles.LB2P(self, _("Time")) lbNivel = Controles.LB2P(self, _("Depth")) # # Ajustar rival liAjustes = self.personalidades.listaAjustes(True) self.cbAjustarRival = Controles.CB(self, liAjustes, kAjustarMejor).capturaCambiado( self.ajustesCambiado) lbAjustarRival = Controles.LB2P(self, _("Set strength")) btAjustarRival = Controles.PB(self, _("Personality"), self.cambiaPersonalidades, plano=True).ponIcono(Iconos.Mas(), tamIcon=16) # Resign lbResign = Controles.LB2P(self, _("Resign/draw by engine")) liResign = ((_("Very early"), -100), (_("Early"), -300), (_("Average"), -500), (_("Late"), -800), (_("Very late"), -1000), (_("Never"), -9999999)) self.cbResign = Controles.CB(self, liResign, -800) lyH1 = Colocacion.H().control(self.btRival).espacio(20) lyH1.control(lbTiempoSegundosR).control(self.edRtiempo) lyH1.control(lbNivel).control(self.cbRdepth).relleno() lyH2 = Colocacion.H().control(lbAjustarRival).control( self.cbAjustarRival).control(btAjustarRival).relleno() lyH3 = Colocacion.H().control(lbResign).control( self.cbResign).relleno() ly = Colocacion.V().otro(lyH1).otro(lyH2).otro(lyH3) _label(lyG, _("Opponent"), ly) gb = Controles.GB(self, "", lyG) tab.nuevaTab(gb, _("Basic configuration")) # TAB Ayudas lbAyudas = Controles.LB2P(self, _("Available hints")) self.sbAyudas = Controles.SB(self, 7, 0, 999).tamMaximo(50) self.cbAtras = Controles.CHB(self, _("Takeback"), True) self.cbChance = Controles.CHB(self, _("Second chance"), True) btTutorChange = Controles.PB(self, _("Tutor change"), self.tutorChange, plano=False).ponIcono(Iconos.Tutor(), tamIcon=16) liThinks = [(_("Nothing"), -1), (_("Score"), 0)] for i in range(1, 5): liThinks.append( ("%d %s" % (i, _("ply") if i == 1 else _("plies")), i)) liThinks.append((_("All"), 9999)) lb = Controles.LB(self, _("It is showed") + ":") self.cbThoughtTt = Controles.CB(self, liThinks, -1) self.cbContinueTt = Controles.CHB( self, _("The tutor thinks while you think"), True) lbBoxHeight = Controles.LB2P(self, _("Box height")) self.sbBoxHeight = Controles.SB(self, 7, 0, 999).tamMaximo(50) ly1 = Colocacion.H().control(lb).control(self.cbThoughtTt).relleno() ly2 = Colocacion.H().control(lbBoxHeight).control( self.sbBoxHeight).relleno() ly = Colocacion.V().otro(ly1).control( self.cbContinueTt).espacio(16).otro(ly2).relleno() gbThoughtTt = Controles.GB(self, _("Thought of the tutor"), ly) gbThoughtTt.setStyleSheet(gbStyle) lb = Controles.LB(self, _("It is showed") + ":") self.cbThoughtOp = Controles.CB(self, liThinks, -1) lbArrows = Controles.LB2P(self, _("Arrows to show")) self.sbArrows = Controles.SB(self, 7, 0, 999).tamMaximo(50) ly1 = Colocacion.H().control(lb).control(self.cbThoughtOp).relleno() ly2 = Colocacion.H().control(lbArrows).control(self.sbArrows).relleno() ly = Colocacion.V().otro(ly1).otro(ly2).relleno() gbThoughtOp = Controles.GB(self, _("Thought of the opponent"), ly) gbThoughtOp.setStyleSheet(gbStyle) self.chbSummary = Controles.CHB( self, _("Save a summary when the game is finished in the main comment"), False) lyH1 = Colocacion.H().relleno() lyH1.control(lbAyudas).control(self.sbAyudas).relleno() lyH1.control(self.cbAtras).relleno() lyH1.control(self.cbChance).relleno() lyH1.control(btTutorChange).relleno() # lyV1 = Colocacion.V().control(gbThoughtOp) lyH3 = Colocacion.H().relleno() lyH3.control(gbThoughtOp).relleno() lyH3.control(gbThoughtTt).relleno() ly = Colocacion.V().otro(lyH1).otro(lyH3).control( self.chbSummary).margen(16) gb = Controles.GB(self, "", ly) tab.nuevaTab(gb, _("Help configuration")) # TAB Tiempo lyG = nuevoG() self.edMinutos, self.lbMinutos = QTUtil2.spinBoxLB( self, 15, 0, 999, maxTam=50, etiqueta=_("Total minutes")) self.edSegundos, self.lbSegundos = QTUtil2.spinBoxLB( self, 6, -999, 999, maxTam=54, etiqueta=_("Seconds added per move")) self.edMinExtra, self.lbMinExtra = QTUtil2.spinBoxLB( self, 0, -999, 999, maxTam=70, etiqueta=_("Extra minutes for the player")) self.edZeitnot, self.lbZeitnot = QTUtil2.spinBoxLB( self, 0, -999, 999, maxTam=54, etiqueta=_("Zeitnot: alarm sounds when remaining seconds")) lyH1 = Colocacion.H() lyH1.control(self.lbMinutos).control(self.edMinutos).espacio(30) lyH1.control(self.lbSegundos).control(self.edSegundos).relleno() lyH2 = Colocacion.H() lyH2.control(self.lbMinExtra).control(self.edMinExtra).relleno() lyH3 = Colocacion.H() lyH3.control(self.lbZeitnot).control(self.edZeitnot).relleno() ly = Colocacion.V().otro(lyH1).otro(lyH2).otro(lyH3) self.chbTiempo = _label(lyG, _("Time"), ly, siCheck=True) gb = Controles.GB(self, "", lyG) tab.nuevaTab(gb, _("Time")) # TAB Initial moves lyG = nuevoG() # Posicion self.btPosicion = Controles.PB(self, " " * 5 + _("Change") + " " * 5, self.posicionEditar).ponPlano(False) self.fen = "" self.btPosicionQuitar = Controles.PB( self, "", self.posicionQuitar).ponIcono(Iconos.Motor_No()) self.btPosicionPegar = Controles.PB(self, "", self.posicionPegar).ponIcono( Iconos.Pegar16()).ponToolTip( _("Paste FEN position")) hbox = Colocacion.H().relleno().control(self.btPosicionQuitar).control( self.btPosicion).control(self.btPosicionPegar).relleno() _label(lyG, _("Start position"), hbox) # Aperturas self.btApertura = Controles.PB(self, " " * 5 + _("Undetermined") + " " * 5, self.editarApertura).ponPlano(False) self.bloqueApertura = None self.btAperturasFavoritas = Controles.PB( self, "", self.aperturasFavoritas).ponIcono(Iconos.Favoritos()) self.btAperturasQuitar = Controles.PB( self, "", self.aperturasQuitar).ponIcono(Iconos.Motor_No()) hbox = Colocacion.H().relleno().control( self.btAperturasQuitar).control(self.btApertura).control( self.btAperturasFavoritas).relleno() _label(lyG, _("Opening"), hbox) # Libros fvar = self.configuracion.ficheroBooks self.listaLibros = Books.ListaLibros() self.listaLibros.recuperaVar(fvar) # Comprobamos que todos esten accesibles self.listaLibros.comprueba() li = [(x.nombre, x) for x in self.listaLibros.lista] libInicial = li[0][1] if li else None self.cbBooks = QTUtil2.comboBoxLB(self, li, libInicial) self.btNuevoBook = Controles.PB(self, "", self.nuevoBook, plano=True).ponIcono(Iconos.Mas(), tamIcon=16) self.chbBookMandatory = Controles.CHB(self, _("Mandatory"), False) # Respuesta rival li = ( (_("Selected by the player"), "su"), (_("Uniform random"), "au"), (_("Proportional random"), "ap"), (_("Always the highest percentage"), "mp"), ) self.cbBooksRR = QTUtil2.comboBoxLB(self, li, "mp") self.lbBooksRR = Controles.LB2P(self, _("Opponent's move")) hbox = Colocacion.H().relleno().control(self.cbBooks).control( self.btNuevoBook).control(self.chbBookMandatory).relleno() hboxRR = Colocacion.H().relleno().control(self.lbBooksRR).control( self.cbBooksRR).relleno() hboxV = Colocacion.V().otro(hbox).otro(hboxRR) self.chbBook = _label(lyG, _("Book"), hboxV, siCheck=True) ly = Colocacion.V().otro(lyG).relleno() gb = Controles.GB(self, "", ly) tab.nuevaTab(gb, _("Initial moves")) layout = Colocacion.V().control(tb).control(tab).relleno().margen(3) self.setLayout(layout) self.liAperturasFavoritas = [] self.btAperturasFavoritas.hide() dic = Util.recuperaDIC(self.configuracion.ficheroEntMaquina) if not dic: dic = {} self.muestraDic(dic) self.ajustesCambiado() # self.ayudasCambiado() self.ponRival() self.recuperarVideo()
def base_inicio(self, dic_var): self.reinicio = dic_var self.cache = dic_var.get("cache", {}) self.game_type = GT_AGAINST_ENGINE self.human_is_playing = False self.plays_instead_of_me_option = True self.state = ST_PLAYING self.is_analyzing = False self.summary = { } # numJugada : "a"ccepted, "s"ame, "r"ejected, dif points, time used self.with_summary = dic_var.get("SUMMARY", False) is_white = dic_var["ISWHITE"] self.is_human_side_white = is_white self.is_engine_side_white = not is_white self.conf_engine = dic_var["RIVAL"].get("CM", None) self.lirm_engine = [] self.next_test_resign = 0 self.resign_limit = -99999 # never self.aperturaObl = self.aperturaStd = None self.fen = dic_var["FEN"] if self.fen: cp = Position.Position() cp.read_fen(self.fen) self.game.set_position(cp) self.game.pending_opening = False else: if dic_var["OPENING"]: self.aperturaObl = Apertura.JuegaApertura( dic_var["OPENING"].a1h8) self.primeroBook = False # la opening es obligatoria self.bookR = dic_var.get("BOOKR", None) if self.bookR: self.bookRdepth = dic_var.get("BOOKRDEPTH", 0) self.bookR.polyglot() self.bookRR = dic_var.get("BOOKRR", "mp") elif dic_var["RIVAL"].get("TIPO", None) in (SelectEngines.MICGM, SelectEngines.MICPER): if self.conf_engine.book: self.bookR = Books.Libro("P", self.conf_engine.book, self.conf_engine.book, True) self.bookR.polyglot() self.bookRR = "mp" self.bookRdepth = 0 self.bookP = dic_var.get("BOOKP", None) if self.bookP: self.bookPdepth = dic_var.get("BOOKPDEPTH", 0) self.bookP.polyglot() self.is_tutor_enabled = ( Code.dgtDispatch is None) and self.configuracion.x_default_tutor_active self.main_window.ponActivarTutor(self.is_tutor_enabled) self.ayudas = dic_var["HINTS"] self.ayudas_iniciales = self.ayudas # Se guarda para guardar el PGN self.nArrows = dic_var.get("ARROWS", 0) n_box_height = dic_var.get("BOXHEIGHT", 24) self.thoughtOp = dic_var.get("THOUGHTOP", -1) self.thoughtTt = dic_var.get("THOUGHTTT", -1) self.continueTt = dic_var.get("CONTINUETT", False) self.nArrowsTt = dic_var.get("ARROWSTT", 0) self.chance = dic_var.get("2CHANCE", True) if self.nArrowsTt != 0 and self.ayudas == 0: self.nArrowsTt = 0 self.with_takeback = dic_var.get("TAKEBACK", True) self.tutor_con_flechas = self.nArrowsTt > 0 and self.ayudas > 0 self.tutor_book = Books.BookGame(Code.tbook) mx = max(self.thoughtOp, self.thoughtTt) if mx > -1: self.alturaRotulo3(n_box_height) dr = dic_var["RIVAL"] rival = dr["CM"] if dr["TYPE"] == SelectEngines.ELO: r_t = 0 r_p = rival.fixed_depth self.nAjustarFuerza = ADJUST_BETTER else: r_t = dr["ENGINE_TIME"] * 100 # Se guarda en decimas -> milesimas r_p = dr["ENGINE_DEPTH"] self.nAjustarFuerza = dic_var.get("AJUSTAR", ADJUST_BETTER) if not self.xrival: # reiniciando is not None if r_t <= 0: r_t = None if r_p <= 0: r_p = None if r_t is None and r_p is None and not dic_var["WITHTIME"]: r_t = 1000 self.xrival = self.procesador.creaGestorMotor( rival, r_t, r_p, self.nAjustarFuerza != ADJUST_BETTER) if self.nAjustarFuerza != ADJUST_BETTER: self.xrival.maximizaMultiPV() self.resign_limit = dic_var["RESIGN"] self.game.add_tag("Event", _("Play against an engine")) player = self.configuracion.nom_player() other = self.xrival.name w, b = (player, other) if self.is_human_side_white else (other, player) self.game.add_tag("White", w) self.game.add_tag("Black", b) self.siBookAjustarFuerza = self.nAjustarFuerza != ADJUST_BETTER self.xrival.is_white = self.is_engine_side_white self.siTiempo = dic_var["WITHTIME"] if self.siTiempo: self.maxSegundos = dic_var["MINUTES"] * 60.0 self.segundosJugada = dic_var["SECONDS"] self.segExtra = dic_var.get("MINEXTRA", 0) * 60.0 self.zeitnot = dic_var.get("ZEITNOT", 0) self.vtime = { WHITE: Util.Timer(self.maxSegundos), BLACK: Util.Timer(self.maxSegundos) } if self.segExtra: self.vtime[self.is_human_side_white].ponSegExtra(self.segExtra) time_control = "%d" % int(self.maxSegundos) if self.segundosJugada: time_control += "+%d" % self.segundosJugada self.game.add_tag("TimeControl", time_control) if self.segExtra: self.game.add_tag( "TimeExtra" + "White" if self.is_human_side_white else "Black", "%d" % self.segExtra) self.pon_toolbar() self.main_window.activaJuego(True, self.siTiempo) self.set_dispatcher(self.mueve_humano) self.setposition(self.game.last_position) self.mostrarIndicador(True) if self.ayudas_iniciales: self.ponAyudasEM() else: self.quitaAyudas(siQuitarAtras=False) self.ponPiezasAbajo(is_white) self.ponRotuloBasico() self.ponRotulo2("") if self.nAjustarFuerza != ADJUST_BETTER: pers = Personalidades.Personalidades(None, self.configuracion) label = pers.label(self.nAjustarFuerza) if label: self.game.add_tag("Strength", label) self.ponCapInfoPorDefecto() self.pgnRefresh(True) rival = self.xrival.name player = self.configuracion.x_player bl, ng = player, rival if self.is_engine_side_white: bl, ng = ng, bl active_clock = max(self.thoughtOp, self.thoughtTt) > -1 if self.siTiempo: tp_bl = self.vtime[True].etiqueta() tp_ng = self.vtime[False].etiqueta() self.main_window.ponDatosReloj(bl, tp_bl, ng, tp_ng) active_clock = True self.refresh() else: self.main_window.base.change_player_labels(bl, ng) if active_clock: self.main_window.start_clock(self.set_clock, 400) self.main_window.set_notify(self.mueve_rival_base) self.is_analyzed_by_tutor = False self.dgt_setposition()