我有以下代码,使用提供的引擎分析给定时间内的所有可能动作:
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得分进行排序。我该怎么办?