0
$\begingroup$

How can one render the environment using the Tensorforce library?

I've tried calling environment.render, but it says that the function does not exist. This is my code:

from tensorforce.agents import Agent
from tensorforce.environments import Environment
from tensorforce.execution import Runner

# Create an OpenAI-Gym environment
environment = Environment.create(environment='gym', level='MountainCarContinuous-v0')

agent = Agent.create(agent='random', environment=environment)   

# runner = Runner(agent=agent, environment=environment) # Initialize the runner
# runner.run(num_episodes=NUM_EPISODES) # Start the runner
# runner.close()

# Train
for ep in range(NUM_EPISODES): # Number of episodes

    print('********Episode ' + str(ep) + '********')

    # Initialize episode
    states = environment.reset()
    done = False
    step = 0

    while not done: # Episode timestep
        actions = agent.act(states=states)
        states, done, reward = environment.execute(actions=actions)
        agent.observe(terminal=done, reward=reward)
        environment.render() # Gives error

environment.close()
agent.close()

And this is the error I get:

Traceback (most recent call last):

  File "c:\users\user\reinforcement learning\rl.py", line 179, in <module>
    environment.render()

AttributeError: 'OpenAIGym' object has no attribute 'render'
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.