#NEWLINE# def getAction( self , state ) : #NEWLINE# #INDENT# from graphicsUtils import keys_waiting #NEWLINE# from graphicsUtils import keys_pressed #NEWLINE# keys = ( keys_waiting ( ) + keys_pressed ( ) ) #NEWLINE# if ( keys != [ ] ) : #NEWLINE# #INDENT# self . keys = keys #NEWLINE# #UNINDENT# legal = state . getLegalActions ( self . index ) #NEWLINE# move = self . getMove ( legal ) #NEWLINE# if ( move == Directions . STOP ) : #NEWLINE# #INDENT# if ( self . lastMove in legal ) : #NEWLINE# #INDENT# move = self . lastMove #NEWLINE# #UNINDENT# #UNINDENT# if ( ( move . STOP_KEY in self . keys ) and ( Directions . STOP in legal ) ) : #NEWLINE# #INDENT# move = Directions . STOP #NEWLINE# #UNINDENT# if ( move not in legal ) : #NEWLINE# #INDENT# move = random . choice ( legal ) #NEWLINE# #UNINDENT# self . lastMove = move #NEWLINE# return move