def inicio(self, recno, siBlancas): db = PantallaPlayPGN.PlayPGNs(self.configuracion.ficheroPlayPGN) reg = db.leeRegistro(recno) partidaObj = Partida.Partida() partidaObj.recuperaDeTexto(reg["PARTIDA"]) nombreObj = reg.get("WHITE" if siBlancas else "BLACK", _("Player")) rotulo = db.rotulo(recno) db.close() self.recno = recno self.siCompetitivo = False self.resultado = None self.siJuegaHumano = False self.analisis = None self.comentario = None self.siAnalizando = False self.siJugamosConBlancas = siBlancas self.siRivalConBlancas = not siBlancas self.numJugadasObj = partidaObj.numJugadas() self.partidaObj = partidaObj self.posJugadaObj = 0 self.nombreObj = nombreObj self.siSave = False self.minTiempo = 5000 self.xanalyzer.maximizaMultiPV() self.puntosMax = 0 self.puntos = 0 self.tiempo = 0.0 self.book = Apertura.AperturaPol(999) self.pantalla.ponToolBar( (k_cancelar, k_reiniciar, k_configurar, k_utilidades)) self.pantalla.activaJuego(True, False, siAyudas=False) self.quitaAyudas(True, True) self.ponMensajero(self.mueveHumano) self.ponPosicion(self.partida.ultPosicion) self.ponPiezasAbajo(self.siJugamosConBlancas) self.mostrarIndicador(True) self.ponRotulo1(rotulo) self.ponRotulo2("") self.pgnRefresh(True) self.ponCapInfoPorDefecto() self.ponPosicionDGT() self.estado = kJugando self.siguienteJugada()
def atras(self): if self.partida.numJugadas(): self.partida.anulaUltimoMovimiento(self.siJugamosConBlancas) self.listaAperturasStd.asignaApertura(self.partida) self.ponteAlFinal() self.apertura = Apertura.AperturaPol(30, self.engine.elo) self.siAnalizadoTutor = False self.addHint() self.addTime() self.refresh() self.siguienteJugada()
def inicio(self, dbwashing, washing, engine): self.dbwashing = dbwashing self.washing = washing self.engine = engine self.dbwashing.addGame() self.tipoJuego = kJugWashingReplay self.timekeeper = Util.Timekeeper() self.siJuegaHumano = False self.siTutorActivado = False self.pantalla.ponActivarTutor(False) self.ayudasPGN = 0 self.pantalla.activaJuego(True, False, siAyudas=False) self.pantalla.quitaAyudas(True, True) self.ponMensajero(self.mueveHumano) self.mostrarIndicador(True) self.partidaObj = self.dbwashing.restoreGame(self.engine) self.numJugadasObj = self.partidaObj.numJugadas() self.posJugadaObj = 0 liOpciones = [k_mainmenu] self.pantalla.ponToolBar(liOpciones) self.errores = 0 self.book = Apertura.AperturaPol(999, elo=engine.elo) siBlancas = self.engine.color self.siJugamosConBlancas = siBlancas self.siRivalConBlancas = not siBlancas self.ponPosicion(self.partida.ultPosicion) self.ponPiezasAbajo(siBlancas) self.ponRotulo1( "%s: %s\n%s: %s" % (_("Rival"), self.engine.nombre, _("Task"), self.engine.lbState())) self.pgnRefresh(True) self.partida.pendienteApertura = True QTUtil.xrefreshGUI() self.ponPosicionDGT() self.estado = kJugando self.siguienteJugada()
def atras(self): if len(self.game): self.analizaTerminar() self.game.anulaUltimoMovimiento(self.is_human_side_white) self.game.assign_opening() self.goto_end() self.opening = Apertura.AperturaPol(30, self.engine.elo) self.is_analyzed_by_tutor = False self.add_hint() self.add_time() self.refresh() self.siguiente_jugada()
def inicio(self, recno, is_white): db = PantallaPlayGame.DBPlayGame(self.configuracion.file_play_game()) reg = db.leeRegistro(recno) partidaObj = Game.Game() partidaObj.restore(reg["GAME"]) nombreObj = partidaObj.get_tag("WHITE" if is_white else "BLACK") rotulo = db.rotulo(recno) db.close() self.recno = recno self.resultado = None self.human_is_playing = False self.analysis = None self.comment = None self.siAnalizando = False self.is_human_side_white = is_white self.is_engine_side_white = not is_white self.numJugadasObj = partidaObj.num_moves() self.partidaObj = partidaObj self.posJugadaObj = 0 self.nombreObj = nombreObj self.siSave = False self.minTiempo = 5000 self.xanalyzer.maximizaMultiPV() self.puntosMax = 0 self.puntos = 0 self.vtime = 0.0 self.book = Apertura.AperturaPol(999) self.main_window.pon_toolbar((TB_CANCEL, TB_REINIT, TB_CONFIG, TB_UTILITIES)) self.main_window.activaJuego(True, False, siAyudas=False) self.quitaAyudas(True, True) self.set_dispatcher(self.mueve_humano) self.setposition(self.game.last_position) self.ponPiezasAbajo(self.is_human_side_white) self.mostrarIndicador(True) self.ponRotulo1(rotulo) self.ponRotulo2("") self.pgnRefresh(True) self.ponCapInfoPorDefecto() self.dgt_setposition() self.state = ST_PLAYING self.siguiente_jugada()
def base_inicio(self, id_game): self.resultado = None self.human_is_playing = False self.state = ST_PLAYING self.analysis = None self.comment = None self.siAnalizando = False self.siCompetitivo = True self.read_id(id_game) self.id_game = id_game self.eloObj = int( self.game.get_tag( "WhiteElo" if self.is_human_side_white else "BlackElo")) self.eloUsu = self._activo() self.pwin = Util.fideELO(self.eloUsu, self.eloObj, +1) self.pdraw = Util.fideELO(self.eloUsu, self.eloObj, 0) self.plost = Util.fideELO(self.eloUsu, self.eloObj, -1) self.puntos = 0 self.is_tutor_enabled = False self.main_window.ponActivarTutor(self.is_tutor_enabled) self.ayudas = 0 self.ayudas_iniciales = 0 self.xtutor.maximizaMultiPV() self.book = Apertura.AperturaPol(999) self.pon_toolbar() self.main_window.activaJuego(True, False, siAyudas=False) self.set_dispatcher(self.mueve_humano) self.setposition(self.game.last_position) self.ponPiezasAbajo(self.is_human_side_white) self.quitaAyudas(True, siQuitarAtras=True) self.mostrarIndicador(True) rotulo = "%s: <b>%d</b> | %s: <b>%d</b>" % ( self._titulo, self.eloUsu, _("Elo rival"), self.eloObj) rotulo += " | %+d %+d %+d" % (self.pwin, self.pdraw, self.plost) self.ponRotulo1(rotulo) self.ponRotulo2("") self.pgnRefresh(True) self.ponCapInfoPorDefecto() self.dgt_setposition()
def inicio(self, dbwashing, washing, engine): self.dbwashing = dbwashing self.washing = washing self.engine = engine self.dbwashing.add_game() self.game_type = GT_WASHING_REPLAY self.human_is_playing = False self.is_tutor_enabled = False self.main_window.ponActivarTutor(False) self.ayudas_iniciales = 0 self.main_window.activaJuego(True, False, siAyudas=False) self.main_window.quitaAyudas(True, True) self.set_dispatcher(self.mueve_humano) self.mostrarIndicador(True) self.partidaObj = self.dbwashing.restoreGame(self.engine) self.numJugadasObj = self.partidaObj.num_moves() self.posJugadaObj = 0 li_options = [TB_CLOSE] self.main_window.pon_toolbar(li_options) self.errores = 0 self.book = Apertura.AperturaPol(999, elo=engine.elo) is_white = self.engine.color self.is_human_side_white = is_white self.is_engine_side_white = not is_white self.setposition(self.game.last_position) self.ponPiezasAbajo(is_white) self.ponRotulo1( "%s: %s\n%s: %s" % (_("Rival"), self.engine.name, _("Task"), self.engine.lbState())) self.pgnRefresh(True) self.game.pending_opening = True QTUtil.refresh_gui() self.dgt_setposition() self.state = ST_PLAYING self.siguiente_jugada()
def reiniciar(self): self.partida.reset() self.posJugadaObj = 0 self.puntos = 0 self.ponPuntos() self.tiempo = 0.0 self.book = Apertura.AperturaPol(999) self.estado = kJugando self.tablero.ponPosicion(self.partida.iniPosicion) self.pgnRefresh(True) self.ponPosicionDGT() self.analizaFinal() self.ponRotulo1(self.expedition.label()) self.ponPuntos() self.siguienteJugada()
def inicio(self, recno): self.expedition = Everest.Expedition(self.configuracion, recno) self.expedition.run() self.dic_analysis = {} self.siCompetitivo = True self.resultado = None self.human_is_playing = False self.analysis = None self.comment = None self.siAnalizando = False self.is_human_side_white = self.expedition.is_white self.is_engine_side_white = not self.expedition.is_white self.partidaObj = self.expedition.game self.game.set_tags(self.partidaObj.li_tags) self.numJugadasObj = self.partidaObj.num_moves() self.posJugadaObj = 0 self.nombreObj = self.expedition.name self.xanalyzer.maximizaMultiPV() self.puntos = 0 self.vtime = 0.0 self.book = Apertura.AperturaPol(999) self.main_window.pon_toolbar((TB_CANCEL, TB_REINIT, TB_CONFIG)) self.main_window.activaJuego(True, False, siAyudas=False) self.quitaAyudas(True, True) self.set_dispatcher(self.mueve_humano) self.setposition(self.game.last_position) self.ponPiezasAbajo(self.is_human_side_white) self.mostrarIndicador(True) self.ponRotulo1(self.expedition.label()) self.ponRotulo2("") self.pgnRefresh(True) self.ponCapInfoPorDefecto() self.dgt_setposition() self.state = ST_PLAYING self.siguiente_jugada()
def reiniciar(self): self.game.set_position() self.posJugadaObj = 0 self.puntos = 0 self.ponPuntos() self.vtime = 0.0 self.book = Apertura.AperturaPol(999) self.state = ST_PLAYING self.tablero.setposition(self.game.first_position) self.pgnRefresh(True) self.dgt_setposition() self.analizaFinal() self.terminaNoContinuo() self.ponRotulo1(self.expedition.label()) self.ponPuntos() self.siguiente_jugada()
def inicio(self, recno): self.expedition = Everest.Expedition(self.configuracion, recno) self.expedition.run() self.dic_analysis = {} self.siCompetitivo = True self.resultado = None self.siJuegaHumano = False self.analisis = None self.comentario = None self.siAnalizando = False self.siJugamosConBlancas = self.expedition.is_white self.siRivalConBlancas = not self.expedition.is_white self.partidaObj = self.expedition.partida self.numJugadasObj = self.partidaObj.numJugadas() self.posJugadaObj = 0 self.nombreObj = self.expedition.nombre self.xanalyzer.maximizaMultiPV() self.puntos = 0 self.tiempo = 0.0 self.book = Apertura.AperturaPol(999) self.pantalla.ponToolBar((k_cancelar, k_reiniciar, k_configurar)) self.pantalla.activaJuego(True, False, siAyudas=False) self.quitaAyudas(True, True) self.ponMensajero(self.mueveHumano) self.ponPosicion(self.partida.ultPosicion) self.ponPiezasAbajo(self.siJugamosConBlancas) self.mostrarIndicador(True) self.ponRotulo1(self.expedition.label()) self.ponRotulo2("") self.pgnRefresh(True) self.ponCapInfoPorDefecto() self.ponPosicionDGT() self.estado = kJugando self.siguienteJugada()
def reiniciar(self, siPregunta): if siPregunta: if not QTUtil2.pregunta(self.pantalla, _("Restart the game?")): return self.partida.reset() self.posJugadaObj = 0 self.puntos = 0 self.ponPuntos() self.tiempo = 0.0 self.book = Apertura.AperturaPol(999) self.estado = kJugando self.tablero.ponPosicion(self.partida.iniPosicion) self.pgnRefresh(True) self.ponPosicionDGT() self.analizaFinal() self.siguienteJugada()
def reiniciar(self, siPregunta): if siPregunta: if not QTUtil2.pregunta(self.main_window, _("Restart the game?")): return self.game.set_position() self.posJugadaObj = 0 self.puntos = 0 self.puntosMax = 0 self.ponPuntos() self.vtime = 0.0 self.book = Apertura.AperturaPol(999) self.state = ST_PLAYING self.tablero.setposition(self.game.first_position) self.pgnRefresh(True) self.dgt_setposition() self.analizaFinal() self.siguiente_jugada()
def calc_elos(self, configuracion): for jg in self.liJugadas: jg.siBook = False if self.siFenInicial(): from Code import Apertura ap = Apertura.AperturaPol(999) for jg in self.liJugadas: jg.siBook = ap.compruebaHumano(jg.posicionBase.fen(), jg.desde, jg.hasta) if not jg.siBook: break elos = {} for siBlancas in (True, False): elos[siBlancas] = self.calc_elo_color(configuracion.perfomance, siBlancas) elos[None] = {} for std in (OPENING, MIDDLEGAME, ENDGAME, ALLGAME): elos[None][std] = int((elos[True][std] + elos[False][std])/2.0) return elos
def calc_elosFORM(self, configuracion): for move in self.li_moves: move.siBook = False if self.siFenInicial(): from Code import Apertura ap = Apertura.AperturaPol(999) for move in self.li_moves: move.siBook = ap.check_human(move.position_before.fen(), move.from_sq, move.to_sq) if not move.siBook: break elos = {} for is_white in (True, False): elos[is_white] = self.calc_elo_colorFORM(configuracion.perfomance, is_white) elos[None] = {} for std in (OPENING, MIDDLEGAME, ENDGAME, ALLGAME): elos[None][std] = int((elos[True][std] + elos[False][std]) / 2.0) return elos
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()
def inicio(self, idGame, siCompetitivo, aplazamiento=None): self.siCompetitivo = siCompetitivo self.resultado = None self.siJuegaHumano = False self.estado = kJugando self.analisis = None self.comentario = None self.siAnalizando = False if aplazamiento: idGame = aplazamiento["IDGAME"] self.siCompetitivo = aplazamiento["SICOMPETITIVO"] self.readID(idGame) self.idGame = idGame self.eloObj = int(self.cabs["WhiteElo" if self.siJugamosConBlancas else "BlackElo"]) self.eloUsu = self._activo(self.siCompetitivo) self.pwin = Util.fideELO(self.eloUsu, self.eloObj, +1) self.pdraw = Util.fideELO(self.eloUsu, self.eloObj, 0) self.plost = Util.fideELO(self.eloUsu, self.eloObj, -1) self.puntos = 0 if aplazamiento: self.posJugadaObj = aplazamiento["POSJUGADAOBJ"] self.puntos = aplazamiento["PUNTOS"] self.siTutorActivado = False self.pantalla.ponActivarTutor(self.siTutorActivado) self.ayudas = 0 self.ayudasPGN = 0 # tutor = self.configuracion.buscaRival("stockfish") # self.xtutor = self.procesador.creaGestorMotor(tutor, None, None) # self.xtutor.maximizaactMultiPV(500) # -Aplazamiento 1/2-------------------------------------------------- if aplazamiento: self.partida.recuperaDeTexto(aplazamiento["JUGADAS"]) self.partida.pendienteApertura = aplazamiento["PENDIENTEAPERTURA"] self.partida.apertura = None if aplazamiento["APERTURA"] is None else self.listaAperturasStd.dic[ aplazamiento["APERTURA"]] self.book = Apertura.AperturaPol(999) self.ponToolBar() self.pantalla.activaJuego(True, False, siAyudas=False) self.ponMensajero(self.mueveHumano) self.ponPosicion(self.partida.ultPosicion) self.ponPiezasAbajo(self.siJugamosConBlancas) self.quitaAyudas(True, siQuitarAtras=siCompetitivo) self.mostrarIndicador(True) rotulo = "%s: <b>%d</b> | %s: <b>%d</b>" % (self._titulo, self.eloUsu, _("Elo rival"), self.eloObj) rotulo += " | %+d %+d %+d" % (self.pwin, self.pdraw, self.plost) self.ponRotulo1(rotulo) self.ponRotulo2("") self.pgnRefresh(True) self.ponCapInfoPorDefecto() # -Aplazamiento 2/2-------------------------------------------------- if aplazamiento: self.mueveJugada(kMoverFinal) self.ponPuntos() self.ponPosicionDGT() self.siguienteJugada()
def inicio(self, categoria, nivel, siBlancas, puntos, aplazamiento=None): self.tipoJuego = kJugNueva self.liReiniciar = categoria, nivel, siBlancas self.resultado = None self.siJuegaHumano = False self.estado = kJugando self.siCompetitivo = True self.siJuegaPorMi = True self.siJugamosConBlancas = siBlancas self.siRivalConBlancas = not siBlancas self.rmRival = None self.categoria = categoria self.nivelJugado = nivel self.puntos = puntos self.siTutorActivado = (VarGen.dgtDispatch is None ) and self.configuracion.tutorActivoPorDefecto self.pantalla.ponActivarTutor(self.siTutorActivado) self.ayudas = categoria.ayudas self.ayudasPGN = self.ayudas # Se guarda para guardar el PGN self.siApertura = True self.apertura = Apertura.AperturaPol(nivel) # lee las aperturas self.xrival = self.procesador.creaGestorMotor(self.configuracion.rival, None, nivel) # -Aplazamiento 1/2-------------------------------------------------- if aplazamiento: self.partida.recuperaDeTexto(aplazamiento["JUGADAS"]) self.siApertura = aplazamiento["SIAPERTURA"] self.partida.pendienteApertura = aplazamiento["PENDIENTEAPERTURA"] self.partida.apertura = None if aplazamiento[ "APERTURA"] is None else self.listaAperturasStd.dic[ aplazamiento["APERTURA"]] self.apertura.recuperaEstado(aplazamiento["ESTADOAPERTURA"]) self.siTutorActivado = aplazamiento["SITUTOR"] self.pantalla.ponActivarTutor(self.siTutorActivado) self.ayudas = aplazamiento["AYUDAS"] self.pantalla.ponToolBar((k_cancelar, k_rendirse, k_atras, k_reiniciar, k_aplazar, k_configurar, k_utilidades)) self.pantalla.activaJuego(True, False) self.ponMensajero(self.mueveHumano) self.ponPosicion(self.partida.ultPosicion) self.ponPiezasAbajo(siBlancas) self.ponAyudas(self.ayudas) self.mostrarIndicador(True) rotulo = "%s: <b>%s</b><br>%s %s %d" % ( _("Opponent"), self.xrival.nombre, categoria.nombre(), _("Level"), nivel) if self.puntos: rotulo += " (+%d %s)" % (self.puntos, _("points")) self.ponRotulo1(rotulo) self.xrotulo2() self.pgnRefresh(True) self.ponCapInfoPorDefecto() # -Aplazamiento 2/2-------------------------------------------------- if aplazamiento: self.mueveJugada(kMoverFinal) self.siAnalizadoTutor = False self.ponPosicionDGT() self.siguienteJugada()
def inicio(self, record): self.tipoJuego = kJugGM self.ayudas = 9999 # Para que analice sin problemas self.puntos = 0 self.record = record self.gm = record.gm self.siBlancas = record.siBlancas self.modo = record.modo self.siJuez = record.siJuez self.showevals = record.showevals self.motor = record.motor self.tiempo = record.tiempo self.depth = record.depth self.multiPV = record.multiPV self.mostrar = record.mostrar self.jugContrario = record.jugContrario self.jugInicial = record.jugInicial self.partidaElegida = record.partidaElegida self.bypassBook = record.bypassBook self.apertura = record.apertura self.onBypassBook = True if self.bypassBook else False if self.onBypassBook: self.bypassBook.polyglot() self.onApertura = True if self.apertura else False self.siAnalizando = False if self.siJuez: self.puntos = 0 tutor = self.configuracion.buscaRivalExt(self.motor) t_t = self.tiempo * 100 self.xtutor = self.procesador.creaGestorMotor( tutor, t_t, self.depth) self.xtutor.actMultiPV(self.multiPV) self.analisis = None self.book = Apertura.AperturaPol(999) self.pensando(True) carpeta = "GM" if self.modo == "estandar" else self.configuracion.dirPersonalTraining self.motorGM = GM.GM(carpeta, self.gm) self.motorGM.colorFilter(self.siBlancas) if self.partidaElegida is not None: self.motorGM.ponPartidaElegida(self.partidaElegida) self.siJugamosConBlancas = self.siBlancas self.siRivalConBlancas = not self.siBlancas self.pensando(False) self.pantalla.ponToolBar( (k_mainmenu, k_reiniciar, k_configurar, k_utilidades)) self.pantalla.activaJuego(True, False) self.ponMensajero(self.mueveHumano) self.ponPosicion(self.partida.ultPosicion) self.mostrarIndicador(True) self.quitaAyudas() self.ponPiezasAbajo(self.siBlancas) dic = GM.dicGM() self.nombreGM = dic[ self.gm.lower()] if self.modo == "estandar" else self.gm rotulo1 = _( "Grandmaster" ) + ": <b>%s</b>" if self.modo == "estandar" else "<b>%s</b>" self.ponRotulo1(rotulo1 % self.nombreGM) self.nombreRival = "" self.textoPuntuacion = "" self.ponRotuloSecundario() self.pgnRefresh(True) self.ponCapInfoPorDefecto() self.estado = kJugando self.ponPosicionDGT() self.siguienteJugada()
def base_inicio(self, datos_motor): self.game_type = GT_ELO self.siCompetitivo = True self.resultado = None self.human_is_playing = False self.state = ST_PLAYING is_white = self.determina_side(datos_motor) self.is_human_side_white = is_white self.is_engine_side_white = not is_white self.lirm_engine = [] self.next_test_resign = False self.resign_limit = -1000 self.is_tutor_enabled = False self.main_window.ponActivarTutor(self.is_tutor_enabled) self.ayudas = 0 self.ayudas_iniciales = self.ayudas self.in_the_opening = True self.datosMotor = datos_motor self.opening = Apertura.AperturaPol(100, elo=self.datosMotor.elo) eloengine = self.datosMotor.elo eloplayer = self.configuracion.eloActivo() self.whiteElo = eloplayer if is_white else eloengine self.blackElo = eloplayer if not is_white else eloengine self.siRivalInterno = self.datosMotor.siInterno if self.siRivalInterno: rival = self.configuracion.buscaRival("irina") depth = 2 if self.datosMotor.clave in ("Rat", "Snake") else 1 self.xrival = self.procesador.creaGestorMotor(rival, None, depth) self.xrival.set_option("Personality", self.datosMotor.clave) else: rival = self.configuracion.buscaRival(self.datosMotor.clave) self.xrival = self.procesador.creaGestorMotor(rival, None, self.datosMotor.depth) self.pte_tool_resigndraw = True self.pon_toolbar() self.main_window.activaJuego(True, False, siAyudas=False) self.set_dispatcher(self.mueve_humano) self.setposition(self.game.last_position) self.ponPiezasAbajo(is_white) self.quitaAyudas(True, siQuitarAtras=True) self.mostrarIndicador(True) rotulo = "%s: <b>%s</b>" % (_("Opponent"), self.datosMotor.rotulo()) self.ponRotulo1(rotulo) nbsp = " " * 3 txt = "%s:%+d%s%s:%+d%s%s:%+d" % ( _("Win"), self.datosMotor.pgana, nbsp, _("Draw"), self.datosMotor.ptablas, nbsp, _("Loss"), self.datosMotor.ppierde, ) self.ponRotulo2("<center>%s</center>" % txt) self.pgnRefresh(True) self.ponCapInfoPorDefecto() self.dgt_setposition() self.game.add_tag("Event", _("Lucas-Elo")) player = self.configuracion.nom_player() other = self.datosMotor.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)
def inicio(self, dic, aplazamiento=None, siPrimeraJugadaHecha=False): if aplazamiento: dic = aplazamiento["EMDIC"] self.reinicio = dic self.tipoJuego = kJugEntMaq self.resultado = None self.siJuegaHumano = False self.siJuegaPorMi = True self.estado = kJugando self.siAnalizando = False self.timekeeper = Util.Timekeeper() self.summary = {} # numJugada : "a"ccepted, "s"ame, "r"ejected, dif points, time used self.siSummary = dic.get("SUMMARY", False) siBlancas = dic["SIBLANCAS"] self.siJugamosConBlancas = siBlancas self.siRivalConBlancas = not siBlancas self.cm = dic["RIVAL"].get("CM", None) if self.cm: if hasattr(self.cm, "icono"): delattr(self.cm, "icono") # problem with configuracion.escVariables and saving qt variables self.siAtras = dic["ATRAS"] self.rmRival = None self.liRMrival = [] self.noMolestar = 0 self.resignPTS = -99999 # never self.aperturaObl = self.aperturaStd = None self.fen = dic["FEN"] if self.fen: cp = ControlPosicion.ControlPosicion() cp.leeFen(self.fen) self.partida.reset(cp) self.partida.pendienteApertura = False if "MOVE" in dic: self.partida.leerPV(dic["MOVE"]) else: if dic["APERTURA"]: self.aperturaObl = Apertura.JuegaApertura(dic["APERTURA"].a1h8) self.primeroBook = False # la apertura es obligatoria self.pensando(True) self.book = dic.get("BOOK", None) elo = getattr(self.cm, "elo", 0) self.maxMoveBook = elo / 200 if 0 < elo <= 1700 else 9999 if self.book: self.book.polyglot() self.bookRR = dic.get("BOOKRR", "mp") self.bookMandatory = dic.get("BOOKMANDATORY", False) elif dic["RIVAL"].get("TIPO", None) in (Motores.MICGM, Motores.MICPER): if self.cm.book: self.book = Books.Libro("P", self.cm.book, self.cm.book, True) self.book.polyglot() self.bookRR = "mp" self.bookMandatory = None self.maxMoveBook = 0 self.siTutorActivado = (VarGen.dgtDispatch is None) and self.configuracion.tutorActivoPorDefecto self.pantalla.ponActivarTutor(self.siTutorActivado) self.ayudas = dic["AYUDAS"] self.ayudasPGN = self.ayudas # Se guarda para guardar el PGN self.nArrows = dic.get("ARROWS", 0) nBoxHeight = dic.get("BOXHEIGHT", 24) self.thoughtOp = dic.get("THOUGHTOP", -1) self.thoughtTt = dic.get("THOUGHTTT", -1) self.continueTt = dic.get("CONTINUETT", False) self.nArrowsTt = dic.get("ARROWSTT", 0) self.chance = dic.get("2CHANCE", True) if self.nArrowsTt and self.ayudas == 0: self.nArrowsTt = 0 self.childmode = self.nArrowsTt > 0 and self.ayudas > 0 mx = max(self.thoughtOp, self.thoughtTt) if mx > -1: self.alturaRotulo3(nBoxHeight) dr = dic["RIVAL"] rival = dr["CM"] if dr["TIPO"] == Motores.ELO: r_t = 0 r_p = rival.fixed_depth self.nAjustarFuerza = kAjustarMejor else: r_t = dr["TIEMPO"] * 100 # Se guarda en decimas -> milesimas r_p = dr["PROFUNDIDAD"] self.nAjustarFuerza = dic.get("AJUSTAR", kAjustarMejor) 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["SITIEMPO"]: r_t = 1000 self.xrival = self.procesador.creaGestorMotor(rival, r_t, r_p, self.nAjustarFuerza != kAjustarMejor) if self.nAjustarFuerza != kAjustarMejor: self.xrival.maximizaMultiPV() self.resignPTS = dr["RESIGN"] self.siBookAjustarFuerza = self.nAjustarFuerza != kAjustarMejor self.xrival.ponGuiDispatch(self.guiDispatch, whoDispatch=False) self.xtutor.ponGuiDispatch(self.guiDispatch, whoDispatch=True) self.xrival.siBlancas = self.siRivalConBlancas self.siPrimeraJugadaHecha = siPrimeraJugadaHecha self.siTiempo = dic["SITIEMPO"] if self.siTiempo: self.maxSegundos = dic["MINUTOS"] * 60.0 self.segundosJugada = dic["SEGUNDOS"] self.segExtra = dic.get("MINEXTRA", 0) * 60.0 self.zeitnot = dic.get("ZEITNOT", 0) self.tiempo = {} self.tiempo[True] = Util.Timer(self.maxSegundos) self.tiempo[False] = Util.Timer(self.maxSegundos) if self.segExtra: self.tiempo[self.siJugamosConBlancas].ponSegExtra(self.segExtra) self.pensando(False) # -Aplazamiento 1/2-------------------------------------------------- if aplazamiento: self.partida.recuperaDeTexto(aplazamiento["JUGADAS"]) self.partida.pendienteApertura = aplazamiento["PENDIENTEAPERTURA"] self.partida.apertura = None if aplazamiento["APERTURA"] is None else self.listaAperturasStd.dic[ aplazamiento["APERTURA"]] self.siTutorActivado = aplazamiento["SITUTOR"] self.pantalla.ponActivarTutor(self.siTutorActivado) self.ayudas = aplazamiento["AYUDAS"] self.summary = aplazamiento["SUMMARY"] self.siTiempo = aplazamiento["SITIEMPO"] if self.siTiempo: self.maxSegundos = aplazamiento["MAXSEGUNDOS"] self.segundosJugada = aplazamiento["SEGUNDOSJUGADA"] self.segExtra = aplazamiento.get("SEGEXTRA", 0) self.tiempo = {} self.tiempo[True] = Util.Timer(aplazamiento["TIEMPOBLANCAS"]) self.tiempo[False] = Util.Timer(aplazamiento["TIEMPONEGRAS"]) if self.segExtra: self.tiempo[self.siJugamosConBlancas].ponSegExtra(self.segExtra) self.siPrimeraJugadaHecha = False li = [k_cancelar, k_rendirse, k_tablas, k_atras, k_ayudaMover, k_reiniciar, k_aplazar, k_peliculaPausa, k_configurar, k_utilidades] if not self.siAtras: del li[3] self.pantalla.ponToolBar(li) self.pantalla.mostrarOpcionToolbar(k_tablas, True) self.pantalla.activaJuego(True, self.siTiempo) self.ponMensajero(self.mueveHumano) self.ponPosicion(self.partida.ultPosicion) self.mostrarIndicador(True) if self.ayudasPGN: self.ponAyudasEM() else: self.quitaAyudas(siQuitarAtras=not self.siAtras) self.ponPiezasAbajo(siBlancas) self.ponRotuloBasico() if self.ayudasPGN: self.ponRotulo2(_("Tutor") + ": <b>" + self.xtutor.nombre) else: self.ponRotulo2("") self.ponCapInfoPorDefecto() self.pgnRefresh(True) # -Aplazamiento 2/2-------------------------------------------------- if aplazamiento or "MOVE" in dic: self.mueveJugada(kMoverFinal) if self.siTiempo: self.siPrimeraJugadaHecha = siPrimeraJugadaHecha tpBL = self.tiempo[True].etiqueta() tpNG = self.tiempo[False].etiqueta() rival = self.xrival.nombre jugador = self.configuracion.jugador bl, ng = jugador, rival if self.siRivalConBlancas: bl, ng = ng, bl self.pantalla.ponDatosReloj(bl, tpBL, ng, tpNG) self.refresh() self.siAnalizadoTutor = False self.ponPosicionDGT() if self.childmode: self.pantalla.base.btActivarTutor.setVisible(False) self.siguienteJugada()
def inicio(self, record): self.game_type = GT_AGAINST_GM self.ayudas = 9999 # Para que analice sin problemas self.puntos = 0 self.record = record self.gm = record.gm self.is_white = record.is_white self.modo = record.modo self.siJuez = record.siJuez self.showevals = record.showevals self.engine = record.engine self.vtime = record.vtime self.depth = record.depth self.multiPV = record.multiPV self.mostrar = record.mostrar self.jugContrario = record.jugContrario self.jugInicial = record.jugInicial self.partidaElegida = record.partidaElegida self.bypassBook = record.bypassBook self.opening = record.opening self.onBypassBook = True if self.bypassBook else False if self.onBypassBook: self.bypassBook.polyglot() self.onApertura = True if self.opening else False self.siAnalizando = False if self.siJuez: self.puntos = 0 tutor = self.configuracion.buscaRival(self.engine) t_t = self.vtime * 100 self.xtutor = self.procesador.creaGestorMotor(tutor, t_t, self.depth) self.xtutor.actMultiPV(self.multiPV) self.analysis = None self.book = Apertura.AperturaPol(999) self.pensando(True) default = Code.path_resource("GM") carpeta = default if self.modo == "estandar" else self.configuracion.dirPersonalTraining self.motorGM = GM.GM(carpeta, self.gm) self.motorGM.colorFilter(self.is_white) if self.partidaElegida is not None: self.motorGM.ponPartidaElegida(self.partidaElegida) self.is_human_side_white = self.is_white self.is_engine_side_white = not self.is_white self.pensando(False) self.main_window.pon_toolbar((TB_CLOSE, TB_REINIT, TB_CONFIG, TB_UTILITIES)) # self.main_window.pon_toolbar((TB_CLOSE, TB_REINIT, TB_ADJOURN, TB_CONFIG, TB_UTILITIES)) self.main_window.activaJuego(True, False) self.set_dispatcher(self.mueve_humano) self.setposition(self.game.last_position) self.mostrarIndicador(True) self.quitaAyudas() self.ponPiezasAbajo(self.is_white) dic = GM.dic_gm() self.nombreGM = dic[self.gm.lower()] if self.modo == "estandar" else self.gm rot = _("Grandmaster") rotulo1 = rot + ": <b>%s</b>" if self.modo == "estandar" else "<b>%s</b>" self.ponRotulo1(rotulo1 % self.nombreGM) self.nombreRival = "" self.textoPuntuacion = "" self.ponRotuloSecundario() self.pgnRefresh(True) self.ponCapInfoPorDefecto() self.state = ST_PLAYING self.dgt_setposition() self.siguiente_jugada()
def inicio(self, resistance, numEngine, clave): self.tipoJuego = kJugBoxing self.resistance = resistance self.numEngine = numEngine self.clave = clave siBlancas = "BLANCAS" in clave self.segundos, self.puntos, self.maxerror = resistance.actual() self.movimientos = 0 self.puntosRival = 0 self.siJuegaHumano = False self.estado = kJugando self.siJugamosConBlancas = siBlancas self.siRivalConBlancas = not siBlancas self.siBoxing = True self.rmRival = None self.siApertura = False self.apertura = Apertura.AperturaPol(5) # lee las aperturas # debe hacerse antes que rival self.xarbitro = self.procesador.creaGestorMotor( self.configuracion.tutor, self.segundos * 1000, None) self.xarbitro.anulaMultiPV() motor = resistance.dameClaveEngine(numEngine) rival = self.configuracion.buscaRivalExt(motor) self.xrival = self.procesador.creaGestorMotor(rival, self.segundos * 1000, None) self.pantalla.ponToolBar( (k_rendirse, k_reiniciar, k_configurar, k_utilidades)) self.pantalla.activaJuego(True, False, siAyudas=False) self.ponMensajero(self.mueveHumano) self.ponPosicion(self.partida.ultPosicion) self.ponPiezasAbajo(siBlancas) self.quitaAyudas() self.ponActivarTutor(False) self.mostrarIndicador(True) self.ponRotuloObjetivo() self.ponRotuloActual() self.pgnRefresh(True) self.ponCapInfoPorDefecto() self.ponPosicionDGT() tp = self.resistance.tipo if tp: b = n = False if tp == "p2": if siBlancas: b = True else: n = True elif tp == "p1": if siBlancas: n = True else: b = True self.tablero.mostrarPiezas(b, n) self.siguienteJugada()
def base_inicio(self, dic_var): self.reinicio = dic_var self.cache = dic_var.get("cache", {}) self.game_type = GT_AGAINST_CHILD_ENGINE self.human_is_playing = False self.plays_instead_of_me_option = True self.state = ST_PLAYING 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 w, b = self.configuracion.nom_player(), dic_var["RIVAL"] if not is_white: w, b = b, w self.game.add_tag("White", w) self.game.add_tag("Black", b) self.with_takeback = True cmrival = self.configuracion.buscaRival("irina", None) self.xrival = self.procesador.creaGestorMotor(cmrival, None, 2) self.rival_name = dic_var["RIVAL"] self.xrival.set_option("Personality", self.rival_name) if not dic_var["FASTMOVES"]: self.xrival.set_option("Max Time", "5") self.xrival.set_option("Min Time", "1") self.xrival.name = _F(self.rival_name) self.lirm_engine = [] self.next_test_resign = 0 self.resign_limit = -99999 # never self.aperturaObl = self.aperturaStd = None self.human_is_playing = False self.state = ST_PLAYING self.siAnalizando = False self.aperturaStd = Apertura.AperturaPol(1) self.set_dispatcher(self.mueve_humano) self.main_window.set_notify(self.mueve_rival_base) self.pensando(True) self.main_window.ponActivarTutor(False) self.ayudas = 0 self.ayudas_iniciales = 0 self.xrival.is_white = self.is_engine_side_white self.siPrimeraJugadaHecha = False self.siTiempo = dic_var["SITIEMPO"] if self.siTiempo: self.maxSegundos = dic_var["MINUTOS"] * 60.0 self.segundosJugada = dic_var["SEGUNDOS"] self.segExtra = dic_var.get("MINEXTRA", 0) * 60.0 self.vtime = { WHITE: Util.Timer(self.maxSegundos), BLACK: Util.Timer(self.maxSegundos) } self.pensando(False) li = [ TB_CANCEL, TB_RESIGN, TB_TAKEBACK, TB_REINIT, TB_ADJOURN, TB_PAUSE, TB_CONFIG, TB_UTILITIES ] self.main_window.pon_toolbar(li) self.main_window.activaJuego(True, self.siTiempo) self.set_dispatcher(self.mueve_humano) self.setposition(self.game.last_position) self.mostrarIndicador(True) self.quitaAyudas(True, siQuitarAtras=False) self.ponPiezasAbajo(is_white) imagen = getattr(Iconos, "pm%s" % self.rival_name) self.main_window.base.lbRotulo1.ponImagen(imagen()) self.main_window.base.lbRotulo1.show() self.ponCapInfoPorDefecto() self.pgnRefresh(True) if self.siTiempo: self.siPrimeraJugadaHecha = False tpBL = self.vtime[True].etiqueta() tpNG = self.vtime[False].etiqueta() player = self.configuracion.x_player bl, ng = player, self.rival_name if self.is_engine_side_white: bl, ng = ng, bl self.main_window.ponDatosReloj(bl, tpBL, ng, tpNG) self.refresh() self.dgt_setposition()
def inicio(self, dbwashing, washing, engine): self.dbwashing = dbwashing self.washing = washing self.engine = engine self.game_type = GT_WASHING_CREATE self.resultado = None self.human_is_playing = False self.state = ST_PLAYING is_white = self.engine.color self.is_human_side_white = is_white self.is_engine_side_white = not is_white self.siCompetitivo = True self.opening = Apertura.AperturaPol(30, self.engine.elo) self.is_tutor_enabled = True self.siAnalizando = False # self.main_window.ponActivarTutor(self.is_tutor_enabled) rival = self.configuracion.buscaRival(self.engine.key) self.xrival = self.procesador.creaGestorMotor(rival, None, None) self.xrival.is_white = self.is_engine_side_white self.rm_rival = None self.tmRival = 15.0 * 60.0 * engine.elo / 3000.0 self.xtutor.maximizaMultiPV() self.is_analyzed_by_tutor = False self.main_window.activaJuego(True, False, False) self.quitaAyudas() li = [TB_CLOSE, TB_REINIT, TB_TAKEBACK] self.main_window.pon_toolbar(li) self.set_dispatcher(self.mueve_humano) self.setposition(self.game.last_position) self.mostrarIndicador(True) self.ponPiezasAbajo(is_white) self.ponRotulo1("%s: %s\n%s: %s\n %s: %s" % (_("Rival"), self.engine.name, _("Task"), self.engine.lbState(), _("Tutor"), self.xtutor.name)) self.ponRotuloDatos() self.ponCapInfoPorDefecto() self.pgnRefresh(True) game = dbwashing.restoreGame(engine) if game: if not game.is_finished(): self.game = game self.goto_end() self.main_window.base.pgnRefresh() self.dgt_setposition() self.siguiente_jugada()
def inicio(self, datosMotor, siCompetitivo, aplazamiento=None): self.tipoJuego = kJugElo self.siCompetitivo = siCompetitivo self.resultado = None self.siJuegaHumano = False self.estado = kJugando if aplazamiento: siBlancas = aplazamiento["SIBLANCAS"] else: siBlancas = self.determinaColor(datosMotor) self.siJugamosConBlancas = siBlancas self.siRivalConBlancas = not siBlancas self.rmRival = None self.liRMrival = [] self.noMolestar = False self.resignPTS = -1000 self.siTutorActivado = False self.pantalla.ponActivarTutor(self.siTutorActivado) self.ayudas = 0 self.ayudasPGN = self.ayudas self.siApertura = True # -Aplazamiento 1/2-------------------------------------------------- if aplazamiento: self.partida.recuperaDeTexto(aplazamiento["JUGADAS"]) self.siApertura = aplazamiento["SIAPERTURA"] self.partida.pendienteApertura = aplazamiento["PENDIENTEAPERTURA"] self.partida.apertura = None if aplazamiento[ "APERTURA"] is None else self.listaAperturasStd.dic[ aplazamiento["APERTURA"]] self.datosMotor = MotorElo(aplazamiento["ELO"], aplazamiento["NOMBRE"], aplazamiento["CLAVE"], aplazamiento["DEPTH"]) self.datosMotor.pgana = aplazamiento["PGANA"] self.datosMotor.ppierde = aplazamiento["PPIERDE"] self.datosMotor.ptablas = aplazamiento["PTABLAS"] self.datosMotor.siInterno = False self.apertura = Apertura.AperturaPol(100, elo=self.datosMotor.elo) self.apertura.recuperaEstado(aplazamiento["ESTADOAPERTURA"]) else: self.datosMotor = datosMotor self.apertura = Apertura.AperturaPol(100, elo=self.datosMotor.elo) eloengine = self.datosMotor.elo eloplayer = self.configuracion.eloActivo(siCompetitivo) self.whiteElo = eloplayer if siBlancas else eloengine self.blackElo = eloplayer if not siBlancas else eloengine self.siRivalInterno = self.datosMotor.siInterno if self.siRivalInterno: rival = self.configuracion.buscaRival("irina") depth = 2 if self.datosMotor.clave in ("Rat", "Snake") else 1 self.xrival = self.procesador.creaGestorMotor(rival, None, depth) self.xrival.set_option("Personality", self.datosMotor.clave) else: rival = self.configuracion.buscaRival(self.datosMotor.clave) self.xrival = self.procesador.creaGestorMotor( rival, None, self.datosMotor.depth) self.pteToolRendirse = False if not siCompetitivo: self.pteToolRendirse = True self.maxPlyRendirse = 6 elif self.siJugamosConBlancas: self.pteToolRendirse = True self.maxPlyRendirse = 1 else: self.maxPlyRendirse = 0 if aplazamiento and self.partida.numJugadas() > self.maxPlyRendirse: self.pteToolRendirse = False self.ponToolBar() self.pantalla.activaJuego(True, False, siAyudas=False) self.ponMensajero(self.mueveHumano) self.ponPosicion(self.partida.ultPosicion) self.ponPiezasAbajo(siBlancas) self.quitaAyudas(True, siQuitarAtras=siCompetitivo) self.mostrarIndicador(True) rotulo = "%s: <b>%s</b>" % (_("Opponent"), self.datosMotor.rotulo()) self.ponRotulo1(rotulo) nbsp = " " * 3 txt = "%s:%+d%s%s:%+d%s%s:%+d" % ( _("Win"), self.datosMotor.pgana, nbsp, _("Draw"), self.datosMotor.ptablas, nbsp, _("Lost"), self.datosMotor.ppierde) self.ponRotulo2("<center>%s</center>" % txt) self.pgnRefresh(True) self.ponCapInfoPorDefecto() # -Aplazamiento 2/2-------------------------------------------------- if aplazamiento: self.mueveJugada(kMoverFinal) self.ponPosicionDGT() self.siguienteJugada()
def inicio(self, resistance, numEngine, key): self.game_type = GT_RESISTANCE self.resistance = resistance self.numEngine = numEngine self.key = key is_white = "BLANCAS" in key self.segundos, self.puntos, self.maxerror = resistance.actual() self.movimientos = 0 self.puntosRival = 0 self.human_is_playing = False self.state = ST_PLAYING self.is_human_side_white = is_white self.is_engine_side_white = not is_white self.siBoxing = True self.rm_rival = None self.in_the_opening = False self.opening = Apertura.AperturaPol(5) # lee las aperturas # debe hacerse antes que rival self.xarbitro = self.procesador.creaGestorMotor( self.configuracion.tutor, self.segundos * 1000, None) self.xarbitro.anulaMultiPV() engine = resistance.dameClaveEngine(numEngine) rival = self.configuracion.buscaRival(engine) self.xrival = self.procesador.creaGestorMotor(rival, self.segundos * 1000, None) self.main_window.pon_toolbar( (TB_RESIGN, TB_REINIT, TB_CONFIG, TB_UTILITIES)) self.main_window.activaJuego(True, False, siAyudas=False) self.set_dispatcher(self.mueve_humano) self.setposition(self.game.last_position) self.ponPiezasAbajo(is_white) self.quitaAyudas() self.ponActivarTutor(False) self.mostrarIndicador(True) self.ponRotuloObjetivo() self.ponRotuloActual() self.pgnRefresh(True) self.ponCapInfoPorDefecto() self.dgt_setposition() tp = self.resistance.tipo if tp: b = n = False if tp == "p2": if is_white: b = True else: n = True elif tp == "p1": if is_white: n = True else: b = True self.tablero.mostrarPiezas(b, n) self.siguiente_jugada()
def inicio(self, dic, aplazamiento=None, siPrimeraJugadaHecha=False): if aplazamiento: dic = aplazamiento["EMDIC"] self.reinicio = dic self.cache = {} self.tipoJuego = kJugEntMaq self.resultado = None self.siJuegaHumano = False self.estado = kJugando self.timekeeper = Util.Timekeeper() self.siAnalizando = False self.summary = {} self.siSummary = dic.get("SUMMARY", False) siBlancas = dic["SIBLANCAS"] self.siJugamosConBlancas = siBlancas self.siRivalConBlancas = not siBlancas self.siAtras = True self.rmRival = None self.liRMrival = [] self.aperturaStd = Apertura.AperturaPol(1) self.pensando(True) self.pantalla.ponActivarTutor(False) self.ayudas = 0 self.ayudasPGN = 0 cmrival = self.configuracion.buscaRival("irina", None) self.xrival = self.procesador.creaGestorMotor(cmrival, None, 2) self.rival_name = dic["RIVAL"] self.xrival.set_option("Personality", self.rival_name) if not dic["FASTMOVES"]: self.xrival.set_option("Max Time", "5") self.xrival.set_option("Min Time", "1") self.xrival.nombre = _F(self.rival_name) self.xrival.siBlancas = self.siRivalConBlancas self.siPrimeraJugadaHecha = siPrimeraJugadaHecha self.siTiempo = dic["SITIEMPO"] if self.siTiempo: self.maxSegundos = dic["MINUTOS"] * 60.0 self.segundosJugada = dic["SEGUNDOS"] self.segExtra = dic.get("MINEXTRA", 0) * 60.0 self.tiempo = {} self.tiempo[True] = Util.Timer(self.maxSegundos) self.tiempo[False] = Util.Timer(self.maxSegundos) self.pensando(False) # -Aplazamiento 1/2-------------------------------------------------- if aplazamiento: self.partida.recuperaDeTexto(aplazamiento["JUGADAS"]) self.partida.pendienteApertura = aplazamiento["PENDIENTEAPERTURA"] self.partida.apertura = None if aplazamiento[ "APERTURA"] is None else self.listaAperturasStd.dic[ aplazamiento["APERTURA"]] self.siTiempo = aplazamiento["SITIEMPO"] if self.siTiempo: self.maxSegundos = aplazamiento["MAXSEGUNDOS"] self.segundosJugada = aplazamiento["SEGUNDOSJUGADA"] self.tiempo = {} self.tiempo[True] = Util.Timer(aplazamiento["TIEMPOBLANCAS"]) self.tiempo[False] = Util.Timer(aplazamiento["TIEMPONEGRAS"]) if self.segExtra: self.tiempo[self.siJugamosConBlancas].ponSegExtra( self.segExtra) self.siPrimeraJugadaHecha = False li = [ k_cancelar, k_rendirse, k_atras, k_reiniciar, k_aplazar, k_peliculaPausa, k_configurar, k_utilidades ] self.pantalla.ponToolBar(li) self.pantalla.activaJuego(True, self.siTiempo) self.ponMensajero(self.mueveHumano) self.ponPosicion(self.partida.ultPosicion) self.mostrarIndicador(True) self.quitaAyudas(True, siQuitarAtras=False) self.ponPiezasAbajo(siBlancas) imagen = getattr(Iconos, "pm%s" % self.rival_name) self.pantalla.base.lbRotulo1.ponImagen(imagen()) self.pantalla.base.lbRotulo1.show() self.ponCapInfoPorDefecto() self.pgnRefresh(True) # -Aplazamiento 2/2-------------------------------------------------- if aplazamiento or "MOVE" in dic: self.mueveJugada(kMoverFinal) if self.siTiempo: self.siPrimeraJugadaHecha = False tpBL = self.tiempo[True].etiqueta() tpNG = self.tiempo[False].etiqueta() jugador = self.configuracion.jugador bl, ng = jugador, self.rival_name if self.siRivalConBlancas: bl, ng = ng, bl self.pantalla.ponDatosReloj(bl, tpBL, ng, tpNG) self.refresh() self.ponPosicionDGT() self.siguienteJugada()
def inicio(self, dbwashing, washing, engine): self.dbwashing = dbwashing self.washing = washing self.engine = engine self.tipoJuego = kJugWashingCreate self.resultado = None self.siJuegaHumano = False self.estado = kJugando self.timekeeper = Util.Timekeeper() siBlancas = self.engine.color self.siJugamosConBlancas = siBlancas self.siRivalConBlancas = not siBlancas self.siCompetitivo = True self.apertura = Apertura.AperturaPol(30, self.engine.elo) self.siTutorActivado = True self.siAnalizando = False # self.pantalla.ponActivarTutor(self.siTutorActivado) rival = self.configuracion.buscaRival(self.engine.clave) self.xrival = self.procesador.creaGestorMotor(rival, None, None) self.xrival.siBlancas = self.siRivalConBlancas self.rmRival = None self.tmRival = 15.0 * 60.0 * engine.elo / 3000.0 self.xtutor.maximizaMultiPV() self.siAnalizadoTutor = False self.pantalla.activaJuego(True, False, False) self.quitaAyudas() li = [k_mainmenu, k_reiniciar, k_atras] self.pantalla.ponToolBar(li) self.ponMensajero(self.mueveHumano) self.ponPosicion(self.partida.ultPosicion) self.mostrarIndicador(True) self.ponPiezasAbajo(siBlancas) self.ponRotulo1( "%s: %s\n%s: %s\n %s: %s" % (_("Rival"), self.engine.nombre, _("Task"), self.engine.lbState(), _("Tutor"), self.xtutor.nombre)) self.ponRotuloDatos() self.ponCapInfoPorDefecto() self.pgnRefresh(True) game = dbwashing.restoreGame(engine) if game: if not game.siTerminada(): self.partida = game self.ponteAlFinal() self.pantalla.base.pgnRefresh() self.ponPosicionDGT() self.siguienteJugada()