Trajectory-based Learning for Ball-in-Maze Games