#include "SearchHeuristic.h"

void swap_candidates(Candidate** tab, unsigned int i, unsigned int j) {
    Candidate* tmp = tab[i];
    tab[i] = tab[j];
    tab[j] = tmp;
}

SearchHeuristic::SearchHeuristic()
{
    m_abortion_limit = -1;
    m_record = nullptr;
    m_objective = 1.00;
}

MasterMind* SearchHeuristic::get_problem() {
    return m_problem;
}

void SearchHeuristic::set_problem(MasterMind* problem) {
    m_problem = problem;
}

void SearchHeuristic::set_abortion_limit(double l) {
    m_abortion_limit = l;
}

void SearchHeuristic::set_record(std::vector<Point>* m_record_tab) {
    m_record = m_record_tab;
}

bool SearchHeuristic::is_recording() {
    return (m_record != nullptr);
}

void SearchHeuristic::clear_record() {
    if(m_record != nullptr) {
        m_record->clear();
    }
}

void SearchHeuristic::record(int nb_calls, double value) {
    if(m_record != nullptr) {
        m_record->push_back(Point(nb_calls, value));
    }
}

std::vector<Point>* SearchHeuristic::get_record() {
    return m_record;
}

void SearchHeuristic::set_objective(double objective) {
    m_objective = objective;
}

SearchHeuristic::~SearchHeuristic() {
    //dtor
}
