#include "experiences/complexity-rls.h"

void study_complexity_of_rls(std::default_random_engine& randomizer, int option, int argc, char** argv) {
    switch(option) {
    case 0:
        int n_initial = (argc>=4) ? atoi(argv[3]) : 10;
        std::stringstream ss;
        ss << "complexity-rls-n-" << n_initial << ".csv";
        study_complexity_of_rls_sample(randomizer, ss.str(), n_initial, 500, 10, true);
        break;
    }
}

void study_complexity_of_rls_sample(std::default_random_engine& randomizer, std::string filename, int n_initial, int n_final, int n_step, bool displaying) {
    std::ofstream outfile(filename);
    for(int n=n_initial; n<=n_final; n+=n_step) {
        if(displaying) std::cout << " - n=" << n << std::endl;
        MasterMind mm(n, n, randomizer);
        RLS algo;
        algo.set_problem(&mm);
        Statistic stat = avg_calls(&algo, 100, -1, 1.9842169516);
        outfile << n << ";" << stat.average-stat.alea << ";" << stat.average+stat.alea << std::endl;
    }
}
