AlphaZero_Gomoku-tensorflow icon indicating copy to clipboard operation
AlphaZero_Gomoku-tensorflow copied to clipboard

click部分代码简化问题

Open fmscole opened this issue 6 years ago • 1 comments

尽管不涉及错误,也不影响什么, 双重循环看起来还是很不舒服,毕竟0(1)的问题变成了0(n^2)的问题了,做如下修改比较好: def click1(self, event): #click1 because keyword repetition size = self.board.width current_player = self.board.get_current_player() if current_player == 1: # for i in range(size): # for j in range(size): i=(event.x)//30 j=(event.y)//30 ri=(event.x)%30 rj=(event.y)%30 i=i-1 if ri<15 else i j=j-1 if rj<15 else j

        move = self.board.location_to_move((i, j))
        # if move in self.board.availables:
        #     square_distance = math.pow((event.x - self.chess_board_points[i][j].pixel_x), 2) + math.pow((event.y - self.chess_board_points[i][j].pixel_y), 2)                        
            
        #     if (square_distance <= 200):
        self.cv.create_oval(self.chess_board_points[i][j].pixel_x-10, self.chess_board_points[i][j].pixel_y-10, self.chess_board_points[i][j].pixel_x+10, self.chess_board_points[i][j].pixel_y+10, fill='black')
        self.board.do_move(move)

fmscole avatar Aug 21 '18 18:08 fmscole

谢谢指出!

zouyih avatar Jan 12 '19 06:01 zouyih