예제 #1
0
    def miraBuffer(self):
        if not self.siPlay:
            return
        self.lock = True

        li = self.buffer.split("\n")
        if self.buffer.endswith("\n"):
            self.buffer = ""
        else:
            self.buffer = li[-1]
            li = li[:-1]
        mrm = XMotorRespuesta.MRespuestaMotor("", " w " in self.fen)
        mrm.dispatch("\n".join(li), None, 9999)
        mrm.maxTiempo = None
        mrm.maxProfundidad = 9999

        if mrm.liMultiPV:

            cp = ControlPosicion.ControlPosicion()
            cp.leeFen(self.fen)

            txt = ['<table border="1" cellpadding="4" cellspacing="0" style="border-color: #ACA899">', ]

            def tr(tp, mas=""):
                txt[0] += '<tr><th>%s</th><td align="right">%.01f%%</td><td>%s%s</td></tr>' % (tp[0], tp[1], mas, tp[2])

            tp = AnalisisIndexes.tp_gamestage(cp, mrm)
            txt[0] += '<tr><th>%s</th><td align="right">%d</td><td>%s</td></tr>' % (tp[0], tp[1], tp[2])

            pts = mrm.liMultiPV[0].puntosABS()
            if pts:
                w, b = _("White"), _("Black")
                siW = "w" in self.fen
                if pts > 0:
                    mas = w if siW else b
                elif pts < 0:
                    mas = b if siW else w
                mas += "-"
            else:
                mas = ""

            tr(AnalisisIndexes.tp_winprobability(cp, mrm), mas)
            tr(AnalisisIndexes.tp_complexity(cp, mrm))
            tr(AnalisisIndexes.tp_efficientmobility(cp, mrm))

            tr(AnalisisIndexes.tp_narrowness(cp, mrm))
            tr(AnalisisIndexes.tp_piecesactivity(cp, mrm))
            tr(AnalisisIndexes.tp_exchangetendency(cp, mrm))

            tp = AnalisisIndexes.tp_positionalpressure(cp, mrm)
            txt[0] += '<tr><th>%s</th><td align="right">%dcp</td><td></td></tr>' % (tp[0], int(tp[1]))

            tr(AnalisisIndexes.tp_materialasymmetry(cp, mrm))

            txt[0] += "</table>"

            self.em.ponHtml(txt[0])

        self.lock = False
예제 #2
0
    def compruebaInput(self):
        if not self.engine:
            return
        self.veces += 1
        if self.veces == 3:
            self.veces = 0
            if self.siPlay:
                mrm = self.engine.ac_estado()
                rm = mrm.rmBest()
                if rm and rm.depth > self.depth:
                    if mrm.li_rm:

                        cp = Position.Position()
                        cp.read_fen(self.fen)

                        self.liData = []

                        def tr(tp, mas=""):
                            self.liData.append((tp[0], "%.01f%%" % tp[1],
                                                "%s%s" % (mas, tp[2])))

                        tp = AnalisisIndexes.tp_gamestage(cp, mrm)
                        self.liData.append((tp[0], "%d" % tp[1], tp[2]))

                        pts = mrm.li_rm[0].centipawns_abs()
                        mas = ""
                        if pts:
                            w, b = _("White"), _("Black")
                            siW = "w" in self.fen
                            if pts > 0:
                                mas = w if siW else b
                            elif pts < 0:
                                mas = b if siW else w
                            mas += "-"

                        tr(AnalisisIndexes.tp_winprobability(cp, mrm), mas)
                        tr(AnalisisIndexes.tp_complexity(cp, mrm))
                        tr(AnalisisIndexes.tp_efficientmobility(cp, mrm))

                        tr(AnalisisIndexes.tp_narrowness(cp, mrm))
                        tr(AnalisisIndexes.tp_piecesactivity(cp, mrm))
                        tr(AnalisisIndexes.tp_exchangetendency(cp, mrm))

                        tp = AnalisisIndexes.tp_positionalpressure(cp, mrm)
                        self.liData.append((tp[0], "%d" % int(tp[1]), ""))

                        tr(AnalisisIndexes.tp_materialasymmetry(cp, mrm))

                    self.grid.refresh()
                    self.grid.resizeRowsToContents()

                QTUtil.refresh_gui()

        self.cpu.compruebaInput()
예제 #3
0
    def miraBuffer(self):
        if not self.siPlay:
            return
        self.lock = True

        li = self.buffer.split("\n")
        if self.buffer.endswith("\n"):
            self.buffer = ""
        else:
            self.buffer = li[-1]
            li = li[:-1]
        mrm = XMotorRespuesta.MRespuestaMotor("", " w " in self.fen)
        mrm.dispatch("\n".join(li))
        mrm.ordena()
        mrm.maxTiempo = None
        mrm.maxProfundidad = 9999

        if mrm.liMultiPV:

            cp = ControlPosicion.ControlPosicion()
            cp.leeFen(self.fen)

            litxt = ['<table border="1" cellpadding="4" cellspacing="0" style="border-color: #ACA899">', ]

            def tr(tp, mas=""):
                litxt.append('<tr><th>%s</th><td align="right">%.01f%%</td><td>%s%s</td></tr>' % (tp[0], tp[1], mas, tp[2]))

            tp = AnalisisIndexes.tp_gamestage(cp, mrm)
            litxt.append('<tr><th>%s</th><td align="right">%d</td><td>%s</td></tr>' % (tp[0], tp[1], tp[2]))

            pts = mrm.liMultiPV[0].puntosABS()
            if pts:
                w, b = _("White"), _("Black")
                siW = "w" in self.fen
                if pts > 0:
                    mas = w if siW else b
                elif pts < 0:
                    mas = b if siW else w
                mas += "-"
            else:
                mas = ""

            tr(AnalisisIndexes.tp_winprobability(cp, mrm), mas)
            tr(AnalisisIndexes.tp_complexity(cp, mrm))
            tr(AnalisisIndexes.tp_efficientmobility(cp, mrm))

            tr(AnalisisIndexes.tp_narrowness(cp, mrm))
            tr(AnalisisIndexes.tp_piecesactivity(cp, mrm))
            tr(AnalisisIndexes.tp_exchangetendency(cp, mrm))

            tp = AnalisisIndexes.tp_positionalpressure(cp, mrm)
            litxt.append('<tr><th>%s</th><td align="right">%dcp</td><td></td></tr>' % (tp[0], int(tp[1])))

            tr(AnalisisIndexes.tp_materialasymmetry(cp, mrm))

            # tr(AnalisisIndexes.tp_test1(cp, mrm))
            # tr(AnalisisIndexes.tp_test2(cp, mrm))
            # tr(AnalisisIndexes.tp_test3(cp, mrm))
            # tr(AnalisisIndexes.tp_test4(cp, mrm))
            # tr(AnalisisIndexes.tp_test5(cp, mrm))

            litxt.append("</table>")

            self.em.ponHtml("".join(litxt))

        self.lock = False