Ah, a game like Pipe Dream. I have a suggestion for designing this game. It involves mapping the pipe tiles to a 2D array.
The array holds the coordinates for the pipe tiles, which are organized into a grid. Start each round of the game by having a grid with all of the tiles connected to form a path. Scramble (i.e. rotate) as many random tiles as necessary. Once the player has rotated the correct tiles (and the array is the same as it looked before getting scrambled), the ball will then begin its movement towards the end point. To actually move the ball, have another array filled with the positions of the tiles which form the path. Finally, use move_and_collide()
to move the ball to its destination.