Its not random
The instructions were flashed in the first level. If you swipe the color to the right, it goes straight to the right, and when it hits an obstacle (such as a wall or another color source), it gets deflected in a counterclockwise way (i.e. makes a right turn / changes direction and moves toward the bottom of the grid), and when it hits another obstacle, gets deflected again, until it can no longer move.
I thought the gameplay was similar to the Flow Free game, but it isnt. Its fun, really. You should totally try this. :)
VCrts about
FLOU - puzzle game