def nuevoAnalisis(self, lm):
        fen = lm.partidaBase.ultPosicion.fen()
        alm = PantallaAnalisisParam.paramAnalisis(self,
                                                  VarGen.configuracion,
                                                  False,
                                                  siTodosMotores=True)
        if alm is None:
            return
        confMotor = VarGen.configuracion.buscaMotor(alm.motor)
        confMotor.actMultiPV(alm.multiPV)
        # confMotor.debug( "rival" )

        xmotor = self.procesador.creaGestorMotor(confMotor,
                                                 alm.tiempo,
                                                 alm.depth,
                                                 siMultiPV=True)

        me = QTUtil2.analizando(self)
        mrm = xmotor.analiza(fen)
        mrm.tiempo = alm.tiempo / 1000.0
        mrm.depth = alm.depth

        tipo = "%s=%d" % (_("Depth"),
                          mrm.depth) if mrm.depth else "%.0f\"" % mrm.tiempo
        mrm.rotulo = ("%s %s" % (mrm.nombre, tipo))
        xmotor.terminar()
        me.final()

        lm.liAnalisis.append(mrm)
        self.ponAnalisis(lm, len(lm.liAnalisis) - 1)
Пример #2
0
    def nuevoAnalisis(self, lm):
        fen = lm.partidaBase.last_position.fen()
        alm = PantallaAnalisisParam.paramAnalisis(self,
                                                  Code.configuracion,
                                                  False,
                                                  siTodosMotores=True)
        if alm is None:
            return
        confMotor = Code.configuracion.buscaRival(alm.engine)
        confMotor.actMultiPV(alm.multiPV)
        # confMotor.debug( "rival" )

        xengine = self.procesador.creaGestorMotor(confMotor,
                                                  alm.vtime,
                                                  alm.depth,
                                                  siMultiPV=True)

        me = QTUtil2.analizando(self)
        mrm = xengine.analiza(fen)
        mrm.vtime = alm.vtime / 1000.0
        mrm.depth = alm.depth

        tipo = "%s=%d" % (_("Depth"),
                          mrm.depth) if mrm.depth else '%.0f"' % mrm.vtime
        mrm.rotulo = "%s %s" % (mrm.name, tipo)
        xengine.terminar()
        me.final()

        lm.liAnalisis.append(mrm)
        self.ponAnalisis(lm, len(lm.liAnalisis) - 1)
    def nuevoAnalisis(self, fenM2, infoDispatch):
        alm = PantallaAnalisisParam.paramAnalisis(self.pantalla,
                                                  VarGen.configuracion,
                                                  False,
                                                  siTodosMotores=True)
        if alm is None:
            return
        configuracion = VarGen.configuracion
        confMotor = configuracion.buscaMotor(alm.motor)
        confMotor.actMultiPV(alm.multiPV)

        xmotor = self.procesador.creaGestorMotor(confMotor,
                                                 alm.tiempo,
                                                 alm.depth,
                                                 siMultiPV=True)

        me = QTUtil2.analizando(self.pantalla)
        mrm = xmotor.analiza(fenM2 + " 0 1")
        mrm.tiempo = alm.tiempo / 1000.0

        mrm.rotulo = ("%s %.0f\"" % (mrm.nombre, mrm.tiempo))
        xmotor.terminar()
        me.final()

        self.dbAnalisis.nuevo(fenM2, mrm)

        self.dispatchAnalisis(infoDispatch)
Пример #4
0
 def crear(self):
     alm = PantallaAnalisisParam.paramAnalisis(self,
                                               VarGen.configuracion,
                                               False,
                                               siTodosMotores=True)
     if alm:
         um = self.mAnalisis.creaMuestra(self, alm)
         self.crearMuestra(um)
Пример #5
0
 def crear(self):
     alm = PantallaAnalisisParam.paramAnalisis(self,
                                               Code.configuracion,
                                               False,
                                               siTodosMotores=True)
     if alm:
         um = self.tb_analysis.create_show(self, alm)
         self.crearMuestra(um)
