forked from se2-w19-group24/PyGame-Learning-Environment
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.py
More file actions
34 lines (28 loc) · 726 Bytes
/
test.py
File metadata and controls
34 lines (28 loc) · 726 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
26
27
28
29
30
31
32
33
34
from ple import PLE
from ple.games.pong import Pong
import pygame
import time
import sys
game = Pong(width=300, height=200)
p = PLE(game, fps=30, display_screen=True, force_fps=True)
p.init()
print(p.getActionSet())
nb_frames = 1000
action = None
for f in range(nb_frames):
if p.game_over():
p.reset_game()
obs = p.getScreenRGB()
events = pygame.event.get()
for event in events:
if event.type == pygame.QUIT:
sys.exit()
elif event.type == pygame.KEYDOWN:
if event.key:
action = event.key
print(action)
elif event.type == pygame.KEYUP:
action = None
p.act(action)
time.sleep(.05)
#This is a change