Esempio n. 1
0
    def __init__(self,
                 nombre,
                 exe,
                 liOpcionesUCI=None,
                 nMultiPV=0,
                 priority=EngineThread.PRIORITY_NORMAL,
                 args=None):
        self.nombre = nombre

        self.ponder = False
        self.pondering = False

        self.is_white = True

        self.guiDispatch = None
        self.ultDispatch = 0
        self.minDispatch = 1.0  # segundos
        self.whoDispatch = nombre
        self.uci_ok = False
        self.pid = None

        self.uci_lines = []

        if not os.path.isfile(exe):
            return

        self.engine = EngineThread.EnginePOP(exe, priority, args)
        self.engine.start()

        # time.sleep(0.01)
        # n = 100
        # while self.engine.starting and n:
        #     time.sleep(0.1 if n > 50 else 0.2)
        #     n-= 1

        self.lockAC = True
        self.pid = self.engine.pid

        self.order_uci()

        txt_uci_analysemode = "UCI_AnalyseMode"
        uci_analysemode = False

        if liOpcionesUCI:
            for opcion, valor in liOpcionesUCI:
                if type(valor) == bool:
                    valor = str(valor).lower()
                self.set_option(opcion, valor)
                if opcion == txt_uci_analysemode:
                    uci_analysemode = True
                if opcion.lower() == "ponder":
                    self.ponder = valor == "true"

        self.nMultiPV = nMultiPV
        if nMultiPV:
            self.ponMultiPV(nMultiPV)
            if not uci_analysemode:
                for line in self.uci_lines:
                    if "UCI_AnalyseMode" in line:
                        self.set_option("UCI_AnalyseMode", "true")
Esempio n. 2
0
    def __init__(self, nombre, exe, liOpcionesUCI=None, nMultiPV=0, priority=None, args=None):
        self.nombre = nombre

        self.ponder = False
        self.pondering = False

        self.is_white = True

        self.guiDispatch = None
        self.ultDispatch = 0
        self.minDispatch = 1.0  # segundos
        self.whoDispatch = nombre
        self.uci_ok = False
        self.pid = None

        self.log = None

        self.uci_lines = []

        if not os.path.isfile(exe):
            return

        self.engine = EngineThread.Engine(exe, priority, args)
        self.engine.start()

        self.lockAC = True
        self.pid = self.engine.pid

        self.order_uci()

        txt_uci_analysemode = "UCI_AnalyseMode"
        uci_analysemode = False

        setoptions = False
        if liOpcionesUCI:
            for opcion, valor in liOpcionesUCI:
                if type(valor) == bool:
                    valor = str(valor).lower()
                self.set_option(opcion, valor)
                setoptions = True
                if opcion == txt_uci_analysemode:
                    uci_analysemode = True
                if opcion.lower() == "ponder":
                    self.ponder = valor == "true"

        self.nMultiPV = nMultiPV
        if nMultiPV:
            self.ponMultiPV(nMultiPV)
            if not uci_analysemode:
                for line in self.uci_lines:
                    if "UCI_AnalyseMode" in line:
                        self.set_option("UCI_AnalyseMode", "true")
                        setoptions = True
        if setoptions:
            self.put_line("isready")
            self.wait_mrm("readyok", 1000)

        self.ucinewgame()