Пример #6
0
    def tw_massive(self):
        liSeleccionadas = self.grid.recnosSeleccionados()
        nSeleccionadas = len(liSeleccionadas)

        alm = PantallaAnalisisParam.paramAnalisisMasivo(self, self.configuracion, nSeleccionadas > 1, siDatabase=True)
        if alm:

            if alm.siVariosSeleccionados:
                nregs = nSeleccionadas
            else:
                nregs = self.dbGames.reccount()

            tmpBP = QTUtil2.BarraProgreso2(self, _("Mass analysis"), formato2="%p%")
            tmpBP.ponTotal(1, nregs)
            tmpBP.ponRotulo(1, _("Game"))
            tmpBP.ponRotulo(2, _("Moves"))
            tmpBP.mostrar()

            ap = Analisis.AnalizaPartida(self.procesador, alm, True)

            for n in range(nregs):

                if tmpBP.siCancelado():
                    break

                tmpBP.pon(1, n + 1)

                if alm.siVariosSeleccionados:
                    n = liSeleccionadas[n]

                partida = self.dbGames.leePartidaRecno(n)
                self.grid.goto(n, 0)

                ap.xprocesa(partida.dicTags(), partida, tmpBP, partida.pgn())

                self.dbGames.guardaPartidaRecno(n, partida)

            if not tmpBP.siCancelado():
                ap.terminar(True)

                liCreados = []
                liNoCreados = []

                if alm.tacticblunders:
                    if ap.siTacticBlunders:
                        liCreados.append(alm.tacticblunders)
                    else:
                        liNoCreados.append(alm.tacticblunders)

                for x in (alm.pgnblunders, alm.fnsbrilliancies, alm.pgnbrilliancies):
                    if x:
                        if Util.existeFichero(x):
                            liCreados.append(x)
                        else:
                            liNoCreados.append(x)

                if alm.bmtblunders:
                    if ap.siBMTblunders:
                        liCreados.append(alm.bmtblunders)
                    else:
                        liNoCreados.append(alm.bmtblunders)
                if alm.bmtbrilliancies:
                    if ap.siBMTbrilliancies:
                        liCreados.append(alm.bmtbrilliancies)
                    else:
                        liNoCreados.append(alm.bmtbrilliancies)
                if liCreados:
                    PantallaPGN.mensajeEntrenamientos(self, liCreados, liNoCreados)

            else:
                ap.terminar(False)

            tmpBP.cerrar()
Пример #7
0
def analizaPartida(gestor):
    partida = gestor.partida
    procesador = gestor.procesador
    pantalla = gestor.pantalla
    pgn = gestor.pgn

    alm = PantallaAnalisisParam.paramAnalisis(pantalla,
                                              procesador.configuracion, True)

    if alm is None:
        return

    liJugadas = []
    lni = Util.ListaNumerosImpresion(alm.jugadas)
    numJugada = int(partida.primeraJugada())
    siBlancas = not partida.siEmpiezaConNegras
    for nRaw in range(partida.numJugadas()):
        siGrabar = lni.siEsta(numJugada)
        if siGrabar:
            if siBlancas:
                if not alm.blancas:
                    siGrabar = False
            elif not alm.negras:
                siGrabar = False
        if siGrabar:
            liJugadas.append(nRaw)
        siBlancas = not siBlancas
        if siBlancas:
            numJugada += 1

    mensaje = _("Analyzing the move....")
    numJugadas = len(liJugadas)
    tmpBP = QTUtil2.BarraProgreso(pantalla, _("Analysis"), mensaje,
                                  numJugadas).mostrarAD()

    ap = AnalizaPartida(procesador, alm, False, liJugadas)

    def dispatchBP(pos, ntotal, njg):
        tmpBP.mensaje(mensaje + " %d/%d" % (pos + 1, ntotal))
        jg = partida.jugada(njg)
        gestor.ponPosicion(jg.posicion)
        gestor.pantalla.pgnColocate(njg / 2, (njg + 1) % 2)
        gestor.tablero.ponFlechaSC(jg.desde, jg.hasta)
        gestor.ponVista()

    ap.dispatchBP(dispatchBP)

    ap.xprocesa(pgn.dicCabeceraActual(), partida, tmpBP, pgn.actual())

    notCanceled = not tmpBP.siCancelado()
    ap.terminar(notCanceled)

    if notCanceled:
        liCreados = []
        liNoCreados = []

        if alm.tacticblunders:
            if ap.siTacticBlunders:
                liCreados.append(alm.tacticblunders)
            else:
                liNoCreados.append(alm.tacticblunders)

        for x in (alm.pgnblunders, alm.fnsbrilliancies, alm.pgnbrilliancies):
            if x:
                if Util.existeFichero(x):
                    liCreados.append(x)
                else:
                    liNoCreados.append(x)

        if alm.bmtblunders:
            if ap.siBMTblunders:
                liCreados.append(alm.bmtblunders)
            else:
                liNoCreados.append(alm.bmtblunders)
        if alm.bmtbrilliancies:
            if ap.siBMTbrilliancies:
                liCreados.append(alm.bmtbrilliancies)
            else:
                liNoCreados.append(alm.bmtbrilliancies)

        if liCreados or liNoCreados:
            PantallaPGN.mensajeEntrenamientos(pantalla, liCreados, liNoCreados)

    tmpBP.cerrar()

    gestor.ponteAlFinal()

    if notCanceled:
        if alm.showGraphs:
            gestor.showAnalisis()
