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

IndexError: only integers, slices (:), ellipsis (...), numpy.newaxis (None) and integer or boolean arrays are valid indices #6

Open
zzlking opened this issue Nov 3, 2019 · 3 comments

Comments

@zzlking
Copy link

zzlking commented Nov 3, 2019

\irl-imitation\mdp\gridworld.py", line 151, in get_transition_states_and_probs
nei_s[1] < 0 or nei_s[1] >= self.width or self.grid[nei_s[0]][nei_s[1]] == 'x':
IndexError: only integers, slices (:), ellipsis (...), numpy.newaxis (None) and integer or boolean arrays are valid indices

@Matrixsun
Copy link

check your python version, it should be use python2

@Jo-wang
Copy link

Jo-wang commented Feb 28, 2021

check your python version, it should be use python2

Is there any difference in this case? I solved this problem but is show another problem which is sj will bigger than 25..

@mlshehab
Copy link

mlshehab commented Apr 30, 2022

I solved by updating the function below in gridworld.py (I'm using python 3):

def idx2pos(self, idx):
"""
input:
1d idx
returns:
2d column-major position
"""
return (idx % self.height, int(idx / self.height))

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

4 participants