diff --git a/src/include/client.h b/src/include/client.h index 4a24488..b23405b 100644 --- a/src/include/client.h +++ b/src/include/client.h @@ -252,7 +252,7 @@ std::vector > GaussianJordanElimination( n = equations.size(); for (int i = 0; i < n; i++) { int pivot = i; - if(i>=m-1) break; + if (i >= m - 1) break; for (int j = i + 1; j < n; j++) if (abs(equations[j][i]) > abs(equations[pivot][i])) pivot = j; std::swap(equations[i], equations[pivot]); @@ -421,6 +421,13 @@ std::pair TotalRandomGuess() { } return std::make_pair(row, column); } +inline double GetProb(double default_p,const std::vector &ps) +{ + if(ps.empty()) return default_p; + double res=0; + for(int i=0;i SimpleGuess() { } if (total_known > 5) default_probability = (double)(total_known_with_mine) / (total_known); - // if((double)(total_known)/(rows*columns)<0.3) return TotalRandomGuess(); + // if((double)(total_known)/(rows*columns)<0.15) return TotalRandomGuess(); for (int i = 0; i < rows; i++) for (int j = 0; j < columns; j++) if (map_status[i][j] == 2) { @@ -474,22 +481,8 @@ std::pair SimpleGuess() { for (int i = 0; i < rows; i++) for (int j = 0; j < columns; j++) if (map_status[i][j] == 0) { - double current_prob = default_probability; - if (probability[best_guess.first][best_guess.second].size() > 0) { - current_prob = 0; - for (int k = 0; - k < probability[best_guess.first][best_guess.second].size(); k++) - current_prob += probability[best_guess.first][best_guess.second][k]; - current_prob /= - probability[best_guess.first][best_guess.second].size(); - } - double this_prob = default_probability; - if (probability[i][j].size() > 0) { - this_prob = 0; - for (int k = 0; k < probability[i][j].size(); k++) - this_prob += probability[i][j][k]; - this_prob /= probability[i][j].size(); - } + double current_prob=GetProb(default_probability,probability[best_guess.first][best_guess.second]); + double this_prob=GetProb(default_probability,probability[i][j]); if (this_prob < current_prob) { best_guess.first = i; best_guess.second = j;