% monte carlo path planning runner
% HOLLINGER AND SINGH
clear all; close all; clc;
% set up random number generator

M = 20;
m = 1;
offset = 1;
xdata = linspace(0.15,0.10,M);
util = zeros(M,1);
comp_time = zeros(M,1);

while m <= M
    rng(m + offset);
    fprintf("\nbegin iteration %d --------- \n",m);
    input_env_step_size = xdata(m);
    [utility, computation_time] = main(input_env_step_size, m);
    if utility ~= -1 && computation_time ~= -1
        util(m) = utility;
        comp_time(m) = computation_time;
        m = m + 1;
    else
        fprintf("\niteration %d failed \n",m);
        offset = offset + 1;
    end
end
time_str = datestr(now,31);
time_str = regexprep(time_str(6:end-3),':','-');
time_str = regexprep(time_str,' ','_');
filename = ['HS_allrand_M',num2str(M),'_',time_str,'.mat'];
save(filename,'util','comp_time','xdata');

offset
m