Factored out random track generator algorithm

Made some refactoring to allow multiple kinds of random track generator algorithms.