Deciding whether there is something left to learn from responses

This commit is contained in:
Matúš Púll 2024-11-03 12:15:35 +01:00
parent 090e1e6ffe
commit 7aae78f92e

View file

@ -104,31 +104,47 @@ public:
known.empty_color(col);
}
void learn_back(Historic_guess hist) {
bool learn_back(Historic_guess hist) {
bool something_to_learn = true;
// TODO
return something_to_learn;
}
void learn(vector<int> guess, vector<int> response) {
bool something_to_learn;
// None of these colors are there
if(response[0] == 0 && response[1] == 0)
if(response[0] == 0 && response[1] == 0) {
empty(guess);
something_to_learn = false;
}
// None at the right spot
else if(response[1] == 0)
else if(response[1] == 0) {
not_here(guess);
something_to_learn = false;
}
// At least only on the right spot
else if(response[0] == 0)
else if(response[0] == 0) {
if_not_here_then_nowhere(guess);
something_to_learn = true;
}
// TODO nonzero / nonzero
else
{}
else {
something_to_learn = true;
}
// Learn from previous guesses
for(auto hist : history)
learn_back(hist);
for(int i = 0; i < history.size(); i++)
if(!learn_back(history[i])) {
// If there is nothing left to learn from the guess
history.erase(history.begin()+i);
i--;
}
// Write to history
if(something_to_learn)
history.push_back({guess, response});
}
void print() {