mirror of
https://github.com/kuhyx/WUT_Computer_Science.git
synced 2026-07-06 16:43:01 +02:00
chore: metadrivee <hello_world>
This commit is contained in:
parent
0b954cb1ea
commit
ee59f88e4c
21
main.py
21
main.py
@ -1,11 +1,16 @@
|
|||||||
import gymnasium as gym
|
import metadrive
|
||||||
env = gym.make("LunarLander-v2", render_mode="human")
|
|
||||||
observation, info = env.reset(seed=42)
|
|
||||||
for _ in range(1000):
|
|
||||||
action = env.action_space.sample() # this is where you would insert your policy
|
|
||||||
observation, reward, terminated, truncated, info = env.step(action)
|
|
||||||
|
|
||||||
if terminated or truncated:
|
# Initialize the MetaDrive environment
|
||||||
observation, info = env.reset()
|
env = metadrive.MetaDriveEnv()
|
||||||
|
|
||||||
|
# Reset the environment to start a new episode
|
||||||
|
env.reset()
|
||||||
|
|
||||||
|
# Run the environment for a few steps
|
||||||
|
for _ in range(10):
|
||||||
|
env.step(env.action_space.sample()) # Take random actions
|
||||||
|
|
||||||
|
print("Hello, MetaDrive World!") # Print a greeting
|
||||||
|
|
||||||
|
# Close the environment after use
|
||||||
env.close()
|
env.close()
|
||||||
@ -1 +1,5 @@
|
|||||||
|
metadrive
|
||||||
|
ray
|
||||||
|
rlib
|
||||||
|
ray[rllib]
|
||||||
metadrive-simulator
|
metadrive-simulator
|
||||||
Loading…
Reference in New Issue
Block a user