def __init__(self): if Code.list_engine_managers is None: Code.list_engine_managers = EngineManager.ListEngineManagers() self.web = "https://lucaschess.pythonanywhere.com" self.blog = "https://lucaschess.blogspot.com" self.github = "https://github.com/lukasmonk/lucaschessR"
def __init__(self, manager, cromo): self.cromo = cromo self.manager = manager self.game = manager.game self.name = cromo.name self.xirina = None self.xsimilar = None conf_engine = self.manager.configuration.buscaRival("irina") self.xirina = EngineManager.EngineManager(self.manager.procesador, conf_engine) self.xirina.options(None, 1, False) self.opening = self.cromo.opening if self.opening: bookdef = Code.tbookPTZ name = os.path.basename(bookdef)[:-4] self.book = Books.Book("P", name, bookdef, True) self.book.polyglot() # De compatibilidad self.motorTiempoJugada = 0 self.motorProfundidad = 0 atexit.register(self.cerrar)
def creaManagerMotor(self, confMotor, vtime, nivel, siMultiPV=False, priority=None): xmanager = EngineManager.EngineManager(self, confMotor) xmanager.options(vtime, nivel, siMultiPV) xmanager.setPriority(priority) return xmanager
def creaGestorMotor(self, confMotor, vtime, nivel, siMultiPV=False, priority=None): xgestor = EngineManager.EngineManager(self, confMotor) xgestor.opciones(vtime, nivel, siMultiPV) xgestor.setPriority(priority) return xgestor
def creaXTutor(self): xtutor = EngineManager.EngineManager(self, self.configuration.tutor) xtutor.function = _("tutor") xtutor.options(self.configuration.x_tutor_mstime, self.configuration.x_tutor_depth, True) if self.configuration.x_tutor_multipv == 0: xtutor.maximize_multipv() else: xtutor.set_multipv(self.configuration.x_tutor_multipv) self.xtutor = xtutor
def creaXTutor(self): xtutor = EngineManager.EngineManager(self, self.configuracion.tutor) xtutor.name += "(%s)" % _("tutor") xtutor.opciones(self.configuracion.x_tutor_mstime, self.configuracion.x_tutor_depth, True) if self.configuracion.x_tutor_multipv == 0: xtutor.maximizaMultiPV() else: xtutor.setMultiPV(self.configuracion.x_tutor_multipv) self.xtutor = xtutor
def creaXAnalyzer(self): xanalyzer = EngineManager.EngineManager(self, self.configuration.tutor) xanalyzer.function = _("analyzer") xanalyzer.options(self.configuration.x_tutor_mstime, self.configuration.x_tutor_depth, True) if self.configuration.x_tutor_multipv == 0: xanalyzer.maximize_multipv() else: xanalyzer.set_multipv(self.configuration.x_tutor_multipv) self.xanalyzer = xanalyzer Code.xanalyzer = xanalyzer
def juega_similar(self, fen): if self.xsimilar is None: conf_engine = self.manager.configuration.buscaRival( self.cromo.engine) self.xsimilar = EngineManager.EngineManager( self.manager.procesador, conf_engine) self.xsimilar.options(None, 5, True) mrm = self.xsimilar.control(fen, 5) mrm.game = self.game return mrm.mejorMovAjustadoSimilar(self.cromo.dif_puntos, self.cromo.mate, self.cromo.aterrizaje)
def creaXAnalyzer(self): xanalyzer = EngineManager.EngineManager(self, self.configuration.tutor) xanalyzer.name += "(%s)" % _("analyzer") xanalyzer.options(self.configuration.x_tutor_mstime, self.configuration.x_tutor_depth, True) if self.configuration.x_tutor_multipv == 0: xanalyzer.maximizaMultiPV() else: xanalyzer.setMultiPV(self.configuration.x_tutor_multipv) self.xanalyzer = xanalyzer Code.xanalyzer = xanalyzer
def __init__(self, file_tournament, file_work): QtWidgets.QWidget.__init__(self) Code.list_engine_managers = EngineManager.ListEngineManagers() self.torneo = TournamentRun( file_tournament) # Tournament.Tournament(file_tournament) self.file_work = file_work self.db_work = UtilSQL.ListSQL(file_work) self.slow_pieces = self.torneo.slow_pieces() self.setWindowTitle( "%s - %s %d" % (self.torneo.name(), _("Worker"), int(file_work[-5:]))) self.setWindowIcon(Iconos.Torneos()) # Toolbar self.tb = Controles.TBrutina(self, icon_size=24) # Board conf_board = Code.configuration.config_board("TOURNEYPLAY", 36) self.board = Board.Board(self, conf_board) self.board.crea() Delegados.generaPM(self.board.piezas) # PGN self.configuration = Code.configuration self.game = Game.Game() self.pgn = ControlPGN.ControlPGN(self) ly_pgn = self.crea_bloque_informacion() self.is_closed = False self.state = None self.current_side = WHITE ly_tt = Colocacion.V().control(self.tb).control(self.board) layout = Colocacion.H().otro(ly_tt).otro(ly_pgn).relleno().margen(3) self.setLayout(layout) self.cpu = CPU.CPU(self) self.pon_estado(ST_WAITING)
def procesa_game(self): self.pon_estado(ST_PLAYING) # Configuración self.fen_inicial = self.torneo.fenNorman() # Cerramos los motores anteriores si los hay Code.list_engine_managers.close_all() if self.torneo.adjudicator_active(): conf_engine = Code.configuracion.buscaRival( self.torneo.adjudicator()) self.xadjudicator = EngineManager.EngineManager(self, conf_engine) self.xadjudicator.opciones(self.torneo.adjudicator_time() * 1000, 0, False) self.xadjudicator.anulaMultiPV() else: self.xadjudicator = None self.next_control = 0 self.max_segundos = self.tournament_game.minutos * 60.0 self.segundos_jugada = self.tournament_game.segundos_jugada # abrimos motores rival = { WHITE: self.torneo.buscaHEngine(self.tournament_game.hwhite), BLACK: self.torneo.buscaHEngine(self.tournament_game.hblack), } for side in (WHITE, BLACK): self.lb_player[side].ponTexto(rival[side].name) self.vtime = {} self.book = {} self.bookRR = {} self.xengine = {} for side in (WHITE, BLACK): rv = rival[side] self.xengine[side] = EngineManager.EngineManager(self, rv) self.xengine[side].opciones(rv.time * 1000, rv.depth, False) self.xengine[side].ponGuiDispatch(self.gui_dispatch) self.vtime[side] = Util.Timer(self.max_segundos) bk = rv.book if bk == "*": bk = self.torneo.book() if bk == "-": # Puede que el torneo tenga "-" bk = None if bk: self.book[side] = Books.Libro("P", bk, bk, True) self.book[side].polyglot() else: self.book[side] = None self.bookRR[side] = rv.bookRR self.game = Game.Game(fen=self.fen_inicial) self.pgn.game = self.game self.lbRotulo3.altoFijo(32) self.tablero.disable_all() self.tablero.setposition(self.game.last_position) self.grid_pgn.refresh() for side in (WHITE, BLACK): ot = self.vtime[side] eti, eti2 = ot.etiquetaDif2() self.pon_reloj_side(side, eti, eti2) while self.state == ST_PAUSE or self.siguiente_jugada(): if self.state == ST_PAUSE: QTUtil.refresh_gui() time.sleep(0.1) if self.is_closed: break for side in (WHITE, BLACK): self.xengine[side].terminar() if not self.is_closed: if self.game_finished(): self.save_game_done()