mirror of
https://github.com/kuhyx/WUT_Computer_Science.git
synced 2026-07-04 13:03:05 +02:00
chore: metadrivee <hello_world>
This commit is contained in:
parent
0b954cb1ea
commit
ee59f88e4c
23
main.py
23
main.py
@ -1,11 +1,16 @@
|
||||
import gymnasium as gym
|
||||
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)
|
||||
import metadrive
|
||||
|
||||
if terminated or truncated:
|
||||
observation, info = env.reset()
|
||||
# Initialize the MetaDrive environment
|
||||
env = metadrive.MetaDriveEnv()
|
||||
|
||||
env.close()
|
||||
# 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()
|
||||
|
||||
@ -1 +1,5 @@
|
||||
metadrive
|
||||
ray
|
||||
rlib
|
||||
ray[rllib]
|
||||
metadrive-simulator
|
||||
Loading…
Reference in New Issue
Block a user