<s> __author__ = '<STR_LIT>' <EOL> from random import choice , random <EOL> from scipy import array <EOL> from . pomdp import POMDPTask <EOL> class TigerTask ( POMDPTask ) : <EOL> """<STR_LIT>""" <EOL> observations = <NUM_LIT:2> <EOL> actions = <NUM_LIT:3> <EOL> minReward = - <NUM_LIT:100> <EOL> discount = <NUM_LIT> <EOL> Listen = <NUM_LIT:0> <EOL> OpenLeft = <NUM_LIT:1> <EOL> OpenRight = <NUM_LIT:2> <EOL> stochObs = <NUM_LIT> <EOL> def reset ( self ) : <EOL> self . steps = <NUM_LIT:0> <EOL> self . cumreward = <NUM_LIT:0> <EOL> self . tigerLeft = choice ( [ True , False ] ) <EOL> self . done = False <EOL> self . nextReward = - <NUM_LIT:1> <EOL> def performAction ( self , action ) : <EOL> self . steps += <NUM_LIT:1> <EOL> if action != self . Listen : <EOL> self . done = True <EOL> if ( ( action == self . OpenLeft and self . tigerLeft ) <EOL> or ( action == self . OpenRight and not self . tigerLeft ) ) : <EOL> self . nextReward = - <NUM_LIT:100> <EOL> else : <EOL> self . nextReward = <NUM_LIT:10> <EOL> def getObservation ( self ) : <EOL> """<STR_LIT>""" <EOL> if self . tigerLeft : <EOL> obs = array ( [ <NUM_LIT:1> , <NUM_LIT:0> ] ) <EOL> else : <EOL> obs = array ( [ <NUM_LIT:0> , <NUM_LIT:1> ] ) <EOL> if random ( ) < self . stochObs : <EOL> obs = <NUM_LIT:1> - obs <EOL> return obs <EOL> def isFinished ( self ) : <EOL> return self . done or POMDPTask . isFinished ( self ) <EOL> def getReward ( self ) : <EOL> return self . nextReward </s>
