-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.py
More file actions
25 lines (20 loc) · 742 Bytes
/
test.py
File metadata and controls
25 lines (20 loc) · 742 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import gymnasium as gym
import numpy as np
from gym_modifly.env import DroneEnv # Import the custom drone environment
# Initialize the environment
env = DroneEnv()
episodes = 5 # Number of episodes
for episode in range(episodes):
state, _ = env.reset()
done = False
truncate = False
step = 0
total_reward = 0
while not (done or truncate):
action = env.action_space.sample() # Select a random action
next_state, reward, done, truncate, _ = env.step(action)
total_reward += reward
step += 1
print(f"Episode {episode + 1}, Step {step}: State={next_state}, Reward={reward}")
print(f"Episode {episode + 1} finished with total reward: {total_reward}")
env.close()