コード例 #1
0
    def cambioRival(self):
        if self.dicRival:
            dicBase = self.dicRival
        else:
            dicBase = self.configuration.read_variables("ENG_MANAGERSOLO")

        dic = self.dicRival = WPlayAgainstEngine.cambioRival(
            self.main_window, self.configuration, dicBase, siManagerSolo=True)

        if dic:
            for k, v in dic.items():
                self.reinicio[k] = v

            dr = dic["RIVAL"]
            rival = dr["CM"]
            r_t = dr["TIME"] * 100  # Se guarda en decimas -> milesimas
            r_p = dr["DEPTH"]
            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

            nAjustarFuerza = dic["ADJUST"]
            self.xrival = self.procesador.creaManagerMotor(
                rival, r_t, r_p, nAjustarFuerza != ADJUST_BETTER)
            self.xrival.nAjustarFuerza = nAjustarFuerza

            dic["ROTULO1"] = _("Opponent") + ": <b>" + self.xrival.name
            self.set_label1(dic["ROTULO1"])
            self.play_against_engine = True
            self.configuration.write_variables("ENG_MANAGERSOLO", dic)
コード例 #2
0
        def mira(xis_white):
            ot = self.vtime[xis_white]

            eti, eti2 = ot.etiquetaDif2()
            if eti:
                if xis_white:
                    self.main_window.ponRelojBlancas(eti, eti2)
                else:
                    self.main_window.ponRelojNegras(eti, eti2)

            siJugador = self.human_side == xis_white
            if ot.siAgotado():
                if siJugador and QTUtil2.pregunta(
                        self.main_window,
                        _X(_("%1 has won on time."), self.xrival.name) +
                        "\n\n" + _("Add time and keep playing?"),
                ):
                    minX = WPlayAgainstEngine.dameMinutosExtra(
                        self.main_window)
                    if minX:
                        ot.ponSegExtra(minX * 60)
                        return
                self.game.set_termination(
                    TERMINATION_WIN_ON_TIME,
                    RESULT_WIN_BLACK if xis_white else RESULT_WIN_WHITE)
                self.state = ST_ENDGAME  # necesario que esté antes de reloj_stop para no entrar en bucle
                self.reloj_stop(siJugador)
                self.muestra_resultado()
                return

            elif siJugador and ot.isZeitnot():
                self.beepZeitnot()

            return
コード例 #3
0
ファイル: Procesador.py プロジェクト: lukasmonk/lucaschessR
 def juegaExterno(self, fich_tmp):
     dic_sended = Util.restore_pickle(fich_tmp)
     dic = WPlayAgainstEngine.play_position(self, _("Play a position"), dic_sended["ISWHITE"])
     if dic is None:
         self.run_action(TB_QUIT)
     else:
         side = dic["SIDE"]
         if side == "R":
             side = "B" if random.randint(1, 2) == 1 else "N"
         dic["ISWHITE"] = side == "B"
         self.manager = ManagerPlayAgainstEngine.ManagerPlayAgainstEngine(self)
         self.manager.play_position(dic, dic_sended["GAME"])
コード例 #4
0
    def cambioRival(self):
        dic = WPlayAgainstEngine.cambioRival(self.main_window,
                                             self.configuration, self.reinicio)

        if dic:
            dr = dic["RIVAL"]
            rival = dr["CM"]
            if hasattr(rival, "icono"):
                delattr(rival, "icono")

            Util.save_pickle(self.configuration.ficheroEntMaquina, dic)
            for k, v in dic.items():
                self.reinicio[k] = v

            is_white = dic["ISWHITE"]

            self.pon_toolbar()

            self.nAjustarFuerza = dic["ADJUST"]

            r_t = dr["TIME"] * 100  # Se guarda en decimas -> milesimas
            r_p = dr["DEPTH"]
            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

            dr["RESIGN"] = self.resign_limit
            self.xrival.terminar()
            self.xrival = self.procesador.creaManagerMotor(
                rival, r_t, r_p, self.nAjustarFuerza != ADJUST_BETTER)

            self.xrival.is_white = not is_white

            rival = self.xrival.name
            player = self.configuration.x_player
            bl, ng = player, rival
            if not is_white:
                bl, ng = ng, bl
            self.main_window.change_player_labels(bl, ng)

            # self.put_pieces_bottom( is_white )
            self.ponRotuloBasico()

            self.put_pieces_bottom(is_white)
            if is_white != self.human_side:
                self.human_side = is_white
                self.is_engine_side_white = not is_white

                self.play_next_move()
コード例 #5
0
    def cambioRival(self):

        if self.dicRival:
            dicBase = self.dicRival
        else:
            dicBase = self.configuration.read_variables("ENG_VARIANTES")

        import Code.PlayAgainstEngine.WPlayAgainstEngine as WindowEntMaq

        dic = self.dicRival = WindowEntMaq.cambioRival(self.main_window, self.configuration, dicBase, siManagerSolo=True)

        if dic:
            self.ponRival(dic)
コード例 #6
0
    def cambioRival(self):
        if self.dicRival:
            dicBase = self.dicRival
        else:
            dicBase = self.configuration.read_variables("ENG_MANAGERSOLO")

        dic = self.dicRival = WPlayAgainstEngine.cambioRival(
            self.main_window, self.configuration, dicBase, siManagerSolo=True)

        if dic:
            for k, v in dic.items():
                self.reinicio[k] = v

            dr = dic["RIVAL"]
            rival = dr["CM"]
            if hasattr(rival, "icono"):
                delattr(
                    rival, "icono"
                )  # problem with configuration.write_variables and saving qt variables
            r_t = dr["TIME"] * 100  # Se guarda en decimas -> milesimas
            r_p = dr["DEPTH"]
            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

            nAjustarFuerza = dic["ADJUST"]
            self.xrival = self.procesador.creaManagerMotor(
                rival, r_t, r_p, nAjustarFuerza != ADJUST_BETTER)
            self.xrival.nAjustarFuerza = nAjustarFuerza

            dic["ROTULO1"] = _("Opponent") + ": <b>" + self.xrival.name
            self.set_label1(dic["ROTULO1"])
            self.play_against_engine = True
            self.configuration.write_variables("ENG_MANAGERSOLO", dic)
            self.human_side = dic["ISWHITE"]
            if self.game.last_position.is_white != self.human_side and not self.game.siEstaTerminada(
            ):
                self.play_against_engine = False
                self.disable_all()
                self.juegaRival()
                self.play_against_engine = True
コード例 #7
0
 def libre(self):
     dic = WPlayAgainstEngine.play_against_engine(
         self, _("Play against an engine"))
     if dic:
         self.entrenaMaquina(dic)