<s> __author__ = '<STR_LIT>' <EOL> from scipy import random , zeros <EOL> from pybrain . rl . environments import Environment <EOL> class SimpleEnvironment ( Environment ) : <EOL> def __init__ ( self , dim = <NUM_LIT:1> ) : <EOL> Environment . __init__ ( self ) <EOL> self . dim = dim <EOL> self . indim = dim <EOL> self . outdim = dim <EOL> self . noise = None <EOL> self . reset ( ) <EOL> def setNoise ( self , variance ) : <EOL> self . noise = variance <EOL> def getSensors ( self ) : <EOL> if not self . updated : <EOL> self . update ( ) <EOL> return self . state <EOL> def performAction ( self , action ) : <EOL> self . updated = False <EOL> self . action = action <EOL> def update ( self ) : <EOL> self . state = [ s + <NUM_LIT:0.1> * a for s , a in zip ( self . state , self . action ) ] <EOL> if self . noise : <EOL> self . state += random . normal ( <NUM_LIT:0> , self . noise , self . dim ) <EOL> def f ( self , x ) : <EOL> return [ v ** <NUM_LIT:2> for v in x ] <EOL> def reset ( self ) : <EOL> self . state = random . uniform ( <NUM_LIT:2> , <NUM_LIT:2> , self . dim ) <EOL> self . action = zeros ( self . dim , float ) <EOL> self . updated = True </s>
