Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No seed method error. #33

Open
cwk20 opened this issue Jun 30, 2023 · 1 comment
Open

No seed method error. #33

cwk20 opened this issue Jun 30, 2023 · 1 comment

Comments

@cwk20
Copy link

cwk20 commented Jun 30, 2023

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, max_steps=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
Copy link
Author

cwk20 commented Jun 30, 2023

I think this is the same issue as #32.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant