From 4d51eb339cab2a8e1ef8a3dd8080acd31aef7776 Mon Sep 17 00:00:00 2001 From: ZhuangYumin Date: Thu, 28 Sep 2023 12:59:07 +0800 Subject: [PATCH] format --- src/include/client.h | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/include/client.h b/src/include/client.h index 812f6e2..d1ef6f0 100644 --- a/src/include/client.h +++ b/src/include/client.h @@ -421,13 +421,12 @@ 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; - const double v=2; - for(int i=0;i &ps) { + if (ps.empty()) return default_p; + double res = 0; + const double v = 2; + for (int i = 0; i < ps.size(); i++) res += pow(ps[i], v); + return pow(res / ps.size(), 1.0 / v); } /** * @brief The definition of function SimpleGuess() @@ -482,8 +481,10 @@ 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=GetProb(default_probability,probability[best_guess.first][best_guess.second]); - double this_prob=GetProb(default_probability,probability[i][j]); + 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;