TicTacToe.py 文件源码

python
阅读 38 收藏 0 点赞 0 评论 0

项目:ToeBot 作者: barkdong123 项目源码 文件源码
def turn(self):
        global board,whos_turn,n_of_turn

        for event in pygame.event.get():
            if (event.type == pygame.MOUSEBUTTONDOWN):
                mouse_pos = pygame.mouse.get_pos()
                for i in range(3):
                    for j in range(3):
                        if (sqr_pos[i][j][0] < mouse_pos[0] and sqr_pos[i][j][0] + sqr_size[0] > mouse_pos[0] and
                                    sqr_pos[i][j][1] < mouse_pos[1] and sqr_pos[i][j][1] + sqr_size[1] > mouse_pos[
                            1] and board[i*3+j] == NO_ONE):

                            board[i*3+j] = whos_turn
                            n_of_turn += 1
                            who_won(tuple(board) ,whos_turn, n_of_turn)
                            reward_consider(winner,tuple(board),p1,p2)
                            whos_turn = self.ID ^ 1


            elif (event.type == pygame.K_ESCAPE):
                esc_pause()

            if (event.type == pygame.QUIT):
                sys.exit()
                # -------------------------------------------
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号