def restart(self, lost_points): self.terminaNoContinuo() change_game = self.expedition.add_try(False, self.vtime, self.puntos) self.vtime = 0.0 licoment = [] if lost_points: licoment.append(_("You have exceeded the limit of lost points.")) if change_game: licoment.append(_("You have exceeded the limit of tries, you will fall back to the previous.")) elif lost_points: licoment.append(_("You must repeat the game from beginning.")) if licoment: comment = "\n".join(licoment) w = WindowJuicio.MensajeF(self.main_window, comment) w.mostrar() return change_game
def player_has_moved(self, from_sq, to_sq, promotion=""): jgUsu = self.check_human_move(from_sq, to_sq, promotion) if not jgUsu: return False self.vtime += time.time() - self.iniTiempo jgObj = self.gameObj.move(self.posJugadaObj) siAnalizaJuez = True if self.book: fen = self.last_fen() siBookUsu = self.book.check_human(fen, from_sq, to_sq) siBookObj = self.book.check_human(fen, jgObj.from_sq, jgObj.to_sq) if siBookUsu and siBookObj: if jgObj.movimiento() != jgUsu.movimiento(): bmove = _("book move") comment = "%s: %s %s<br>%s: %s %s" % ( self.nombreObj, jgObj.pgn_translated(), bmove, self.configuration.x_player, jgUsu.pgn_translated(), bmove, ) w = WindowJuicio.MensajeF(self.main_window, comment) w.mostrar() siAnalizaJuez = False else: siAnalizaJuez = True if not siBookObj: self.book = None analysis = None comment = None if siAnalizaJuez: um = QTUtil2.analizando(self.main_window) pvUsu = jgUsu.movimiento() pvObj = jgObj.movimiento() mrm = self.analizaMinimo(pvUsu, pvObj) position = self.game.last_position rmUsu, nada = mrm.buscaRM(pvUsu) rmObj, posObj = mrm.buscaRM(pvObj) analysis = mrm, posObj um.final() w = WindowJuicio.WJuicio(self, self.xanalyzer, self.nombreObj, position, mrm, rmObj, rmUsu, analysis) w.exec_() analysis = w.analysis if w.siAnalisisCambiado: self.siSave = True dpts = w.difPuntos() self.puntos += dpts dptsMax = w.difPuntosMax() self.puntosMax += dptsMax comentarioUsu = " %s" % (rmUsu.abrTexto()) comentarioObj = " %s" % (rmObj.abrTexto()) comentarioPuntos = "%s = %d %+d %+d = %d" % ( _("Score"), self.puntos - dpts, rmUsu.centipawns_abs(), -rmObj.centipawns_abs(), self.puntos, ) comment = "%s: %s %s\n%s: %s %s\n%s" % ( self.nombreObj, jgObj.pgn_translated(), comentarioObj, self.configuration.x_player, jgUsu.pgn_translated(), comentarioUsu, comentarioPuntos, ) self.ponPuntos() self.analizaFinal() self.add_move(True, analysis, comment) self.play_next_move() return True
def player_has_moved(self, from_sq, to_sq, promotion=""): jgUsu = self.check_human_move(from_sq, to_sq, promotion) if not jgUsu: return False self.vtime += time.time() - self.iniTiempo jgObj = self.gameObj.move(self.posJugadaObj) fen = jgObj.position_before.fen() siAnalizaJuez = True if self.book: siBookUsu = self.book.check_human(fen, from_sq, to_sq) siBookObj = self.book.check_human(fen, jgObj.from_sq, jgObj.to_sq) if siBookUsu and siBookObj: if jgObj.movimiento() != jgUsu.movimiento(): bmove = _("book move") comment = "%s: %s %s<br>%s: %s %s" % ( self.nombreObj, jgObj.pgn_translated(), bmove, self.configuration.x_player, jgUsu.pgn_translated(), bmove, ) w = WindowJuicio.MensajeF(self.main_window, comment) w.mostrar() siAnalizaJuez = False else: siAnalizaJuez = True if not siBookObj: self.book = None analysis = None comment = None if siAnalizaJuez: position = self.game.last_position saved = fen in self.dic_analysis if saved: rmObj, posObj, analysis, mrm = self.dic_analysis[fen] else: if self.continueTt: um = QTUtil2.analizando(self.main_window) mrm = self.analizaMinimo( 3000) if self.continueTt else self.mrm um.final() else: self.analizaNoContinuoFinal() mrm = self.mrm rmObj, posObj = mrm.buscaRM(jgObj.movimiento()) analysis = mrm, posObj self.dic_analysis[fen] = [rmObj, posObj, analysis, mrm] rmUsu, posUsu = mrm.buscaRM(jgUsu.movimiento()) if rmUsu is None: um = QTUtil2.analizando(self.main_window) self.analizaFinal() rmUsu = self.xanalyzer.valora(position, from_sq, to_sq, promotion) mrm.agregaRM(rmUsu) self.analizaInicio() um.final() w = WindowJuicio.WJuicio(self, self.xanalyzer, self.nombreObj, position, mrm, rmObj, rmUsu, analysis, is_competitive=False) w.exec_() if not saved: analysis = w.analysis self.dic_analysis[fen][2] = analysis dpts = w.difPuntos() self.puntos += dpts self.ponPuntos() if posUsu != posObj: comentarioUsu = " %s" % (rmUsu.abrTexto()) comentarioObj = " %s" % (rmObj.abrTexto()) comentarioPuntos = "%s = %d %+d %+d = %d" % ( _("Score"), self.puntos - dpts, rmUsu.centipawns_abs(), -rmObj.centipawns_abs(), self.puntos, ) comment = "%s: %s %s\n%s: %s %s\n%s" % ( self.nombreObj, jgObj.pgn_translated(), comentarioObj, self.configuration.x_player, jgUsu.pgn_translated(), comentarioUsu, comentarioPuntos, ) if not self.continueTt: self.terminaNoContinuo() self.analizaFinal() self.add_move(True, analysis, comment) self.play_next_move() return True
def player_has_moved(self, from_sq, to_sq, promotion=""): jgUsu = self.check_human_move(from_sq, to_sq, promotion) if not jgUsu: return False jgObj = self.gameObj.move(self.posJugadaObj) analysis = None comment = None comentarioUsu = "" comentarioObj = "" siAnalizaJuez = jgUsu.movimiento() != jgObj.movimiento() if self.book: fen = self.last_fen() siBookUsu = self.book.check_human(fen, from_sq, to_sq) siBookObj = self.book.check_human(fen, jgObj.from_sq, jgObj.to_sq) if siBookUsu: comentarioUsu = _("book move") if siBookObj: comentarioObj = _("book move") if siBookUsu and siBookObj: if jgObj.movimiento() != jgUsu.movimiento(): # comment = "%s: %s" % (_("Same book move"), jgObj.pgn_translated()) # else: bmove = _("book move") comment = "%s: %s %s\n%s: %s %s" % ( self.nombreObj, jgObj.pgn_translated(), bmove, self.configuration.x_player, jgUsu.pgn_translated(), bmove, ) w = WindowJuicio.MensajeF(self.main_window, comment) w.mostrar() siAnalizaJuez = False else: if not siBookObj: self.book = None if siAnalizaJuez: um = QTUtil2.analizando(self.main_window) if not self.continueTt: self.analizaInicio() mrm = self.analizaMinimo(5000) position = self.game.last_position rmUsu, nada = mrm.buscaRM(jgUsu.movimiento()) if rmUsu is None: self.analizaFinal() rmUsu = self.xtutor.valora(position, jgUsu.from_sq, jgUsu.to_sq, jgUsu.promotion) mrm.agregaRM(rmUsu) self.analizaInicio() rmObj, posObj = mrm.buscaRM(jgObj.movimiento()) if rmObj is None: self.analizaFinal() rmObj = self.xtutor.valora(position, jgObj.from_sq, jgObj.to_sq, jgObj.promotion) posObj = mrm.agregaRM(rmObj) self.analizaInicio() analysis = mrm, posObj um.final() w = WindowJuicio.WJuicio(self, self.xtutor, self.nombreObj, position, mrm, rmObj, rmUsu, analysis) w.exec_() analysis = w.analysis dpts = w.difPuntos() self.puntos += dpts self.ponPuntos() comentarioUsu += " %s" % (rmUsu.abrTexto()) comentarioObj += " %s" % (rmObj.abrTexto()) comentarioPuntos = "%s = %d %+d %+d = %d" % ( _("Points"), self.puntos - dpts, rmUsu.centipawns_abs(), -rmObj.centipawns_abs(), self.puntos, ) comment = "%s: %s %s\n%s: %s %s\n%s" % ( self.nombreObj, jgObj.pgn_translated(), comentarioObj, self.configuration.x_player, jgUsu.pgn_translated(), comentarioUsu, comentarioPuntos, ) self.analizaFinal() self.add_move(True, comment, analysis) 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 movUsu = move.movimiento().lower() self.dbwashing.add_time(self.timekeeper.stop()) jgObj = self.gameObj.move(self.posJugadaObj) movObj = jgObj.movimiento().lower() if movUsu != movObj: lic = [] if jgObj.analysis: mrmObj, posObj = jgObj.analysis rmObj = mrmObj.li_rm[posObj] lic.append("%s: %s (%s)" % (_("Played previously"), jgObj.pgn_translated(), rmObj.abrTextoBase())) ptsObj = rmObj.centipawns_abs() rmUsu, posUsu = mrmObj.buscaRM(movUsu) if posUsu >= 0: lic.append("%s: %s (%s)" % (_("Played now"), move.pgn_translated(), rmUsu.abrTextoBase())) ptsUsu = rmUsu.centipawns_abs() if ptsUsu < ptsObj - 10: lic[-1] += ' <span style="color:red"><b>%s</b></span>' % _( "Bad move") self.errores += 1 self.dbwashing.add_hint() else: lic.append("%s: %s (?) %s" % (_("Played now"), move.pgn_translated(), _("Bad move"))) self.errores += 1 self.dbwashing.add_hint() else: # Debe ser una move de book para aceptarla fen = self.last_fen() siBookUsu = self.book.check_human(fen, from_sq, to_sq) bmove = _("book move") lic.append( "%s: %s (%s)" % (_("Played previously"), jgObj.pgn_translated(), bmove)) if siBookUsu: lic.append("%s: %s (%s)" % (_("Played now"), move.pgn_translated(), bmove)) else: lic.append("%s: %s (?) %s" % (_("Played now"), move.pgn_translated(), _("Bad move"))) self.errores += 1 self.dbwashing.add_hint() comment = "<br>".join(lic) w = WindowJuicio.MensajeF(self.main_window, comment) w.mostrar() self.set_position(move.position_before) # Creamos un move sin analysis ok, self.error, move = Move.get_game_move(self.game, self.game.last_position, jgObj.from_sq, jgObj.to_sq, jgObj.promotion) self.move_the_pieces(move.liMovs) self.add_move(move, True) self.posJugadaObj += 1 if len(self.game) == self.gameObj.num_moves(): self.end_game() else: self.error = "" self.play_next_move() return True