Created
November 10, 2020 11:17
-
-
Save pythonlessons/66035504dafb90df2ad0d4400009b782 to your computer and use it in GitHub Desktop.
LunarLander-v2_random
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import gym | |
| import random | |
| env = gym.make("LunarLander-v2") | |
| def Random_games(): | |
| # Each of this episode is its own game. | |
| for episode in range(10): | |
| env.reset() | |
| # this is each frame, up to 500...but we wont make it that far with random. | |
| while True: | |
| # This will display the environment | |
| # Only display if you really want to see it. | |
| # Takes much longer to display it. | |
| env.render() | |
| # This will just create a sample action in any environment. | |
| # In this environment, the action can be any of one how in list on 4, for example [0 1 0 0] | |
| action = env.action_space.sample() | |
| # this executes the environment with an action, | |
| # and returns the observation of the environment, | |
| # the reward, if the env is over, and other info. | |
| next_state, reward, done, info = env.step(action) | |
| # lets print everything in one line: | |
| print(next_state, reward, done, info, action) | |
| if done: | |
| break | |
| Random_games() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment