Browse Source

update engine

master
Dnomd343 4 years ago
parent
commit
058e95ad28
  1. 4
      src/engine/HRD_analy.cpp
  2. 98
      src/engine/HRD_analy.h
  3. 64
      src/engine/HRD_cal.h
  4. 82
      src/engine/HRD_group.h
  5. 54
      src/engine/HRD_statistic.h

4
src/engine/HRD_analy.cpp

@ -319,11 +319,11 @@ void HRD_analy::Analyse_Case(unsigned long long code) { // 分析输入编码的
for (j = 0; j < Layer[i].size(); j++) {
if ((Layer[i][j]->code >> 32) == 0xD) { // 2 * 2块在出口位置
min_solution_step = i; // 找到最少步数
j = Layer[i].size(); // 跳出两层循环
i = Layer.size();
goto get_min_solution_step; // 跳出两层循环
}
}
}
get_min_solution_step:;
if (min_solution_step == -1) {return;} // 无解则退出
for (i = 0; i < Layer[min_solution_step].size(); i++) { // 遍历最少步所在层
if ((Layer[min_solution_step][i]->code >> 32) == 0xD) { // 判断是否为解

98
src/engine/HRD_analy.h

@ -6,57 +6,57 @@
using namespace std;
class HRD_analy {
public:
~HRD_analy();
struct Case_cal {
bool freeze[4][5]; // true -> no move ; false -> can move
unsigned char status[4][5]; // 0xFF -> undefined ; 0xFE -> space
unsigned char type[15]; // 0 -> 2 * 2 ; 1 -> 2 * 1 ; 2 -> 1 * 2 ; 3 -> 1 * 1
unsigned long long code;
unsigned int layer_num;
unsigned int layer_index;
vector <Case_cal *> *source_case;
vector <Case_cal *> *next_case;
};
vector < vector <Case_cal *> > Layer; // 储存全部层数据的节点
Case_cal Parse_dat;
bool quiet = false; // true -> 静默模式 false -> 输出运算情况
// 布局的基本参数
int stop_point_num; // 端点的个数
int min_solution_step; // 最少的步数
int min_solution_num; // 最少步解的个数
vector <unsigned long long> min_solution_case; // 所有最少步解
vector <unsigned int> solution_step; // 所有解对应的步数
int solution_num; // 解的个数
vector <unsigned long long> solution_case; // 所有解
int farthest_step; // 最远布局的步数
int farthest_num; // 最远布局的个数
vector <unsigned long long> farthest_case; // 所有最远的布局
public:
~HRD_analy();
struct Case_cal {
bool freeze[4][5]; // true -> no move ; false -> can move
unsigned char status[4][5]; // 0xFF -> undefined ; 0xFE -> space
unsigned char type[15]; // 0 -> 2 * 2 ; 1 -> 2 * 1 ; 2 -> 1 * 2 ; 3 -> 1 * 1
unsigned long long code;
unsigned int layer_num;
unsigned int layer_index;
vector <Case_cal *> *source_case;
vector <Case_cal *> *next_case;
};
vector < vector <Case_cal *> > Layer; // 储存全部层数据的节点
Case_cal Parse_dat;
bool quiet = false; // true -> 静默模式 false -> 输出运算情况
// 布局的基本参数
int stop_point_num; // 端点的个数
int min_solution_step; // 最少的步数
int min_solution_num; // 最少步解的个数
vector <unsigned long long> min_solution_case; // 所有最少步解
vector <unsigned int> solution_step; // 所有解对应的步数
int solution_num; // 解的个数
vector <unsigned long long> solution_case; // 所有解
int farthest_step; // 最远布局的步数
int farthest_num; // 最远布局的个数
vector <unsigned long long> farthest_case; // 所有最远的布局
unsigned long long Change_int(char str[10]);
string Change_str(unsigned long long dat);
bool Check_Code(unsigned long long code);
bool Parse_Code(unsigned long long code);
bool Is_Mirror(unsigned long long code);
void Analyse_Case(unsigned long long code);
void Output_Detail(string File_name);
void Free_Data();
void Output_All_Path(string File_name);
bool Output_Path(vector <unsigned long long> target, string File_name);
void Output_Graph(unsigned long long code, unsigned int square_width, unsigned int square_gap, char str[2]);
unsigned long long Change_int(char str[10]);
string Change_str(unsigned long long dat);
bool Check_Code(unsigned long long code);
bool Parse_Code(unsigned long long code);
bool Is_Mirror(unsigned long long code);
void Analyse_Case(unsigned long long code);
void Output_Detail(string File_name);
void Free_Data();
void Output_All_Path(string File_name);
bool Output_Path(vector <unsigned long long> target, string File_name);
void Output_Graph(unsigned long long code, unsigned int square_width, unsigned int square_gap, char str[2]);
private:
Case_cal *now_move_case;
vector <Case_cal *> *Layer_hash = new vector <Case_cal *> [0x10000]; // 哈希表
unsigned int now_move_num, now_move_index; // 当前扫描节点的层编号 / 当前扫描节点的层中编号
bool Parse_Code(Case_cal &dat, unsigned long long code);
void Get_Code(Case_cal &dat);
void Find_Sub_Case(Case_cal &dat, int &num, int x, int y, bool addr[4][5]);
void Build_Case(Case_cal &dat, int &num, int x, int y, bool addr[4][5]);
void Find_Next_Case(Case_cal &dat_raw);
void Add_Case(Case_cal *dat);
void Calculate(unsigned long long code);
bool Search_Case(unsigned long long code, Case_cal* &dat);
private:
Case_cal *now_move_case;
vector <Case_cal *> *Layer_hash = new vector <Case_cal *> [0x10000]; // 哈希表
unsigned int now_move_num, now_move_index; // 当前扫描节点的层编号 / 当前扫描节点的层中编号
bool Parse_Code(Case_cal &dat, unsigned long long code);
void Get_Code(Case_cal &dat);
void Find_Sub_Case(Case_cal &dat, int &num, int x, int y, bool addr[4][5]);
void Build_Case(Case_cal &dat, int &num, int x, int y, bool addr[4][5]);
void Find_Next_Case(Case_cal &dat_raw);
void Add_Case(Case_cal *dat);
void Calculate(unsigned long long code);
bool Search_Case(unsigned long long code, Case_cal* &dat);
};
#endif

64
src/engine/HRD_cal.h

@ -6,40 +6,40 @@
using namespace std;
class HRD_cal {
public:
~HRD_cal();
unsigned long long Change_int(char str[10]);
string Change_str(unsigned long long dat);
bool Check_Code(unsigned long long code);
vector <unsigned long long> Calculate(unsigned long long code);
vector <unsigned long long> Calculate_All(unsigned long long code);
vector <unsigned long long> Calculate(unsigned long long code, unsigned long long target);
public:
~HRD_cal();
unsigned long long Change_int(char str[10]);
string Change_str(unsigned long long dat);
bool Check_Code(unsigned long long code);
vector <unsigned long long> Calculate(unsigned long long code);
vector <unsigned long long> Calculate_All(unsigned long long code);
vector <unsigned long long> Calculate(unsigned long long code, unsigned long long target);
private:
struct Case_cal {
bool freeze[4][5]; // true -> no move ; false -> can move
unsigned char status[4][5]; // 0xFF -> undefined ; 0xFE -> space
unsigned char type[15]; // 0 -> 2 * 2 ; 1 -> 2 * 1 ; 2 -> 1 * 2 ; 3 -> 1 * 1
unsigned long long code;
};
vector <Case_cal *> List; // 主队列 储存每个节点的信息
vector <Case_cal *> *List_hash = new vector <Case_cal *> [0x10000]; // 哈希表
vector <unsigned int> List_source; // 储存上一步编号 用于溯源
unsigned int now_move; // 当前正在计算的块的编号
unsigned int result; // 得到的目标编号
unsigned long long target_code;
unsigned char mode; // 0 -> Calculate_All / 1 -> Calculate_Solution / 2 -> Calculate_Target
bool flag; // 判断是否已找到目标
private:
struct Case_cal {
bool freeze[4][5]; // true -> no move ; false -> can move
unsigned char status[4][5]; // 0xFF -> undefined ; 0xFE -> space
unsigned char type[15]; // 0 -> 2 * 2 ; 1 -> 2 * 1 ; 2 -> 1 * 2 ; 3 -> 1 * 1
unsigned long long code;
};
vector <Case_cal *> List; // 主队列 储存每个节点的信息
vector <Case_cal *> *List_hash = new vector <Case_cal *> [0x10000]; // 哈希表
vector <unsigned int> List_source; // 储存上一步编号 用于溯源
unsigned int now_move; // 当前正在计算的块的编号
unsigned int result; // 得到的目标编号
unsigned long long target_code;
unsigned char mode; // 0 -> Calculate_All / 1 -> Calculate_Solution / 2 -> Calculate_Target
bool flag; // 判断是否已找到目标
bool Parse_Code(Case_cal &dat, unsigned long long code);
void Get_Code(Case_cal &dat);
void Find_Sub_Case(Case_cal &dat, int &num, int x, int y, bool addr[4][5]);
void Build_Case(Case_cal &dat, int &num, int x, int y, bool addr[4][5]);
void Find_Next_Case(Case_cal &dat_raw);
void Add_Case(Case_cal *dat);
void cal(unsigned long long code);
void init_data();
vector <unsigned long long> Get_Path(unsigned int result_num);
bool Parse_Code(Case_cal &dat, unsigned long long code);
void Get_Code(Case_cal &dat);
void Find_Sub_Case(Case_cal &dat, int &num, int x, int y, bool addr[4][5]);
void Build_Case(Case_cal &dat, int &num, int x, int y, bool addr[4][5]);
void Find_Next_Case(Case_cal &dat_raw);
void Add_Case(Case_cal *dat);
void cal(unsigned long long code);
void init_data();
vector <unsigned long long> Get_Path(unsigned int result_num);
};
#endif

82
src/engine/HRD_group.h

@ -6,51 +6,51 @@
using namespace std;
class HRD_group {
public:
unsigned long long Change_int(char str[10]);
string Change_str(unsigned long long dat);
void Batch_Analyse(unsigned long long seed, string name_farthest, string name_solution, bool is_output_solution);
bool Multi_Analyse(string seed_File_name, string name_farthest, string name_solution, bool is_output_solution);
public:
unsigned long long Change_int(char str[10]);
string Change_str(unsigned long long dat);
void Batch_Analyse(unsigned long long seed, string name_farthest, string name_solution, bool is_output_solution);
bool Multi_Analyse(string seed_File_name, string name_farthest, string name_solution, bool is_output_solution);
private:
struct Case_cal {
unsigned long long code;
unsigned char status[4][5]; // 0xFF -> undefined ; 0xFE -> space
unsigned char type[15]; // 0 -> 2 * 2 ; 1 -> 2 * 1 ; 2 -> 1 * 2 ; 3 -> 1 * 1
};
struct Case {
unsigned long long code;
int layer_num;
bool flag;
unsigned int addr_2x2;
vector <Case *> next;
};
struct Case_detail {
unsigned long long code;
int farthest_step;
int farthest_num;
vector <unsigned long long> farthest_case;
private:
struct Case_cal {
unsigned long long code;
unsigned char status[4][5]; // 0xFF -> undefined ; 0xFE -> space
unsigned char type[15]; // 0 -> 2 * 2 ; 1 -> 2 * 1 ; 2 -> 1 * 2 ; 3 -> 1 * 1
};
struct Case {
unsigned long long code;
int layer_num;
bool flag;
unsigned int addr_2x2;
vector <Case *> next;
};
struct Case_detail {
unsigned long long code;
int farthest_step;
int farthest_num;
vector <unsigned long long> farthest_case;
int min_solution_step;
int min_solution_num;
vector <unsigned long long> min_solution_case;
int min_solution_step;
int min_solution_num;
vector <unsigned long long> min_solution_case;
int solution_num;
vector <unsigned long long> solution_case;
vector <unsigned long long> solution_step;
};
vector <unsigned long long> Next_Case_dat; // 储存Find_Next_Case找到的结果
bool Output_solution_case; // 是否输出全部solution_case
int solution_num;
vector <unsigned long long> solution_case;
vector <unsigned long long> solution_step;
};
vector <unsigned long long> Next_Case_dat; // 储存Find_Next_Case找到的结果
bool Output_solution_case; // 是否输出全部solution_case
bool Parse_Code(Case_cal &dat, unsigned long long code);
void Get_Code(Case_cal &dat);
void Find_Sub_Case(Case_cal &dat, int &num, int x, int y, bool addr[4][5]);
void Build_Case(Case_cal &dat, int &num, int x, int y, bool addr[4][5]);
vector <unsigned long long> Find_Next_Case(unsigned long long code);
void Case_detail_init(Case_detail &dat);
Case_detail* Analyse_Case(Case *start);
void Analyse_Group(vector <unsigned long long> dat);
void Output_detail(Case_detail *dat);
bool Parse_Code(Case_cal &dat, unsigned long long code);
void Get_Code(Case_cal &dat);
void Find_Sub_Case(Case_cal &dat, int &num, int x, int y, bool addr[4][5]);
void Build_Case(Case_cal &dat, int &num, int x, int y, bool addr[4][5]);
vector <unsigned long long> Find_Next_Case(unsigned long long code);
void Case_detail_init(Case_detail &dat);
Case_detail* Analyse_Case(Case *start);
void Analyse_Group(vector <unsigned long long> dat);
void Output_detail(Case_detail *dat);
};
#endif

54
src/engine/HRD_statistic.h

@ -6,35 +6,35 @@
using namespace std;
class HRD_statistic {
public:
void Find_All_Case(string File_name);
void All_Statistic();
public:
void Find_All_Case(string File_name);
void All_Statistic();
private:
struct Case {
unsigned int id;
bool is_mirror;
unsigned long long code;
unsigned char jiang_num;
unsigned char bing_num;
unsigned char style_num;
unsigned int group_num;
unsigned int group_index;
};
struct Case_group {
unsigned int id;
unsigned long long code;
unsigned int group_num;
unsigned int group_index;
};
vector <Case *> All_Case; // 记录所有布局的信息
private:
struct Case {
unsigned int id;
bool is_mirror;
unsigned long long code;
unsigned char jiang_num;
unsigned char bing_num;
unsigned char style_num;
unsigned int group_num;
unsigned int group_index;
};
struct Case_group {
unsigned int id;
unsigned long long code;
unsigned int group_num;
unsigned int group_index;
};
vector <Case *> All_Case; // 记录所有布局的信息
void Get_seed();
void Find_All_Case();
void Sort_All_Case();
vector <Case_group *> Split_Group(vector <unsigned long long> dat);
void Output_All_Case(string File_name);
void Output_main_table(string File_name);
void Get_seed();
void Find_All_Case();
void Sort_All_Case();
vector <Case_group *> Split_Group(vector <unsigned long long> dat);
void Output_All_Case(string File_name);
void Output_main_table(string File_name);
};
#endif

Loading…
Cancel
Save