Game-state should be asked properly and not interact with its contents
This commit is contained in:
parent
0cee5a167e
commit
1d416deed8
1 changed files with 4 additions and 7 deletions
11
solver.hpp
11
solver.hpp
|
@ -61,7 +61,7 @@ public:
|
||||||
for(int col = 0; col < known.M; col++) {
|
for(int col = 0; col < known.M; col++) {
|
||||||
int possible_count = 0;
|
int possible_count = 0;
|
||||||
for(int n : positions_of_colors[col])
|
for(int n : positions_of_colors[col])
|
||||||
if(known.possible[n][col])
|
if(known.can(n, col))
|
||||||
possible_count++;
|
possible_count++;
|
||||||
if(possible_count == 0 && positions_of_colors[col].size() > 0)
|
if(possible_count == 0 && positions_of_colors[col].size() > 0)
|
||||||
known.empty_color(col);
|
known.empty_color(col);
|
||||||
|
@ -69,11 +69,8 @@ public:
|
||||||
}
|
}
|
||||||
void here(vector<int> guess) {
|
void here(vector<int> guess) {
|
||||||
for(int n = 0; n < known.N; n++)
|
for(int n = 0; n < known.N; n++)
|
||||||
if(guess[n] > -1 && known.possible[n][guess[n]])
|
if(guess[n] > -1 && known.can(n, guess[n]))
|
||||||
for(int col = 0; col < known.M; col++) {
|
known.must_be(n, guess[n]);
|
||||||
if(col != guess[n])
|
|
||||||
known.possible[n][col] = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
void not_here(vector<int> guess) {
|
void not_here(vector<int> guess) {
|
||||||
for(int n = 0; n < known.N; n++)
|
for(int n = 0; n < known.N; n++)
|
||||||
|
@ -105,7 +102,7 @@ public:
|
||||||
// Get number of colors, that can be on their positions
|
// Get number of colors, that can be on their positions
|
||||||
int possible_count = 0;
|
int possible_count = 0;
|
||||||
for(int n = 0; n < known.N; n++)
|
for(int n = 0; n < known.N; n++)
|
||||||
if(guess[n] > -1 && known.possible[n][guess[n]])
|
if(guess[n] > -1 && known.can(n, guess[n]))
|
||||||
possible_count++;
|
possible_count++;
|
||||||
|
|
||||||
// None of these colors are there
|
// None of these colors are there
|
||||||
|
|
Loading…
Reference in a new issue