コード例 #1
0
ファイル: othello.py プロジェクト: pengshiqi/BlackWhiteChess
                                canvas.total_num += 1
                                refresh()
                                whether_clicked = True  # 标记为已经落子

                if not whether_black:
                    # 黑色不能落子
                    black_turn.undraw()
                    white_turn.draw(win)
                    canvas.total_num += 1
                    whether_clicked = True

                if whether_clicked:
                    # 如果黑色已经落子,则轮到白色方落子
                    # 如果白色可以落子

                    if canvas.check_white():
                        sleep(0.2)
                        # AI--------------------------------------------------
                        # 找出白色的最佳落子坐标
                        # [best_x, best_y] = find_the_best(canvas)
                        a = calculate.intArray(64)
                        for i in xrange(8):
                            for j in xrange(8):
                                a[i * 8 + j] = canvas.board[i][j].color
                        best_place = calculate.find_the_best(a, -1)
                        best_x = best_place / 10
                        best_y = best_place % 10
                        logging.info('WHITE places at (%s, %s)' % (best_x, best_y))
                        canvas.click(best_x, best_y, 1)

                        canvas.piece_num[1] += 1
コード例 #2
0
ファイル: othello.py プロジェクト: pengshiqi/BlackWhiteChess
                if not blackHasValidMove:
                    # 黑色不能落子
                    t_skip_black.draw(win)
                    sleep(1)
                    t_skip_black.undraw()

                    black_turn.undraw()
                    white_turn.draw(win)
                    # canvas.total_num += 1
                    blackClicked = True

                # 黑色已落子
                if blackClicked:
                    # 如果黑色已经落子,则轮到白色方落子
                    # 如果白色可以落子
                    whiteHasValidMove = canvas.check_white()

                    if whiteHasValidMove:
                        # Human VS Human
                        if playerType == 0:
                            quitFlag = False
                            whiteClicked = False
                            while 1:
                                if whiteClicked:
                                    break

                                p4 = win.getMouse()

                                if b_qt.clicked(p4):  # 如果点击quit按钮
                                    quitFlag = True
                                    break