#NEWLINE# def move( self , state ) : #NEWLINE# #INDENT# '\n        Given a state, choose the next item at random.\n        ' #NEWLINE# ( choices , weights ) = zip ( * self . model [ state ] . items ( ) ) #NEWLINE# cumdist = list ( accumulate ( weights ) ) #NEWLINE# r = ( random . random ( ) * cumdist [ ( - 1 ) ] ) #NEWLINE# selection = choices [ bisect . bisect ( cumdist , r ) ] #NEWLINE# return selection