Update README.md
Browse files
README.md
CHANGED
@@ -30,8 +30,28 @@ TODO: Add your code
|
|
30 |
|
31 |
|
32 |
```python
|
33 |
-
|
34 |
-
from huggingface_sb3 import load_from_hub
|
35 |
|
36 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
```
|
|
|
30 |
|
31 |
|
32 |
```python
|
33 |
+
import gymnasium as gym
|
|
|
34 |
|
35 |
+
# First, we create our environment called LunarLander-v2
|
36 |
+
env = gym.make("LunarLander-v2")
|
37 |
+
|
38 |
+
# Then we reset this environment
|
39 |
+
observation, info = env.reset()
|
40 |
+
|
41 |
+
for _ in range(20):
|
42 |
+
# Take a random action
|
43 |
+
action = env.action_space.sample()
|
44 |
+
print("Action taken:", action)
|
45 |
+
|
46 |
+
# Do this action in the environment and get
|
47 |
+
# next_state, reward, terminated, truncated and info
|
48 |
+
observation, reward, terminated, truncated, info = env.step(action)
|
49 |
+
|
50 |
+
# If the game is terminated (in our case we land, crashed) or truncated (timeout)
|
51 |
+
if terminated or truncated:
|
52 |
+
# Reset the environment
|
53 |
+
print("Environment is reset")
|
54 |
+
observation, info = env.reset()
|
55 |
+
|
56 |
+
env.close()
|
57 |
```
|