示例#1
0
    def __init__(self):
        
        super(UciEngineWidget, self).__init__()

        self.engine = UciEngine(UciEngine.STOCKFISH)
        self.info = QtGui.QGraphicsSimpleTextItem()
        self.bestmove = QtGui.QGraphicsSimpleTextItem()
        self.status = QtGui.QGraphicsSimpleTextItem()

        self.engine.info_recieved.connect(self._onInfo)
        self.engine.bestmove_recieved.connect(self._onBestMove)

        self.info.setParentItem(self)
        self.bestmove.setParentItem(self)
        self.status.setParentItem(self)

        self.bestmove.setPos(0, 50)
        self.status.setPos(0, 100)
示例#2
0
class UciEngineWidget(GraphicsWidget):
    
    def __init__(self):
        
        super(UciEngineWidget, self).__init__()

        self.engine = UciEngine(UciEngine.STOCKFISH)
        self.info = QtGui.QGraphicsSimpleTextItem()
        self.bestmove = QtGui.QGraphicsSimpleTextItem()
        self.status = QtGui.QGraphicsSimpleTextItem()

        self.engine.info_recieved.connect(self._onInfo)
        self.engine.bestmove_recieved.connect(self._onBestMove)

        self.info.setParentItem(self)
        self.bestmove.setParentItem(self)
        self.status.setParentItem(self)

        self.bestmove.setPos(0, 50)
        self.status.setPos(0, 100)

    def _onInfo(self, info):
        self.info.setText(str(info))

    def _onBestMove(self, info):
        self.bestmove.setText(str(info))
        fen = 'QQQ5/1K6/1Q6/8/5r2/4rk2/8/8 w - - 0 0'
        self.engine.start(fen, 10)

    def analyze(self):

        fen = 'QQQ5/1K6/1Q6/8/5r2/4rk2/8/8 w - - 0 0'
        self.engine.start(fen, 10)
        self.info.setText('waiting ...')
        self.bestmove.setText('waiting ...')

    def stop(self):
        self.engine.exit()
        self.info.setText('stopped')
        self.bestmove.setText('stopped')