Your code must define update(readings), called every 50ms.
readings is a list of 4 values: a distance (float ≥ 0) if that sensor fired, or -1 if it didn't. Sensors fire independently each tick with probability based on distance to ball (1.0 within 10px, 0.1 beyond 200px).
You may also define reset_state(), called when the ball resets.
import game)| Heatmap | |
|---|---|
game.get_grid() | Returns flat list of GRID_ROWS × GRID_COLS probabilities |
game.set_grid(lst) | Write back the updated heatmap grid (flat list) |
game.GRID_ROWS, game.GRID_COLS | Grid dimensions |
| Sensors | |
game.get_sensors() | List of sensor positions [{x, y}, ...] |
game.get_readings() | Most recent readings from all sensors |
game.sensor_noise | Current sensor noise std dev (slider value) |
game.SENSOR_NEAR_DIST | Distance at which fire probability = 1 (10px) |
game.SENSOR_FAR_DIST | Distance at which fire probability = min (200px) |
game.MIN_FIRE_PROB | Minimum fire probability (slider value / 100, default 0.1) |
| Paddle | |
game.paddle_y | Current paddle top y position |
game.move_paddle(dir) | Move paddle: "up" or "down". If not called, human controls the paddle. |
game.PADDLE_X, game.PADDLE_W, game.PADDLE_H | Paddle geometry (constants) |
| Game | |
game.WIDTH, game.HEIGHT | Canvas dimensions in pixels |
game.BALL_SPEED | Ball speed in pixels/frame (~60fps) |
numpy and scipy are pre-loaded.