Deciding whether there is something left to learn from responses
This commit is contained in:
parent
090e1e6ffe
commit
7aae78f92e
1 changed files with 25 additions and 9 deletions
32
solver.hpp
32
solver.hpp
|
@ -104,31 +104,47 @@ public:
|
||||||
known.empty_color(col);
|
known.empty_color(col);
|
||||||
}
|
}
|
||||||
|
|
||||||
void learn_back(Historic_guess hist) {
|
bool learn_back(Historic_guess hist) {
|
||||||
|
bool something_to_learn = true;
|
||||||
// TODO
|
// TODO
|
||||||
|
return something_to_learn;
|
||||||
}
|
}
|
||||||
void learn(vector<int> guess, vector<int> response) {
|
void learn(vector<int> guess, vector<int> response) {
|
||||||
|
bool something_to_learn;
|
||||||
// None of these colors are there
|
// None of these colors are there
|
||||||
if(response[0] == 0 && response[1] == 0)
|
if(response[0] == 0 && response[1] == 0) {
|
||||||
empty(guess);
|
empty(guess);
|
||||||
|
something_to_learn = false;
|
||||||
|
}
|
||||||
|
|
||||||
// None at the right spot
|
// None at the right spot
|
||||||
else if(response[1] == 0)
|
else if(response[1] == 0) {
|
||||||
not_here(guess);
|
not_here(guess);
|
||||||
|
something_to_learn = false;
|
||||||
|
}
|
||||||
|
|
||||||
// At least only on the right spot
|
// At least only on the right spot
|
||||||
else if(response[0] == 0)
|
else if(response[0] == 0) {
|
||||||
if_not_here_then_nowhere(guess);
|
if_not_here_then_nowhere(guess);
|
||||||
|
something_to_learn = true;
|
||||||
|
}
|
||||||
|
|
||||||
// TODO nonzero / nonzero
|
// TODO nonzero / nonzero
|
||||||
else
|
else {
|
||||||
{}
|
something_to_learn = true;
|
||||||
|
}
|
||||||
|
|
||||||
// Learn from previous guesses
|
// Learn from previous guesses
|
||||||
for(auto hist : history)
|
for(int i = 0; i < history.size(); i++)
|
||||||
learn_back(hist);
|
if(!learn_back(history[i])) {
|
||||||
|
// If there is nothing left to learn from the guess
|
||||||
|
history.erase(history.begin()+i);
|
||||||
|
i--;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Write to history
|
// Write to history
|
||||||
|
if(something_to_learn)
|
||||||
history.push_back({guess, response});
|
history.push_back({guess, response});
|
||||||
}
|
}
|
||||||
void print() {
|
void print() {
|
||||||
|
|
Loading…
Reference in a new issue