Factored out random track generator algorithm