first test

This commit is contained in:
2023-09-28 00:26:53 +08:00
parent 29074e81d8
commit 67aecb0cdb
2 changed files with 13 additions and 11 deletions

View File

@ -15,7 +15,7 @@ void Execute(int row, int column) {
std::string str; std::string str;
VisitBlock(row, column); VisitBlock(row, column);
if (game_state != 0) { if (game_state != 0) {
PrintMap(); // this line may help you debug // PrintMap(); // this line may help you debug
ExitGame(); ExitGame();
} }
std::ostringstream oss; std::ostringstream oss;
@ -35,8 +35,8 @@ void Execute(int row, int column) {
// stores the output recently // stores the output recently
ReadMap(); ReadMap();
std::cin.rdbuf(old_input_buffer); // Restore the input buffer std::cin.rdbuf(old_input_buffer); // Restore the input buffer
PrintMap(); // These two lines may help you debug // PrintMap(); // These two lines may help you debug
std::cout << std::endl; // std::cout << std::endl;
} }
int main() { int main() {

View File

@ -54,8 +54,8 @@ void InitGame() {
* 01? * 01?
*/ */
namespace Client { namespace Client {
const unsigned int RndSeed = 21212303; // std::random_device{}(); const unsigned int RndSeed = std::random_device{}();
std::mt19937 RawRnd(RndSeed); // a basic random generator std::mt19937 RawRnd(RndSeed); // a basic random generator
const int max_size = 35; const int max_size = 35;
char game_map[max_size][max_size]; // store the raw game map in format of char char game_map[max_size][max_size]; // store the raw game map in format of char
std::queue<std::pair<int, int> > std::queue<std::pair<int, int> >
@ -132,6 +132,7 @@ std::vector<std::pair<int, int> > variaID_to_position;
* @details This function is designed to print the equations for debugging * @details This function is designed to print the equations for debugging
*/ */
void PrintEquations(std::vector<std::vector<double> > equations) { void PrintEquations(std::vector<std::vector<double> > equations) {
return;
std::cout << "equations:" << std::endl; std::cout << "equations:" << std::endl;
for (int i = 0; i < equations.size(); i++) { for (int i = 0; i < equations.size(); i++) {
for (int j = 0; j < equations[i].size(); j++) for (int j = 0; j < equations[i].size(); j++)
@ -266,8 +267,8 @@ std::vector<std::vector<double> > GaussianJordanElimination(
* equations * equations
*/ */
void InterpretResult(std::vector<std::vector<double> > equations) { void InterpretResult(std::vector<std::vector<double> > equations) {
std::cout << "InterpretResult" << std::endl; // std::cout << "InterpretResult" << std::endl;
PrintEquations(equations); // PrintEquations(equations);
int n = equations.size(); int n = equations.size();
if (n == 0) return; if (n == 0) return;
int m = equations[0].size(); int m = equations[0].size();
@ -293,11 +294,13 @@ void InterpretResult(std::vector<std::vector<double> > equations) {
if (sol == 0) { if (sol == 0) {
map_status[pos.first][pos.second] = 1; map_status[pos.first][pos.second] = 1;
no_mine_block_to_be_clicked.push(pos); no_mine_block_to_be_clicked.push(pos);
std::cout<<"push ("<<pos.first<<","<<pos.second<<")"<<std::endl; // std::cout << "push (" << pos.first << "," << pos.second << ")"
// << std::endl;
} }
if (sol == 1) { if (sol == 1) {
map_status[pos.first][pos.second] = -1; map_status[pos.first][pos.second] = -1;
std::cout<<"set ("<<pos.first<<","<<pos.second<<")"<<std::endl; // std::cout << "set (" << pos.first << "," << pos.second << ")"
// << std::endl;
} }
} }
} }
@ -343,8 +346,7 @@ void PreProcessData() {
*/ */
std::pair<int, int> TotalRandomGuess() { std::pair<int, int> TotalRandomGuess() {
using namespace Client; using namespace Client;
std::cout << "TotalRandomGuess" << std::endl; // std::cout << "TotalRandomGuess" << std::endl;
// use a fixed random key
std::uniform_int_distribution<int> row_dis(0, rows - 1), std::uniform_int_distribution<int> row_dis(0, rows - 1),
column_dis(0, columns - 1); column_dis(0, columns - 1);
int row = row_dis(RawRnd), column = column_dis(RawRnd); int row = row_dis(RawRnd), column = column_dis(RawRnd);