Brute force is now implemented within minimax
This commit is contained in:
parent
d8cebb863f
commit
264881428e
1 changed files with 1 additions and 20 deletions
21
solver.cpp
21
solver.cpp
|
@ -13,24 +13,6 @@ bool Solver::all_are_consistent(vector<int> supposed_sequence) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Try all remaining sequences
|
|
||||||
vector<int> Solver::brute_force(vector<vector<int>> *possibilities, vector<int> *chosen, int index) {
|
|
||||||
vector<int> r(N, -1);
|
|
||||||
if(index == N) {
|
|
||||||
if(all_are_consistent(*chosen))
|
|
||||||
r = *chosen;
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
for(int col : (*possibilities)[index]) {
|
|
||||||
chosen->push_back(col);
|
|
||||||
r = brute_force(possibilities, chosen, index+1);
|
|
||||||
if(r[0] != -1)
|
|
||||||
return r;
|
|
||||||
chosen->pop_back();
|
|
||||||
}
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
|
|
||||||
int Solver::get_weight(vector<int> guess) {
|
int Solver::get_weight(vector<int> guess) {
|
||||||
if(!all_are_consistent(guess))
|
if(!all_are_consistent(guess))
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -67,8 +49,7 @@ vector<int> Solver::guess() {
|
||||||
auto possibilities = known.list_all_possibilities();
|
auto possibilities = known.list_all_possibilities();
|
||||||
auto chosen = vector<int>(0);
|
auto chosen = vector<int>(0);
|
||||||
|
|
||||||
// TODO make it smart
|
return minimax(&possibilities, &chosen, 0).guess;
|
||||||
return brute_force(&possibilities, &chosen, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Prints what the solver deduced
|
// Prints what the solver deduced
|
||||||
|
|
Loading…
Reference in a new issue