1

Sorry I'm not that good at StackOverflow.

I'm trying to make a game bot with universe and i got an error saying:

[2018-09-14 07:28:33,723] Making new env: Taxi-v2
Traceback (most recent call last):
  File "d:\pacmantest.py", line 8, in <module>
    action_n = [[('KeyEvent', 'ArrowUp', True)] for ob in observation_n] 
TypeError: 'numpy.int64' object is not iterable

The code is:

import gym
import universe

env = gym.make('Taxi-v2')
observation_n = env.reset()

while True:
  action_n = [[('KeyEvent', 'ArrowUp', True)] for ob in observation_n] 
  observation_n, reward_n, done_n, info = env.step(action_n)
  env.render()
1
  • 3
    Presumably observation_n = env.reset() causes observation_n to be a numpy integer, not a sequence that you can iterate through. You should print(observation_n) Commented Sep 14, 2018 at 12:14

2 Answers 2

1

If you execute print(type(observation_n)) immediately after observation_n = env.reset() it will likely print 'numpy.int64'. You can only iterate on iterable objects, such as lists, single values such as int64 are not iterable.

Sign up to request clarification or add additional context in comments.

Comments

0

Switch the first two lines of your while loop. env.reset returns an int, while env.step returns a tuple.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.