def piensa_rival(self): self.human_is_playing = False self.is_rival_thinking = True self.disable_all() if self.is_playing_gameobj(): if self.game_obj and self.pos_obj == len(self.game_obj): self.is_rival_thinking = False self.lineaTerminadaOpciones() return move = self.game_obj.move(self.pos_obj) self.pos_obj += 1 from_sq, to_sq, promotion = move.from_sq, move.to_sq, move.promotion else: self.thinking(True) self.rm_rival = self.xrival.juega() self.thinking(False) from_sq, to_sq, promotion = (self.rm_rival.from_sq, self.rm_rival.to_sq, self.rm_rival.promotion) self.is_rival_thinking = False ok, mens, move = Move.get_game_move(self.game, self.game.last_position, from_sq, to_sq, promotion) self.is_analyzed_by_tutor = False is_obj = self.is_playing_gameobj() self.move_the_pieces(move.liMovs, True) self.add_move(move, False) if is_obj: self.lineaTerminadaOpciones() self.play_next_move()
def leerLIPV(self, lipv): position = self.last_position pv = [] for mov in lipv: if len(mov) >= 4 and mov[0] in "abcdefgh" and mov[ 1] in "12345678" and mov[2] in "abcdefgh" and mov[ 3] in "12345678": pv.append(mov) else: break siB = self.is_white for mov in pv: from_sq = mov[:2] to_sq = mov[2:4] if len(mov) == 5: promotion = mov[4] if siB: promotion = promotion.upper() else: promotion = None ok, mens, move = Move.get_game_move(self, position, from_sq, to_sq, promotion) if ok: self.li_moves.append(move) position = move.position siB = not siB return self
def player_has_moved(self, from_sq, to_sq, promotion=""): if self.timer: self.ms += int((time.time() - self.timer) * 1000) self.moves += 1 self.timer = None movimiento = from_sq + to_sq # Peon coronando if not promotion and self.game.last_position.siPeonCoronando( from_sq, to_sq): promotion = self.board.peonCoronando( self.game.last_position.is_white) if promotion: movimiento += promotion ok, self.error, move = Move.get_game_move(self.game, self.game.last_position, from_sq, to_sq, promotion) if ok: self.game.add_move(move) self.board.set_position(move.position) self.sigueMaquina() return True else: return False
def juegaRival(self): if self.is_opening: pv = self.liPVopening[self.posOpening] self.posOpening += 1 if self.posOpening == len(self.liPVopening): self.is_opening = False else: fen = self.game.last_position.fen() pv = None if self.book: pv = self.book.eligeJugadaTipo(fen, "au") if not pv: self.book = None if not pv: if len(self.game.last_position) <= 4: t4 = LibChess.T4(self.configuration) pv = t4.best_move(fen) t4.close() if not pv: pv = self.engine.play(fen) ok, mens, move = Move.get_game_move(self.game, self.game.last_position, pv[:2], pv[2:4], pv[4:]) self.add_move(move, False) self.move_the_pieces(move.liMovs, True) self.play_next_move()
def play_rival(self, rm_rival): self.reloj_stop(False) self.thinking(False) time_s = self.timekeeper.stop() self.setSummary("TIMERIVAL", time_s) if self.state in (ST_ENDGAME, ST_PAUSE): return self.state == ST_ENDGAME if self.nAjustarFuerza == ADJUST_SELECTED_BY_PLAYER and hasattr(rm_rival, "li_rm"): rm_rival = self.ajustaPlayer(rm_rival) self.lirm_engine.append(rm_rival) if not self.valoraRMrival(): self.muestra_resultado() return True ok, self.error, move = Move.get_game_move(self.game, self.game.last_position, rm_rival.from_sq, rm_rival.to_sq, rm_rival.promotion) self.rm_rival = rm_rival if ok: fen_ultimo = self.last_fen() move.set_time_ms(int(time_s * 1000)) self.add_move(move, False) self.move_the_pieces(move.liMovs, True) if self.siTiempo: move.cacheTime = self.vtime[self.is_engine_side_white].save() self.cache[fen_ultimo] = move self.play_next_move() return True else: return False
def help_to_move(self): if not self.is_finished(): move = Move.Move(self.game, position_before=self.game.last_position.copia()) if self.is_tutor_enabled: self.analizaFinal() move.analysis = self.mrmTutor, 0 Analysis.show_analysis(self.procesador, self.xtutor, move, self.board.is_white_bottom, 999, 0, must_save=False)
def juegaRival(self): self.thinking(True) self.disable_all() from_sq = to_sq = promotion = "" siEncontrada = False if self.opening: siEncontrada, from_sq, to_sq, promotion = self.opening.run_engine(self.last_fen()) if not siEncontrada: self.opening = None if siEncontrada: self.rm_rival = EngineResponse.EngineResponse("Opening", self.is_engine_side_white) self.rm_rival.from_sq = from_sq self.rm_rival.to_sq = to_sq self.rm_rival.promotion = promotion else: self.rm_rival = self.xrival.play_time(self.game, self.tmRival, self.tmRival, 0) self.thinking(False) ok, self.error, move = Move.get_game_move( self.game, self.game.last_position, self.rm_rival.from_sq, self.rm_rival.to_sq, self.rm_rival.promotion ) if ok: self.add_move(move, False) self.move_the_pieces(move.liMovs, True) return True else: return False
def player_has_moved(self, from_sq, to_sq, promotion=""): move = self.check_human_move(from_sq, to_sq, promotion) if not move: return False a1h8 = move.movimiento() ok = False if self.is_playing_gameobj(): move_obj = self.game_obj.move(self.pos_obj) is_main, is_var = move_obj.test_a1h8(a1h8) if is_main: ok = True self.pos_obj += 1 elif is_var: li_movs = [(move_obj.from_sq, move_obj.to_sq, True)] for a1h8_m in move.variations.list_movimientos(): li_movs.append((a1h8_m[:2], a1h8[2:4], False)) self.board.ponFlechasTmp(li_movs) else: if a1h8[:2] != move_obj.from_sq: self.board.markPosition(move_obj.from_sq) else: self.board.ponFlechasTmp( ([move_obj.from_sq, move_obj.to_sq, True], )) if not ok: self.sigueHumano() return False if not ok: if self.is_tutor_enabled: if not self.is_analyzed_by_tutor: self.analizaTutor() if self.mrmTutor.mejorMovQue(a1h8): if not move.is_mate: tutor = Tutor.Tutor(self, self, move, from_sq, to_sq, False) if tutor.elegir(True): self.set_piece_again(from_sq) from_sq = tutor.from_sq to_sq = tutor.to_sq promotion = tutor.promotion si_bien, mens, move_tutor = Move.get_game_move( self.game, self.game.last_position, from_sq, to_sq, promotion) if si_bien: move = move_tutor del tutor self.mrmTutor = None self.move_the_pieces(move.liMovs) self.add_move(move, True) if self.game_obj and self.pos_obj >= len(self.game_obj): self.lineaTerminadaOpciones() self.play_next_move() return True
def player_has_moved(self, from_sq, to_sq, promotion=""): move = self.check_human_move(from_sq, to_sq, promotion) if not move: return False movimiento = move.movimiento() self.add_time() siAnalisis = False is_selected = False if self.opening: fenBase = self.last_fen() if self.opening.check_human(fenBase, from_sq, to_sq): is_selected = True else: self.opening = None self.analizaFinal() # tiene que acabar siempre if not is_selected: rmUser, n = self.mrmTutor.buscaRM(movimiento) if not rmUser: rmUser = self.xtutor.valora(self.game.last_position, from_sq, to_sq, move.promotion) if not rmUser: self.sigueHumanoAnalisis() return False self.mrmTutor.agregaRM(rmUser) siAnalisis = True pointsBest, pointsUser = self.mrmTutor.difPointsBest(movimiento) if (pointsBest - pointsUser) > 0: if not move.is_mate: tutor = Tutor.Tutor(self, self, move, from_sq, to_sq, False) if tutor.elegir(True): self.set_piece_again(from_sq) from_sq = tutor.from_sq to_sq = tutor.to_sq promotion = tutor.promotion ok, mens, jgTutor = Move.get_game_move( self.game, self.game.last_position, from_sq, to_sq, promotion) if ok: move = jgTutor self.add_hint() del tutor self.move_the_pieces(move.liMovs) if siAnalisis: rm, nPos = self.mrmTutor.buscaRM(move.movimiento()) if rm: move.analysis = self.mrmTutor, nPos self.add_move(move, True) self.error = "" self.play_next_move() return True
def juegaRival(self): if not self.is_finished(): self.thinking(True) rm = self.xrival.play_game(self.game, nAjustado=self.xrival.nAjustarFuerza) if rm.from_sq: ok, self.error, move = Move.get_game_move(self.game, self.game.last_position, rm.from_sq, rm.to_sq, rm.promotion) self.add_move(move) self.move_the_pieces(move.liMovs) self.thinking(False)
def play_rival(self): si_obligatorio = len(self.game) <= self.plies_mandatory si_pensar = True fenm2 = self.game.last_position.fenm2() moves = self.dicFENm2.get(fenm2, set()) if si_obligatorio: nmoves = len(moves) if nmoves == 0: si_obligatorio = False else: move = self.dbop.get_cache_engines(self.keyengine, self.time, fenm2) if move is None: if self.book: move_book = self.book.eligeJugadaTipo( self.game.last_position.fen(), "au") if move_book in list(moves): move = move_book if move is None: move = random.choice(list(moves)) self.dbop.set_cache_engines(self.keyengine, self.time, fenm2, move) from_sq, to_sq, promotion = move[:2], move[2:4], move[4:] si_pensar = False if si_pensar: move = self.dbop.get_cache_engines(self.keyengine, self.time, fenm2) if self.book: move = self.book.eligeJugadaTipo(self.game.last_position.fen(), self.book.mode) if not move: rm_rival = self.xrival.juegaPartida(self.game) move = rm_rival.movimiento() self.dbop.set_cache_engines(self.keyengine, self.time, fenm2, move) from_sq, to_sq, promotion = move[:2], move[2:4], move[4:] if si_obligatorio: if not (move in moves): move = list(moves)[0] from_sq, to_sq, promotion = move[:2], move[2:4], move[4:] ok, mens, move = Move.get_game_move(self.game, self.game.last_position, from_sq, to_sq, promotion) if ok: self.add_move(move, False) self.move_the_pieces(move.liMovs, True) self.error = "" return True else: self.error = mens return False
def player_has_moved(self, from_sq, to_sq, promotion=""): move = self.check_human_move(from_sq, to_sq, promotion) if not move: return False movimiento = move.movimiento() self.analizaFinal() siMirarTutor = self.is_tutor_enabled if self.in_the_opening: if self.opening.check_human(self.last_fen(), from_sq, to_sq): siMirarTutor = False if siMirarTutor: if not self.is_analyzed_by_tutor: self.mrmTutor = self.analizaTutor() if self.mrmTutor is None: self.sigueHumano() return False if not self.tutor_book.si_esta(self.last_fen(), movimiento): if self.mrmTutor.mejorMovQue(movimiento): self.refresh() if not move.is_mate: tutor = Tutor.Tutor(self, self, move, from_sq, to_sq, False) if self.in_the_opening: liApPosibles = self.listaOpeningsStd.list_possible_openings( self.game) else: liApPosibles = None if tutor.elegir(self.hints > 0, liApPosibles=liApPosibles): if self.hints > 0: # doble entrada a tutor. self.set_piece_again(from_sq) self.hints -= 1 from_sq = tutor.from_sq to_sq = tutor.to_sq promotion = tutor.promotion ok, mens, jgTutor = Move.get_game_move( self.game, self.game.last_position, from_sq, to_sq, promotion) if ok: move = jgTutor elif self.configuration.x_save_tutor_variations: tutor.ponVariations(move, 1 + len(self.game) / 2) del tutor self.move_the_pieces(move.liMovs) self.add_move(move, True) self.play_next_move() return True
def play_rival(self, from_sq, to_sq, promotion): ok, mens, move = Move.get_game_move(self.game, self.game.last_position, from_sq, to_sq, promotion) if ok: self.add_move(move, False) self.move_the_pieces(move.liMovs, True) self.error = "" return True else: self.error = mens return False
def phase2(self, entry:os.DirEntry): db = LIBridge(entry.path) for x in range(len(db)): dato = db[x] dic = eval(dato) if "INIFEN" in dic: g = Game.Game(fen=dic["INIFEN"]) else: g = Game.Game() g.set_tags(dic["LITAGS"]) result = g.get_tag("Result") g.set_termination(dic["TERMINATION"], result if result else RESULT_UNKNOWN) li_moves = dic["MOVES"] current_position = g.last_position.copia() for dic_mv in li_moves: pv = dic_mv["MV"] position = current_position.copia() position.moverPV(pv) move = Move.Move(g, position_before=current_position, position=position, from_sq=pv[:2], to_sq=pv[2:4], promotion=pv[4:]) if "VARIATIONS" in dic_mv: li_varpgn = dic_mv["VARIATIONS"] fen_base = current_position.fen() for varpgn in li_varpgn: gv = Game.fen_game(fen_base, varpgn) if gv: move.add_variation(gv) if "COMMENT" in dic_mv: move.comment = dic_mv["COMMENT"] if "$NAGS" in dic_mv: nags = dic_mv["$NAGS"] for nag in nags.split(" "): if nag.isdigit(): move.add_nag(int(nag)) if "NAGS" in dic_mv: nags = dic_mv["NAGS"] for nag in nags.split(" "): if nag in self.dic_cnags: move.add_nag(self.dic_cnags[nag]) if "MRM" in dic_mv: mrm_pos = dic_mv["MRM_POS"] mrm_save = dic_mv["MRM"] mrm = EngineResponse.MultiEngineResponse(None, True) mrm.restore(mrm_save) move.analysis = mrm, mrm_pos current_position = position.copia() g.add_move(move) print(dic) db.close()
def play_next_move(self): if self.test_is_finished(): return False self.current_side = is_white = self.game.is_white() self.board.set_side_indicator(is_white) move_found = False analysis = None bk = self.book[is_white] if bk: move_found, from_sq, to_sq, promotion = self.eligeJugadaBook( bk, self.bookRR[is_white]) if not move_found: self.book[is_white] = None if not move_found: xrival = self.xengine[is_white] tiempoBlancas = self.vtime[True].tiempoPendiente tiempoNegras = self.vtime[False].tiempoPendiente segundosJugada = xrival.motorTiempoJugada self.reloj_start(is_white) mrm = xrival.juegaTiempoTorneo(self.game, tiempoBlancas, tiempoNegras, segundosJugada) if self.state == ST_PAUSE: self.reloj_pause(is_white) self.board.borraMovibles() return True self.reloj_stop(is_white) if mrm is None: return False rm = mrm.mejorMov() from_sq = rm.from_sq to_sq = rm.to_sq promotion = rm.promotion analysis = mrm, 0 ok, mens, move = Move.get_game_move(self.game, self.game.last_position, from_sq, to_sq, promotion) if not move: return False if analysis: move.analysis = analysis move.del_nags() self.add_move(move) self.move_the_pieces(move.liMovs) return True
def player_has_moved(self, from_sq, to_sq, promotion=""): cpActual = self.game.move(self.pos_move).position if self.pos_move >= 0 else self.game.first_position if cpActual.siPeonCoronando(from_sq, to_sq): promotion = self.board.peonCoronando(cpActual.is_white) ok, mens, move = Move.get_game_move(self.game, cpActual, from_sq, to_sq, promotion) if ok: game = Game.Game() game.assign_other_game(self.game) if self.pos_move < len(self.game) - 1: game.li_moves = game.li_moves[: self.pos_move + 1] game.add_move(move) self.panelOpening.player_has_moved(game)
def play_rival(self, engine_response): from_sq = engine_response.from_sq to_sq = engine_response.to_sq promotion = engine_response.promotion ok, mens, move = Move.get_game_move(self.game, self.game.last_position, from_sq, to_sq, promotion) if ok: self.error = "" self.add_move(move, False) self.move_the_pieces(move.liMovs, True) return True else: self.error = mens return False
def juegaHumano(self, is_white): self.reloj_start(True) self.timekeeper.start() self.human_is_playing = True if self.premove: from_sq, to_sq = self.premove promotion = "q" if self.game.last_position.siPeonCoronando(from_sq, to_sq) else None ok, error, move = Move.get_game_move(self.game, self.game.last_position, self.premove[0], self.premove[1], promotion) if ok: self.player_has_moved(from_sq, to_sq, promotion) return self.premove = None self.pon_toolbar() self.analizaInicio() self.activate_side(is_white)
def player_has_moved(self, from_sq, to_sq, promotion=""): self.board.disable_all() # Peon coronando if not promotion and self.position.siPeonCoronando(from_sq, to_sq): promotion = self.board.peonCoronando(self.position.is_white) ok, mens, move = Move.get_game_move(None, self.position, from_sq, to_sq, promotion) if ok: self.board.set_position(move.position) self.board.put_arrow_sc(from_sq, to_sq) self.hechaJugada(move) else: self.ponJuego() return False return True
def ayuda(self): if self.human_is_playing: self.paraHumano() else: return self.board.set_position(self.game.last_position) main = self.list_moves[0][4] saux = False paux = 0 for n, jug in enumerate(self.list_moves): opacity = p = jug[4] simain = p == main if not simain: if not saux: paux = p saux = True opacity = 1.0 if p == paux else max(p, 0.25) self.board.creaFlechaMulti(jug[0] + jug[1], siMain=simain, opacity=opacity) resp = WindowBooks.eligeJugadaBooks(self.main_window, self.list_moves, self.human_side, siSelectSiempre=False) self.board.remove_arrows() if resp is None: self.sumar_aciertos = False self.sigueHumano() return xfrom, xto, promotion = resp ok, mens, jg = Move.get_game_move(self.game, self.game.last_position, xfrom, xto, promotion) self.movimientos += 1 self.set_label3("<b>%s</b>" % self.txt_matches()) self.move_the_pieces(jg.liMovs) self.masJugada(jg, True) self.error = "" self.sumar_aciertos = True self.siguienteJugada()
def restore(self, btxt_save): dic = Util.zip2var(btxt_save) self.first_position = Position.Position() self.first_position.read_fen(dic["first_position"]) self.first_comment = dic["first_comment"] self.result = dic["result"] self.termination = dic["termination"] self.li_moves = [] cp = self.first_position.copia() for save_jg in dic["li_moves"]: move = Move.Move(self, position_before=cp) move.restore(save_jg) cp = move.position.copia() self.li_moves.append(move) self.assign_opening() self.si3repetidas() self.li_tags = dic.get("li_tags", [])
def player_has_moved(self, from_sq, to_sq, promotion=""): # Peon coronando if not promotion and self.position_before.siPeonCoronando(from_sq, to_sq): promotion = self.w.board.peonCoronando(not self.move.position.is_white) if promotion is None: return False si_bien, mens, new_move = Move.get_game_move(None, self.position_before, from_sq, to_sq, promotion) if si_bien: self.move_the_pieces(new_move.liMovs) self.w.board.put_arrow_sc(new_move.from_sq, new_move.to_sq) self.analyse_move(new_move) return True else: return False
def player_has_moved(self, from_sq, to_sq, promotion=""): self.board.disable_all() movimiento = from_sq + to_sq position = self.game.move(self.posCurrent).position if self.posCurrent >= 0 else self.game.last_position # Peon coronando if not promotion and position.siPeonCoronando(from_sq, to_sq): promotion = self.board.peonCoronando(position.is_white) if promotion: movimiento += promotion ok, mens, move = Move.get_game_move(self.game, position, from_sq, to_sq, promotion) if ok: self.nuevaJugada(move) else: self.actualizaPosicion()
def player_has_moved(self, from_sq, to_sq, promotion=""): if not promotion and self.game.last_position.siPeonCoronando( from_sq, to_sq): promotion = self.board.peonCoronando( self.game.last_position.is_white) ok, mens, move = Move.get_game_move(self.game, self.game.last_position, from_sq, to_sq, promotion) if ok: self.game.add_move(move) self.board.set_position(move.position) self.board.put_arrow_sc(move.from_sq, move.to_sq) self.play_next_move() return True else: return False
def play_rival(self, book_response): xfrom = book_response.from_sq xto = book_response.to_sq promotion = book_response.promotion ok, mens, jg = Move.get_game_move(self.game, self.game.last_position, xfrom, xto, promotion) if ok: self.ponVariantes(jg) self.masJugada(jg, False) self.move_the_pieces(jg.liMovs, True) self.error = "" return True else: self.error = mens return False
def player_has_moved(self, from_sq, to_sq, promotion=""): self.paraHumano() movimiento = from_sq + to_sq # Peon coronando if not promotion and self.position.siPeonCoronando(from_sq, to_sq): promotion = self.board.peonCoronando(self.position.is_white) if promotion: movimiento += promotion game = Game.Game(ini_posicion=self.position) ok, mens, self.move = Move.get_game_move(game, self.position, from_sq, to_sq, promotion) if ok: self.board.set_position(self.move.position) self.board.put_arrow_sc(from_sq, to_sq) self.calculaTiempoPuntos() else: self.sigueHumano()
def get_moves_txt(self, position_before, is_gm): li = [] d_repeticiones = {} for gmPartida in self.li_gm_games: move = gmPartida.move(self.ply) if move: if not (move in d_repeticiones): d_repeticiones[move] = [len(li), 1] from_sq, to_sq, promotion = move[:2], move[2:4], move[4:] ok, mens, move = Move.get_game_move( gmPartida, position_before, from_sq, to_sq, promotion) li.append([ from_sq, to_sq, promotion, gmPartida.basic_label(is_gm), move.pgn_translated() ]) else: d_repeticiones[move][1] += 1 pos = d_repeticiones[move][0] li[pos][3] = _("%d games") % d_repeticiones[move][1] return li
def player_has_moved(self, from_sq, to_sq, promotion=""): self.human_is_playing = True # necesario para el check move = self.check_human_move(from_sq, to_sq, promotion) if not move: return False self.game.add_move(move) self.game.check() if self.siAyuda: self.board.remove_arrows() self.move_the_pieces(move.liMovs, False) if self.game.is_finished(): if move.is_mate: self.siguienteMate() else: self.repiteMate(True, True) return self.numMov += 1 if self.numMov == self.mate: self.repiteMate(True, True) return # Juega rival con depth 3 rm = self.xrival.play_game(self.game) from_sq = rm.from_sq to_sq = rm.to_sq promotion = rm.promotion ok, mens, move = Move.get_game_move(self.game, self.game.last_position, from_sq, to_sq, promotion) self.game.add_move(move) self.put_arrow_sc(move.from_sq, move.to_sq) self.move_the_pieces(move.liMovs, False) if self.is_finished(): self.repiteMate(True, True) return self.activate_side( self.human_side ) # Caso en que hay promotion, sino no se activa la dama
def sigueMaquina(self): ended, go_next = self.test_final() if ended: if go_next: self.play_next() return lista = self.t4.best_moves_game(self.game) if len(lista) == 0: return move = random.choice(lista) from_sq, to_sq, promotion = move[:2], move[2:4], move[4:] ok, mens, move = Move.get_game_move(self.game, self.game.last_position, from_sq, to_sq, promotion) self.game.add_move(move) for movim in move.liMovs: if movim[0] == "b": self.board.borraPieza(movim[1]) elif movim[0] == "m": self.board.muevePieza(movim[1], movim[2]) elif movim[0] == "c": self.board.cambiaPieza(movim[1], movim[2]) self.timer = time.time() self.sigueHumano()
def player_has_moved(self, from_sq, to_sq, promotion=""): if not self.human_is_playing: return self.check_premove(from_sq, to_sq) move = self.check_human_move(from_sq, to_sq, promotion, not self.is_tutor_enabled) if not move: return False movimiento = move.movimiento() siAnalisis = False is_selected = False fen_base = self.last_fen() if self.bookR and self.bookMandatory: listaJugadas = self.bookR.get_list_moves(fen_base) if listaJugadas: li = [] for apdesde, aphasta, appromotion, nada, nada1 in listaJugadas: mx = apdesde + aphasta + appromotion if mx.strip().lower() == movimiento: is_selected = True break li.append((apdesde, aphasta, False)) if not is_selected: self.board.ponFlechasTmp(li) self.sigueHumano() return False if not is_selected and self.aperturaObl: if self.aperturaObl.check_human(fen_base, from_sq, to_sq): is_selected = True else: apdesde, aphasta = self.aperturaObl.from_to_active(fen_base) if apdesde is None: self.aperturaObl = None else: self.board.ponFlechasTmp(((apdesde, aphasta, False), )) self.sigueHumano() return False if not is_selected and self.aperturaStd: if self.aperturaStd.check_human(fen_base, from_sq, to_sq): is_selected = True else: if not self.aperturaStd.is_active(fen_base): self.aperturaStd = None is_mate = move.is_mate self.analizaFinal(is_mate) # tiene que acabar siempre if not is_mate and not is_selected and self.is_tutor_enabled: if not self.tutor_book.si_esta(fen_base, movimiento): rmUser, n = self.mrmTutor.buscaRM(movimiento) if not rmUser: self.main_window.pensando_tutor(True) rmUser = self.xtutor.valora(self.game.last_position, from_sq, to_sq, move.promotion) self.main_window.pensando_tutor(False) if not rmUser: self.sigueHumanoAnalisis() return False self.mrmTutor.agregaRM(rmUser) siAnalisis = True pointsBest, pointsUser = self.mrmTutor.difPointsBest( movimiento) self.setSummary("POINTSBEST", pointsBest) self.setSummary("POINTSUSER", pointsUser) difpts = self.configuration.x_tutor_difpoints difporc = self.configuration.x_tutor_difporc if self.mrmTutor.mejorRMQue(rmUser, difpts, difporc): if not move.is_mate: si_tutor = True if self.chance: num = self.mrmTutor.numMejorMovQue(movimiento) if num: rmTutor = self.mrmTutor.rmBest() menu = QTVarios.LCMenu(self.main_window) menu.opcion("None", _("There are %d best moves") % num, Iconos.Motor()) menu.separador() resp = rmTutor.abrTextoBase() if not resp: resp = _("Mate") menu.opcion( "tutor", "&1. %s (%s)" % (_("Show tutor"), resp), Iconos.Tutor(), ) menu.separador() menu.opcion("try", "&2. %s" % _("Try again"), Iconos.Atras()) menu.separador() menu.opcion( "user", "&3. %s (%s)" % (_("Select my move"), rmUser.abrTextoBase()), Iconos.Player(), ) self.main_window.cursorFueraBoard() resp = menu.lanza() if resp == "try": self.sigueHumanoAnalisis() return False elif resp == "user": si_tutor = False elif resp != "tutor": self.sigueHumanoAnalisis() return False if si_tutor: tutor = Tutor.Tutor(self, move, from_sq, to_sq, False) if self.aperturaStd: liApPosibles = self.listaOpeningsStd.list_possible_openings( self.game) else: liApPosibles = None if tutor.elegir(self.hints > 0, liApPosibles=liApPosibles): if self.hints > 0: # doble entrada a tutor. self.set_piece_again(from_sq) self.hints -= 1 self.tutor_con_flechas = self.nArrowsTt > 0 and self.hints > 0 from_sq = tutor.from_sq to_sq = tutor.to_sq promotion = tutor.promotion ok, mens, jgTutor = Move.get_game_move( self.game, self.game.last_position, from_sq, to_sq, promotion) if ok: move = jgTutor self.setSummary("SELECTTUTOR", True) if self.configuration.x_save_tutor_variations: tutor.ponVariations(move, 1 + len(self.game) / 2) del tutor self.setSummary("TIMEUSER", self.timekeeper.stop()) self.reloj_stop(True) self.move_the_pieces(move.liMovs) if siAnalisis: rm, nPos = self.mrmTutor.buscaRM(move.movimiento()) if rm: move.analysis = self.mrmTutor, nPos self.add_move(move, True) self.error = "" self.play_next_move() return True