irl-imitation icon indicating copy to clipboard operation
irl-imitation copied to clipboard

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

Open zzlking opened this issue 5 years ago • 3 comments

\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

zzlking avatar Nov 03 '19 11:11 zzlking

check your python version, it should be use python2

Matrixsun avatar Jan 06 '20 08:01 Matrixsun

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..

Jo-wang avatar Feb 28 '21 07:02 Jo-wang

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))

mlshehab avatar Apr 30 '22 15:04 mlshehab