Пример #8
0
    def masivo(self):

        liSeleccionadas = self.grid.recnosSeleccionados()
        nSeleccionadas = len(liSeleccionadas)

        alm = PantallaAnalisisParam.paramAnalisisMasivo(
            self, self.gestor.configuracion, nSeleccionadas > 1)
        if alm:

            if alm.siVariosSeleccionados:
                nregs = nSeleccionadas
            else:
                nregs = self.dbf.reccount()

            tmpBP = QTUtil2.BarraProgreso2(self,
                                           _("Mass analysis"),
                                           formato2="%p%")
            tmpBP.ponTotal(1, nregs)
            tmpBP.ponRotulo(1, _("Game"))
            tmpBP.ponRotulo(2, _("Moves"))
            tmpBP.mostrar()

            import Code.Analisis

            ap = Code.Analisis.AnalizaPartida(self.gestor.procesador, alm,
                                              True)

            for n in range(nregs):

                if tmpBP.siCancelado():
                    break

                tmpBP.pon(1, n + 1)

                if alm.siVariosSeleccionados:
                    n = liSeleccionadas[n]

                self.dbf.goto(n)
                self.grid.goto(n, 0)

                jugadas = self.dbf.leeOtroCampo(n, "PGN")

                pgn = PGN.UnPGN()
                pgn.leeTexto(jugadas)

                ap.xprocesa(pgn.dic, pgn.partida, tmpBP, jugadas)

            if not tmpBP.siCancelado():
                ap.terminar(True)

                liCreados = []
                liNoCreados = []

                if alm.tacticblunders:
                    if ap.siTacticBlunders:
                        liCreados.append(alm.tacticblunders)
                    else:
                        liNoCreados.append(alm.tacticblunders)

                for x in (alm.pgnblunders, alm.fnsbrilliancies,
                          alm.pgnbrilliancies):
                    if x:
                        if Util.existeFichero(x):
                            liCreados.append(x)
                        else:
                            liNoCreados.append(x)

                if alm.bmtblunders:
                    if ap.siBMTblunders:
                        liCreados.append(alm.bmtblunders)
                    else:
                        liNoCreados.append(alm.bmtblunders)
                if alm.bmtbrilliancies:
                    if ap.siBMTbrilliancies:
                        liCreados.append(alm.bmtbrilliancies)
                    else:
                        liNoCreados.append(alm.bmtbrilliancies)
                mensajeEntrenamientos(self, liCreados, liNoCreados)

            else:
                ap.terminar(False)

            tmpBP.cerrar()
Пример #9
0
def analyse_game(gestor):
    game = gestor.game
    procesador = gestor.procesador
    main_window = gestor.main_window

    alm = PantallaAnalisisParam.paramAnalisis(main_window,
                                              procesador.configuracion, True)

    if alm is None:
        return

    li_moves = []
    lni = Util.ListaNumerosImpresion(alm.num_moves)
    num_move = int(game.primeraJugada())
    is_white = not game.if_starts_with_black
    for nRaw in range(game.num_moves()):
        must_save = lni.siEsta(num_move)
        if must_save:
            if is_white:
                if not alm.white:
                    must_save = False
            elif not alm.black:
                must_save = False
        if must_save:
            li_moves.append(nRaw)
        is_white = not is_white
        if is_white:
            num_move += 1

    mensaje = _("Analyzing the move....")
    num_moves = len(li_moves)
    tmp_bp = QTUtil2.BarraProgreso(main_window, _("Analysis"), mensaje,
                                   num_moves).show_top_right()

    ap = AnalizaPartida(procesador, alm, False, li_moves)

    def dispatch_bp(pos, ntotal, njg):
        tmp_bp.mensaje(mensaje + " %d/%d" % (pos + 1, ntotal))
        move = game.move(njg)
        gestor.setposition(move.position)
        gestor.main_window.pgnColocate(njg / 2, (njg + 1) % 2)
        gestor.tablero.ponFlechaSC(move.from_sq, move.to_sq)
        gestor.put_view()

    ap.dispatch_bp(dispatch_bp)

    ap.xprocesa(game, tmp_bp)

    not_canceled = not tmp_bp.is_canceled()
    ap.terminar(not_canceled)

    if not_canceled:
        li_creados = []
        li_no_creados = []

        if alm.tacticblunders:
            if ap.siTacticBlunders:
                li_creados.append(alm.tacticblunders)
            else:
                li_no_creados.append(alm.tacticblunders)

        for x in (alm.pgnblunders, alm.fnsbrilliancies, alm.pgnbrilliancies):
            if x:
                if Util.exist_file(x):
                    li_creados.append(x)
                else:
                    li_no_creados.append(x)

        if alm.bmtblunders:
            if ap.si_bmt_blunders:
                li_creados.append(alm.bmtblunders)
            else:
                li_no_creados.append(alm.bmtblunders)
        if alm.bmtbrilliancies:
            if ap.si_bmt_brilliancies:
                li_creados.append(alm.bmtbrilliancies)
            else:
                li_no_creados.append(alm.bmtbrilliancies)

        if li_creados or li_no_creados:
            WDB_Utils.mensajeEntrenamientos(main_window, li_creados,
                                            li_no_creados)

    tmp_bp.cerrar()

    gestor.goto_end()

    if not_canceled:
        if alm.show_graphs:
            gestor.show_analysis()