test next two values
This commit is contained in:
@ -178,16 +178,16 @@ def ATest():
|
||||
return win_round/total_round
|
||||
|
||||
value1_list=[0.25,0.5,0.75,1,1.25,1.5,1.75,2,2.25,2.5,3]
|
||||
value2_list=[0.6,0.7,0.8,0.9,1,1.1,1.2,1.3,1.4,1.5,1.7,2,2.5,3]
|
||||
value2_list=[0.25,0.5,0.75,1,1.25,1.5,1.75,2,2.25,2.5,3]
|
||||
def GenerateSource(value1,value2):
|
||||
# read src/include/client.h
|
||||
fn=open("src/include/client.h","r")
|
||||
lines=fn.readlines()
|
||||
fn.close()
|
||||
# change the 428 th line into "value1; //auto set"
|
||||
lines[427]="\t"+str(value1)+"; //auto set\n"
|
||||
# change the 440 th line into "const double m_pow=value2; //auto set"
|
||||
lines[439]="\tconst double m_pow="+str(value2)+"; //auto set\n"
|
||||
# change the 441 th line to "const double m_pow_edge = "+str(value1)+";"
|
||||
lines[440]="const double m_pow_edge = "+str(value1)+";\n"
|
||||
# change the 442 th line to "const double m_pow_coner = "+str(value2)+";"
|
||||
lines[441]="const double m_pow_coner = "+str(value2)+";\n"
|
||||
# write the source to "tmp/client.h"
|
||||
fn=open("tmp/client.h","w")
|
||||
fn.writelines(lines)
|
@ -425,7 +425,8 @@ inline double GetProb(double default_p, const std::vector<double> &ps) {
|
||||
if (ps.empty()) return default_p;
|
||||
double res = 0;
|
||||
const double v =
|
||||
2; // use root mean square to estimate the probability in a cautious way
|
||||
1.75; // use root mean square to estimate the probability in a cautious
|
||||
// way,and this specific value is chosen by testing
|
||||
for (int i = 0; i < ps.size(); i++) res += pow(ps[i], v);
|
||||
return pow(res / ps.size(), 1.0 / v);
|
||||
}
|
||||
@ -437,10 +438,11 @@ inline double GetProb(double default_p, const std::vector<double> &ps) {
|
||||
*/
|
||||
std::pair<int, int> SimpleGuess() {
|
||||
using namespace Client;
|
||||
const double m_pow=1;
|
||||
const double m_pow_edge = 1;
|
||||
const double m_pow_coner = 1;
|
||||
// std::cout << "SimpleGuess" << std::endl;
|
||||
std::vector<double> probability[max_size][max_size];
|
||||
double default_probability = pow(0.06,m_pow);
|
||||
double default_probability = pow(0.06, (m_pow_edge + m_pow_coner) / 2);
|
||||
int total_known = 0, total_known_with_mine = 0;
|
||||
for (int i = 0; i < rows; i++)
|
||||
for (int j = 0; j < columns; j++)
|
||||
@ -449,7 +451,8 @@ std::pair<int, int> SimpleGuess() {
|
||||
if (map_status[i][j] == -1) total_known_with_mine++;
|
||||
}
|
||||
if (total_known > 5)
|
||||
default_probability = pow((double)(total_known_with_mine) / (total_known),m_pow);
|
||||
default_probability = pow((double)(total_known_with_mine) / (total_known),
|
||||
(m_pow_coner + m_pow_edge) / 2);
|
||||
// if((double)(total_known)/(rows*columns)<0.15) return TotalRandomGuess();
|
||||
for (int i = 0; i < rows; i++)
|
||||
for (int j = 0; j < columns; j++)
|
||||
@ -474,8 +477,14 @@ std::pair<int, int> SimpleGuess() {
|
||||
int x = i + dx[k], y = j + dy[k];
|
||||
if (x >= 0 && x < rows && y >= 0 && y < columns) {
|
||||
if (map_status[x][y] == 0)
|
||||
probability[x][y].push_back(pow((double)(nearby_mines) /
|
||||
(nearby_unkown),m_pow));
|
||||
if (abs(dx[k]) + abs(dy[k]) == 2)
|
||||
probability[x][y].push_back(
|
||||
pow((double)(nearby_mines) / (nearby_unkown), m_pow_coner));
|
||||
else
|
||||
probability[x][y].push_back(
|
||||
pow((double)(nearby_mines) / (nearby_unkown), m_pow_edge));
|
||||
assert(abs(dx[k]) + abs(dy[k]) == 1 ||
|
||||
abs(dx[k]) + abs(dy[k]) == 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user