January 2020
Intermediate to advanced
432 pages
10h 18m
English
In the next exercise, we will write code to test Gym and an environment called FrozenLake, which also happens to be our test environment for this chapter. Open the Chapter_2_4.py code example and follow the exercise:
from os import system, nameimport timeimport gymimport numpy as npenv = gym.make('FrozenLake-v0')env.reset()def clear(): if name == 'nt': _ = system('cls') else: _ = system('clear')for _ in range(1000): clear() env.render() time.sleep(.5) env.step(env.action_space.sample()) # take a random actionenv.close()
Read now
Unlock full access