Exemplo n.º 1
0
    def initUI(self):

        self.chessboard = ChessBoard()  # 棋盘类
        self.palette1 = QPalette()  # 设置棋盘背景
        self.palette1.setBrush(QPalette.Background,
                               QtGui.QBrush(QtGui.QPixmap('new board.jpg')))
        self.setPalette(self.palette1)
        # self.setStyleSheet("board-image:url(img/chessboard.jpg)")  # 不知道这为什么不行
        self.setCursor(Qt.PointingHandCursor)  # 鼠标变成手指形状
        self.sound_piece = QSound("luozi.wav")  # 加载落子音效
        self.sound_win = QSound("win.wav")  # 加载胜利音效
        self.sound_defeated = QSound("defeated.wav")  # 加载失败音效
        self.thread = Searcher(skt, 0)
        self.resize(813, 591)  # 固定大小 540*540
        #self.setMinimumSize(QtCore.QSize(WIDTH, HEIGHT))
        #self.setMaximumSize(QtCore.QSize(WIDTH, HEIGHT))

        self.setWindowTitle("单人模式")
        self.setWindowIcon(QIcon('black.png'))

        self.pushButton_back = QPushButton(self)
        self.pushButton_back.setText("退出游戏")
        self.pushButton_back.move(10, 550)
        self.pushButton_back.clicked.connect(self.on_pushButton_back_clicked)

        self.black = QPixmap('black.png')
        self.white = QPixmap('white.png')

        self.piece_now = BLACK
        self.my_turn = True
        self.step = 0
        self.x, self.y = 1000, 1000

        #        self.mouse_point = LaBel(self)
        #       self.mouse_point.setScaledContents(True)
        #       self.mouse_point.setPixmap(self.black)
        #        self.mouse_point.setGeometry(270, 270, PIECE, PIECE)
        self.pieces = [QLabel(self) for i in range(225)]
        for piece in self.pieces:
            piece.setVisible(True)
            piece.setScaledContents(True)

#        self.mouse_point.raise_()
        self.ai_down = True

        #        self.setMouseTracking(True)
        self.show()
Exemplo n.º 2
0
#automatic tester file

from Board import ChessBoard

Chess = ChessBoard()
Chess.setUpBoard()
print(Chess)
#start of movement/move 1
#e4
Chess.performMoveWhite(4,1,4,3)
print(Chess)
#d5
Chess.performMoveBlack(3,6,3,4)
print(Chess)
#e4xd5
Chess.performMoveWhite(4,3,3,4)
print(Chess)
#e5
Chess.performMoveBlack(4,6,4,4)
print(Chess)
#d5xe5
Chess.performMoveWhite(3,4,4,5)
print(Chess)
#Qe7
Chess.performMoveBlack(3,7,4,6)
print(Chess)
#Nf3
Chess.performMoveWhite(6,0,5,2)
print(Chess)