#include "algo-complexity.h"

std::vector<Statistic> compute_complexity(std::default_random_engine& randomizer, SearchHeuristic* algo, int n_initial, int n_final, int n_step, int nb_tests, double slq, bool displaying) {
    std::vector<Statistic> stats;
    for(int n=n_initial; n<n_final; n+=n_step) {
        MasterMind mm(n, n, randomizer);
        algo->set_problem(&mm);
        Statistic stat = avg_calls(algo, nb_tests, -1, slq);
        stat.label = n;
        stats.push_back(stat);

        std::cout << n << ": " << stat.average << " +- " << stat.alea << std::endl;
    }
}

void save_in_file(std::string namefile, std::vector<Statistic> stats) {
    std::ofstream outfile(namefile);
    for(int i=0, s=stats.size(); i<s; i++)
        outfile << (int) stats[i].label << ";" << stats[i].average << ";" << stats[i].alea << std::endl;
}
