1
- '''High-perf Pong
2
-
3
- Inspired from https://gist.github.com/Yttrmin/18ecc3d2d68b407b4be1
4
- & https://jair.org/index.php/jair/article/view/10819/25823
5
- & https://www.youtube.com/watch?v=PSQt5KGv7Vk
6
- '''
7
-
8
1
import numpy as np
9
2
import gymnasium
10
3
@@ -17,7 +10,10 @@ def __init__(self, num_envs=1, render_mode=None,
17
10
paddle_width = 62 , paddle_height = 8 ,
18
11
ball_width = 32 , ball_height = 32 ,
19
12
brick_width = 32 , brick_height = 12 ,
20
- brick_rows = 6 , brick_cols = 18 , continuous = False , log_interval = 128 ,
13
+ brick_rows = 6 , brick_cols = 18 ,
14
+ initial_ball_speed = 256 , max_ball_speed = 448 ,
15
+ paddle_speed = 620 ,
16
+ continuous = False , log_interval = 128 ,
21
17
buf = None , seed = 0 ):
22
18
self .single_observation_space = gymnasium .spaces .Box (low = 0 , high = 1 ,
23
19
shape = (10 + brick_rows * brick_cols ,), dtype = np .float32 )
@@ -40,10 +36,14 @@ def __init__(self, num_envs=1, render_mode=None,
40
36
self .actions = self .actions .astype (np .float32 )
41
37
42
38
self .c_envs = binding .vec_init (self .observations , self .actions , self .rewards ,
43
- self .terminals , self .truncations , num_envs , seed , frameskip = frameskip , width = width , height = height ,
44
- paddle_width = paddle_width , paddle_height = paddle_height , ball_width = ball_width , ball_height = ball_height ,
45
- brick_width = brick_width , brick_height = brick_height , brick_rows = brick_rows ,
46
- brick_cols = brick_cols , continuous = continuous
39
+ self .terminals , self .truncations , num_envs , seed , frameskip = frameskip ,
40
+ width = width , height = height , paddle_width = paddle_width ,
41
+ paddle_height = paddle_height , ball_width = ball_width ,
42
+ ball_height = ball_height , brick_width = brick_width ,
43
+ brick_height = brick_height , brick_rows = brick_rows ,
44
+ brick_cols = brick_cols , initial_ball_speed = initial_ball_speed ,
45
+ max_ball_speed = max_ball_speed , paddle_speed = paddle_speed ,
46
+ continuous = continuous
47
47
)
48
48
49
49
def reset (self , seed = 0 ):
0 commit comments