pong module¶
-
class
pong.
Ball
(game, x_pos=0.5, y_pos=0.5, velocity=0.025, direction=[-0.5, 0.5], radius=0.02)[source]¶ Bases:
pong.BallOrPuck
Class representing the ball.
Parameters: radius (float) – Radius of ball in unit length. For other args, see
BallOrPuck
.
-
class
pong.
BallOrPuck
(game, x_pos=0.5, y_pos=0.5, velocity=0.2, direction=0)[source]¶ Class that represents either a ball or a puck.
Parameters: - game (GameOfPong) – Pong game.
- x_pos (float) – Initial x position in unit length.
- y_pos (float) – Initial y position in unit length.
- velocity (float) – Change in position per iteration.
- direction (list, float) – Heading.
-
class
pong.
GameOfPong
(x_grid=32, y_grid=32, debug=False, norm='L1')[source]¶ Bases:
object
Class representing a game of Pong. Playing field: 1 by 1 discretized into cells.
Parameters: - x_grid (int) – Number of cells to discretize x-axis into.
- y_grid (int) – Number of cells to discretize y-axis into.
- debug (bool) – Print debugging messages.
- norm (string) – “L1” or “L2”, defines norm to be used for velocity vector.
-
class
pong.
Puck
(game, length=0.07, y_pos=0.5, velocity=0.05, direction=0.0)[source]¶ Bases:
pong.BallOrPuck
Class representing the puck.
Parameters: direction (float, int) – +1 for up, -1 for down, 0 for no movement. For other args, see
BallOrPuck
.