mimoralea / gdrl

Grokking Deep Reinforcement Learning
https://www.manning.com/books/grokking-deep-reinforcement-learning
BSD 3-Clause "New" or "Revised" License
798 stars 231 forks source link

No seed method error. #33

Open cwk20 opened 1 year ago

cwk20 commented 1 year ago

Slippery Walk Five MDP and sample policy in Chapter 3 of Jupyter notebook.

Why am I getting this error and how do I fix this?

env = gym.make('SlipperyWalkFive-v0') P = env.env.P init_state = env.reset() goal_state = 6

LEFT, RIGHT = range(2) pi = lambda s: { 0:LEFT, 1:LEFT, 2:LEFT, 3:LEFT, 4:LEFT, 5:LEFT, 6:LEFT }[s] print_policy(pi, P, action_symbols=('<', '>'), n_cols=7) print('Reaches goal {:.2f}%. Obtains an average undiscounted return of {:.4f}.'.format( probability_success(env, pi, goal_state=goal_state)*100, mean_return(env, pi)))

AttributeError Traceback (most recent call last) C:\Temp\ipykernel_11836\386057658.py in <cell line: 11>() 10 print_policy(pi, P, action_symbols=('<', '>'), n_cols=7) 11 print('Reaches goal {:.2f}%. Obtains an average undiscounted return of {:.4f}.'.format( ---> 12 probability_success(env, pi, goal_state=goal_state)*100, 13 mean_return(env, pi)))

C:\Temp\ipykernel_11836\4014631173.py in probability_success(env, pi, goal_state, n_episodes, max_steps) 1 def probability_success(env, pi, goal_state, n_episodes=100, maxsteps=200): ----> 2 random.seed(123); np.random.seed(123) ; env.seed(123) 3 results = [] 4 for in range(n_episodes): 5 state, done, steps = env.reset(), False, 0

~\anaconda3\lib\site-packages\gym\core.py in getattr(self, name) 239 if name.startswith("_"): 240 raise AttributeError(f"accessing private attribute '{name}' is prohibited") --> 241 return getattr(self.env, name) 242 243 @property

~\anaconda3\lib\site-packages\gym\core.py in getattr(self, name) 239 if name.startswith("_"): 240 raise AttributeError(f"accessing private attribute '{name}' is prohibited") --> 241 return getattr(self.env, name) 242 243 @property

~\anaconda3\lib\site-packages\gym\core.py in getattr(self, name) 239 if name.startswith("_"): 240 raise AttributeError(f"accessing private attribute '{name}' is prohibited") --> 241 return getattr(self.env, name) 242 243 @property

AttributeError: 'WalkEnv' object has no attribute 'seed'

cwk20 commented 1 year ago

I think this is the same issue as #32.