在以下程序中根据象棋对棋动作进行排序

时间:2019-01-17 06:14:10

标签: python chess

我有以下代码,使用提供的引擎分析给定时间内的所有可能动作:

invisible_pen = QPen()
invisible_pen.setWidth(0)
invisible_pen.setStyle(Qt.NoPen)


class RoundedMovie(QWidget):

    def __init__(self, movie, parent=None):
        QWidget.__init__(self, parent)
        self.movie = movie

    def setMovie(self, movie):
        self.movie = movie

    def paintEvent(self, event):
        painter = QPainter(self)
        painter.setRenderHint(QPainter.Antialiasing, True)
        pixmap = self.movie.currentPixmap()
        brush = QBrush(pixmap)
        rect = QRect(0, 0, pixmap.width() - 10, pixmap.height() - 10)
        painter.setPen(invisible_pen)
        painter.setBrush(brush)
        painter.drawRoundedRect(rect, 5, 5)

示例输出如下:

<pre><code>    
import chess
import chess.uci

fen = input('Enter FEN: ')
board = chess.Board(fen)
handler = chess.uci.InfoHandler()

engine = chess.uci.popen_engine('engine')

engine.info_handlers.append(handler)
engine.position(board)
if board.turn: print ('White to move')
else: print ('black to move')

for el in board.legal_moves:
    engine.go(searchmoves=[el],movetime=120000)
    print (str(board.san(el)), 'eval = ', handler.info["score"])
</code></pre>

我希望输出根据配合和cp得分进行排序。我该怎么办?

0 个答案:

没有答案