% Monte-Carlo Search Algoritm on low-autocorrelation program
% BSDLicence
% Rick van der Zwet - 0433373 - <hvdzwet@liacs.nl>

% Brute-force result of length 20
% best_20 = [-1,1,1,-1,-1,-1,1,1,-1,1,-1,-1,-1,1,-1,1,1,1,1,1];

% Basic variables
iterations = [1:10:200];
repetitions = 20;
length = 20;

% Plot the stuff
fitnesses = [];
for iteration = iterations
    fitness = [];
    for rep = 1:repetitions
        fprintf('Iter:%i, Rep:%i\n',iteration,rep);
        [new_fitness, value] =  mcs(length,iteration);
        fitness = [fitness, new_fitness];

        % Little hack to display output nicely
        % disp(rot90(value,-1));
    end
    fitnesses = [fitnesses,mean(fitness)];
end

plot(iterations,fitnesses);
title(sprintf('Monte-Carlo Search on Low-Corretation set - repetitions %i',repetitions));
ylabel('fitness');
xlabel('iterations');
grid on;
legend(sprintf('Length %i',length));
print('mcs-fitness.eps','-depsc2');

