#NEWLINE# def _select_moves_and_normalize( self , nn_output , moves , size ) : #NEWLINE# #INDENT# 'helper function to normalize a distribution over the given list of moves\n\t\tand return a list of (move, prob) tuples\n\t\t' #NEWLINE# if ( len ( moves ) == 0 ) : #NEWLINE# #INDENT# return [ ] #NEWLINE# #UNINDENT# move_indices = [ flatten_idx ( m , size ) for m in self ] #NEWLINE# distribution = nn_output [ move_indices ] #NEWLINE# distribution = ( distribution / distribution . sum ( ) ) #NEWLINE# return zip ( moves , distribution )