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.human_side = 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 = Opening.JuegaOpening( 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("TYPE", None) in (SelectEngines.MICGM, SelectEngines.MICPER): if self.conf_engine.book: self.bookR = Books.Book("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.configuration.x_default_tutor_active self.main_window.set_activate_tutor(self.is_tutor_enabled) self.hints = dic_var["HINTS"] self.ayudas_iniciales = self.hints # 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 = not Code.configuration.x_engine_notbackground self.nArrowsTt = dic_var.get("ARROWSTT", 0) self.chance = dic_var.get("2CHANCE", True) if self.nArrowsTt != 0 and self.hints == 0: self.nArrowsTt = 0 self.with_takeback = dic_var.get("TAKEBACK", True) self.tutor_con_flechas = self.nArrowsTt > 0 and self.hints > 0 self.tutor_book = Books.BookGame(Code.tbook) mx = max(self.thoughtOp, self.thoughtTt) if mx > -1: self.set_hight_label3(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("ADJUST", 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.creaManagerMotor( 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.set_tag("Event", _("Play against an engine")) player = self.configuration.nom_player() other = self.xrival.name w, b = (player, other) if self.human_side else (other, player) self.game.set_tag("White", w) self.game.set_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.human_side].ponSegExtra(self.segExtra) time_control = "%d" % int(self.maxSegundos) if self.segundosJugada: time_control += "+%d" % self.segundosJugada self.game.set_tag("TimeControl", time_control) if self.segExtra: self.game.set_tag( "TimeExtra" + "White" if self.human_side else "Black", "%d" % self.segExtra) self.pon_toolbar() self.main_window.activaJuego(True, self.siTiempo) self.set_dispatcher(self.player_has_moved) self.set_position(self.game.last_position) self.show_side_indicator(True) if self.ayudas_iniciales: self.ponAyudasEM() else: self.remove_hints(siQuitarAtras=False) self.put_pieces_bottom(is_white) self.ponRotuloBasico() self.set_label2("") if self.nAjustarFuerza != ADJUST_BETTER: pers = Personalities.Personalities(None, self.configuration) label = pers.label(self.nAjustarFuerza) if label: self.game.set_tag("Strength", label) self.ponCapInfoPorDefecto() self.pgnRefresh(True) rival = self.xrival.name player = self.configuration.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.game.tag_timestart() self.check_boards_setposition()
def base_inicio(self, categorias, categoria, nivel, is_white, puntos): self.game_type = GT_COMPETITION_WITH_TUTOR self.liReiniciar = categoria, nivel, is_white self.dbm = CompetitionWithTutor.DBManagerCWT() self.resultado = None self.human_is_playing = False self.state = ST_PLAYING self.is_competitive = True self.plays_instead_of_me_option = True self.human_side = is_white self.is_engine_side_white = not is_white self.rm_rival = None self.categorias = categorias self.categoria = categoria self.nivelJugado = nivel self.puntos = puntos self.is_tutor_enabled = ( Code.dgtDispatch is None) and self.configuration.x_default_tutor_active self.main_window.set_activate_tutor(self.is_tutor_enabled) self.tutor_book = Books.BookGame(Code.tbook) self.hints = categoria.hints self.ayudas_iniciales = self.hints # Se guarda para guardar el PGN self.in_the_opening = True self.opening = Opening.OpeningPol(nivel) # lee las aperturas self.rival_conf = self.dbm.get_current_rival() self.xrival = self.procesador.creaManagerMotor(self.rival_conf, None, nivel) self.main_window.pon_toolbar( (TB_CANCEL, TB_RESIGN, TB_TAKEBACK, TB_REINIT, TB_ADJOURN, TB_CONFIG, TB_UTILITIES)) self.main_window.activaJuego(True, False) self.set_dispatcher(self.player_has_moved) self.set_position(self.game.last_position) self.put_pieces_bottom(is_white) self.ponAyudas(self.hints) self.show_side_indicator(True) label = "%s: %s\n%s %s %d" % (_("Opponent"), self.xrival.name, categoria.name(), _("Level"), nivel) if self.puntos: label += " (+%d %s)" % (self.puntos, _("points")) self.set_label1(label) self.xrotulo2() self.pgnRefresh(True) self.ponCapInfoPorDefecto() self.game.set_tag("Event", _("Competition with tutor")) player = self.configuration.nom_player() other = "%s (%s %d)" % (self.xrival.name, _("Level"), self.nivelJugado) w, b = (player, other) if self.human_side else (other, player) self.game.set_tag("White", w) self.game.set_tag("Black", b) self.is_analyzed_by_tutor = False self.check_boards_setposition() self.game.tag_timestart()