To make it easy for us to visualize what an environment looks like or what its task is, we will make use of a simple script that can launch any environment and step through it with some randomly sampled actions. You can download the script from this book's code repository under ch4 or create a file named run_gym_env.py under ~/rl_gym_book/ch4 with the following contents:
#!/usr/bin/env pythonimport gymimport sysdef run_gym_env(argv): env = gym.make(argv[1]) # Name of the environment supplied as 1st argument env.reset() for _ in range(int(argv[2])): env.render() env.step(env.action_space.sample()) env.close()if __name__ == "__main__": run_gym_env(sys.argv)
This script will take the name of the environment supplied ...