add first two dimension

This commit is contained in:
2023-09-30 16:50:49 +08:00
parent a270369b18
commit b2d4b2f463

View File

@ -437,9 +437,10 @@ inline double GetProb(double default_p, const std::vector<double> &ps) {
*/ */
std::pair<int, int> SimpleGuess() { std::pair<int, int> SimpleGuess() {
using namespace Client; using namespace Client;
const double m_pow=1;
// std::cout << "SimpleGuess" << std::endl; // std::cout << "SimpleGuess" << std::endl;
std::vector<double> probability[max_size][max_size]; std::vector<double> probability[max_size][max_size];
double default_probability = 0.06; double default_probability = pow(0.06,m_pow);
int total_known = 0, total_known_with_mine = 0; int total_known = 0, total_known_with_mine = 0;
for (int i = 0; i < rows; i++) for (int i = 0; i < rows; i++)
for (int j = 0; j < columns; j++) for (int j = 0; j < columns; j++)
@ -448,7 +449,7 @@ std::pair<int, int> SimpleGuess() {
if (map_status[i][j] == -1) total_known_with_mine++; if (map_status[i][j] == -1) total_known_with_mine++;
} }
if (total_known > 5) if (total_known > 5)
default_probability = (double)(total_known_with_mine) / (total_known); default_probability = pow((double)(total_known_with_mine) / (total_known),m_pow);
// if((double)(total_known)/(rows*columns)<0.15) return TotalRandomGuess(); // if((double)(total_known)/(rows*columns)<0.15) return TotalRandomGuess();
for (int i = 0; i < rows; i++) for (int i = 0; i < rows; i++)
for (int j = 0; j < columns; j++) for (int j = 0; j < columns; j++)
@ -473,8 +474,8 @@ std::pair<int, int> SimpleGuess() {
int x = i + dx[k], y = j + dy[k]; int x = i + dx[k], y = j + dy[k];
if (x >= 0 && x < rows && y >= 0 && y < columns) { if (x >= 0 && x < rows && y >= 0 && y < columns) {
if (map_status[x][y] == 0) if (map_status[x][y] == 0)
probability[x][y].push_back((double)(nearby_mines) / probability[x][y].push_back(pow((double)(nearby_mines) /
(nearby_unkown)); (nearby_unkown),m_pow));
} }
} }
} }