Spaces:
Sleeping
Sleeping
Update evaluate.py
Browse files- evaluate.py +1 -9
evaluate.py
CHANGED
@@ -5,13 +5,10 @@ import pygame
|
|
5 |
import time
|
6 |
|
7 |
def main():
|
8 |
-
# Create the environment
|
9 |
env = TetrisEnv()
|
10 |
|
11 |
-
# Load the trained model
|
12 |
model = DQN.load("models/dqn_tetris")
|
13 |
|
14 |
-
# Number of evaluation episodes
|
15 |
episodes = 5
|
16 |
|
17 |
for ep in range(1, episodes + 1):
|
@@ -19,19 +16,14 @@ def main():
|
|
19 |
done = False
|
20 |
total_reward = 0
|
21 |
while not done:
|
22 |
-
# Render the game (optional)
|
23 |
env.render(mode='human')
|
24 |
|
25 |
-
# Predict the action using the trained model
|
26 |
action, _states = model.predict(obs, deterministic=True)
|
27 |
|
28 |
-
# Take the action in the environment
|
29 |
obs, reward, done, info = env.step(action)
|
30 |
|
31 |
total_reward += reward
|
32 |
-
|
33 |
-
# Control the rendering speed
|
34 |
-
pygame.time.wait(100) # Wait 100 ms between steps
|
35 |
|
36 |
print(f"Episode {ep}: Total Reward = {total_reward}")
|
37 |
|
|
|
5 |
import time
|
6 |
|
7 |
def main():
|
|
|
8 |
env = TetrisEnv()
|
9 |
|
|
|
10 |
model = DQN.load("models/dqn_tetris")
|
11 |
|
|
|
12 |
episodes = 5
|
13 |
|
14 |
for ep in range(1, episodes + 1):
|
|
|
16 |
done = False
|
17 |
total_reward = 0
|
18 |
while not done:
|
|
|
19 |
env.render(mode='human')
|
20 |
|
|
|
21 |
action, _states = model.predict(obs, deterministic=True)
|
22 |
|
|
|
23 |
obs, reward, done, info = env.step(action)
|
24 |
|
25 |
total_reward += reward
|
26 |
+
pygame.time.wait(100)
|
|
|
|
|
27 |
|
28 |
print(f"Episode {ep}: Total Reward = {total_reward}")
|
29 |
|