示例#1
0
    def enNuevo(self):
        # Pedimos el ejecutable
        exeMotor = QTUtil2.leeFichero(self, self.torneo.ultCarpetaEngines(),
                                      "*", _("Engine"))
        if not exeMotor:
            return
        self.torneo.ultCarpetaEngines(os.path.dirname(exeMotor))

        # Leemos el UCI
        me = Engines.read_engine_uci(exeMotor)
        if not me:
            QTUtil2.message_bold(
                self,
                _X(_("The file %1 does not correspond to a UCI engine type."),
                   exeMotor))
            return
        eng = Tournament.EngineTournament()
        eng.restore(me.save())
        eng.pon_huella(self.torneo)
        self.torneo.save_engine(eng)
        self.gridEnginesAlias.refresh()
        self.gridEnginesAlias.gobottom(0)

        self.gridResults.refresh()

        self.rotulos_tabs()
示例#2
0
def selectEngine(wowner):
    """
    :param wowner: window
    :return: MotorExterno / None=error
    """
    # Pedimos el ejecutable
    folderEngines = Code.configuration.read_variables("FOLDER_ENGINES")
    extension = "%s EXE (*.exe)" if Code.is_windows else "%s (*)"
    exeMotor = QTUtil2.leeFichero(wowner,
                                  folderEngines if folderEngines else ".",
                                  extension % _("File"), _("Engine"))
    if not exeMotor:
        return None
    folderEngines = Util.relative_path(os.path.dirname(exeMotor))
    Code.configuration.write_variables("FOLDER_ENGINES", folderEngines)

    # Leemos el UCI
    um = QTUtil2.unMomento(wowner)
    me = Engines.read_engine_uci(exeMotor)
    um.final()
    if not me:
        QTUtil2.message_bold(
            wowner,
            _X(_("The file %1 does not correspond to a UCI engine type."),
               exeMotor))
        return None
    return me
    def mas(alias, autor, version, url, exe, elo, folder=None):
        if folder is None:
            folder = alias

        path_exe = os.path.join(folder_engines, folder, exe)
        engine = Engines.Engine(alias, autor, version, url, path_exe)
        engine.elo = elo
        dic_engines[alias] = engine
        return engine
示例#4
0
 def genEnginesIrina(self):
     cmbase = self.configuracion.buscaRival("irina")
     li = []
     for name, trans, ico in QTVarios.list_irina():
         cm = Engines.Engine(name, cmbase.autor, cmbase.version, cmbase.url, cmbase.path_exe)
         cm.name = trans
         cm.icono = ico
         cm.ordenUCI("Personality", name)
         li.append(cm)
     return li
示例#5
0
 def mas(clave, autor, version, url, exe, elo):
     path_exe = os.path.join(folder_engines, clave, exe)
     engine = Engines.Engine(clave, autor, version, url, path_exe)
     engine.elo = elo
     engine.ordenUCI("Log", "false")
     engine.ordenUCI("Ponder", "false")
     engine.ordenUCI("Hash", "16")
     engine.ordenUCI("Threads", "1")
     dic_engines[clave] = engine
     return engine
示例#6
0
 def restore(self, dic):
     self.ref = dic["REF"]
     self.info = dic["INFO"]
     self.seconds = dic["SECONDS"]
     self.depth = dic["DEPTH"]
     self.ini = dic["INI"]
     self.end = dic["END"]
     self.results = Results(15)  # 15 = cualquier number
     self.results.restore(dic["RESULTS"])
     self.liGroupActive = dic["GROUPACTIVE"]
     self.me = Engines.engine_from_txt(dic["ENGINE"])
     self.workTime = dic.get("WORKTIME", 0.0)
示例#7
0
    def mas(alias, autor, version, url, exe, elo, folder=None):
        if folder is None:
            folder = alias

        path_exe = os.path.join(folder_engines, folder, exe)
        engine = Engines.Engine(alias.lower(), autor, version, url, path_exe)
        engine.elo = elo
        engine.ordenUCI("Log", "false")
        engine.ordenUCI("Ponder", "false")
        engine.ordenUCI("Hash", "16")
        engine.ordenUCI("Threads", "1")
        dic_engines[alias] = engine
        return engine
示例#8
0
    def lee_motores_externos(self):
        li = Util.restore_pickle(self.file_external_engines())
        if li:
            from Code.Engines import Engines

            for x in li:
                eng = Engines.Engine()
                eng.restore(x)
                key = eng.key
                n = 0
                while eng.key in self.dic_engines:
                    n += 1
                    eng.key = "%s-%d" % (key, n)
                eng.set_extern()
                self.dic_engines[eng.key] = eng
示例#9
0
    def command(self):
        separador = FormLayout.separador
        li_gen = [separador]
        li_gen.append(separador)
        config = FormLayout.Fichero(_("File"),
                                    "exe" if Code.is_windows else "*", False)
        li_gen.append((config, ""))

        for num in range(1, 11):
            li_gen.append(("%s:" % (_("Argument %d") % num), ""))
        li_gen.append(separador)
        resultado = FormLayout.fedit(li_gen,
                                     title=_("Command"),
                                     parent=self,
                                     anchoMinimo=600,
                                     icon=Iconos.Terminal())
        if resultado:
            nada, resp = resultado
            command = resp[0]
            liArgs = []
            if not command or not os.path.isfile(command):
                return
            for x in range(1, len(resp)):
                arg = resp[x].strip()
                if arg:
                    liArgs.append(arg)

            um = QTUtil2.unMomento(self)
            me = Engines.Engine(path_exe=command, args=liArgs)
            li_uci = me.read_uci_options()
            um.final()
            if not li_uci:
                QTUtil2.message_bold(
                    self,
                    _X(
                        _("The file %1 does not correspond to a UCI engine type."
                          ), command))
                return None

            # Editamos
            w = WEngine(self, self.lista_motores, me)
            if w.exec_():
                self.lista_motores.append(me)
                self.grid.refresh()
                self.grid.gobottom(0)
                self.grabar()
    def restore_state(self, dic):
        engine_rival = Engines.Engine()
        engine_rival.restore(dic["engine_rival"])
        engine_rival.pgana = dic["pgana"]
        engine_rival.ptablas = dic["ptablas"]
        engine_rival.ppierde = dic["ppierde"]
        engine_rival.alias = dic["alias"]

        minutos = dic["minutos"]
        segundos = dic["segundos"]

        self.base_inicio(engine_rival, minutos, segundos)

        self.game.restore(dic["game_save"])

        self.vtime[WHITE].restore(dic["time_white"])
        self.vtime[BLACK].restore(dic["time_black"])

        self.goto_end()
示例#11
0
 def mas(clave, autor, version, url, exe, elo):
     path_exe = os.path.join(folder_engines, clave, exe)
     engine = Engines.Engine(clave, autor, version, url, path_exe)
     engine.elo = elo
     dic_engines[clave] = engine
     return engine