|
@ -1,6 +1,6 @@ |
|
|
## 库的调用 |
|
|
## 库的调用 |
|
|
|
|
|
|
|
|
代码已封装为四个类 |
|
|
代码已封装为四个类,介绍如下 |
|
|
|
|
|
|
|
|
+ HRD_cal: 华容道快速计算器 |
|
|
+ HRD_cal: 华容道快速计算器 |
|
|
|
|
|
|
|
@ -37,6 +37,7 @@ using namespace std; |
|
|
|
|
|
|
|
|
int main() { |
|
|
int main() { |
|
|
cout << "Klotski fast calculator by Dnomd343" << endl; |
|
|
cout << "Klotski fast calculator by Dnomd343" << endl; |
|
|
|
|
|
cout << "----------------" << endl; |
|
|
vector <unsigned long long> dat; |
|
|
vector <unsigned long long> dat; |
|
|
HRD_cal demo; |
|
|
HRD_cal demo; |
|
|
|
|
|
|
|
@ -49,9 +50,13 @@ int main() { |
|
|
cout << "----------------" << endl; |
|
|
cout << "----------------" << endl; |
|
|
|
|
|
|
|
|
// 检测编码的正确性 |
|
|
// 检测编码的正确性 |
|
|
|
|
|
cout << "Check the code: 123456789 -> "; |
|
|
if (demo.Check_Code(0x123456789) == false) { |
|
|
if (demo.Check_Code(0x123456789) == false) { |
|
|
cout << "Code error!" << endl; |
|
|
cout << "Code error!" << endl; |
|
|
|
|
|
} else { |
|
|
|
|
|
cout << "No problem" << endl; |
|
|
} |
|
|
} |
|
|
|
|
|
cout << "----------------" << endl; |
|
|
|
|
|
|
|
|
// 计算最少步数(参数为unsigned long long 返回vector类) |
|
|
// 计算最少步数(参数为unsigned long long 返回vector类) |
|
|
dat = demo.Calculate(0x1A9BF0C00); |
|
|
dat = demo.Calculate(0x1A9BF0C00); |
|
@ -88,6 +93,8 @@ int main() { |
|
|
|
|
|
|
|
|
+ 检查编码是否合法 |
|
|
+ 检查编码是否合法 |
|
|
|
|
|
|
|
|
|
|
|
+ 检测编码是否左右对称 |
|
|
|
|
|
|
|
|
+ 根据起始布局分析出层级结构,包括各层间的链接关系 |
|
|
+ 根据起始布局分析出层级结构,包括各层间的链接关系 |
|
|
|
|
|
|
|
|
+ 得到布局的具体参数,包括全部最远布局、全部最少步解、全部合法解及其步数 |
|
|
+ 得到布局的具体参数,包括全部最远布局、全部最少步解、全部合法解及其步数 |
|
@ -105,10 +112,28 @@ using namespace std; |
|
|
|
|
|
|
|
|
int main() { |
|
|
int main() { |
|
|
cout << "Klotski Analyser by Dnomd343" << endl; |
|
|
cout << "Klotski Analyser by Dnomd343" << endl; |
|
|
|
|
|
cout << "---------------------------" << endl; |
|
|
HRD_analy demo; |
|
|
HRD_analy demo; |
|
|
|
|
|
|
|
|
|
|
|
// 判断编码是否左右对称 |
|
|
|
|
|
cout << "Check Mirror(code: 1A9BF0C00) -> "; |
|
|
|
|
|
if (demo.Is_Mirror(0x1A9BF0C00)) { |
|
|
|
|
|
cout << "yes" << endl; |
|
|
|
|
|
} else { |
|
|
|
|
|
cout << "no" << endl; |
|
|
|
|
|
} |
|
|
|
|
|
cout << "Check Mirror(code: 4FEA13400) -> "; |
|
|
|
|
|
if (demo.Is_Mirror(0x4FEA13400)) { |
|
|
|
|
|
cout << "yes" << endl; |
|
|
|
|
|
} else { |
|
|
|
|
|
cout << "no" << endl; |
|
|
|
|
|
} |
|
|
|
|
|
cout << "---------------------------" << endl; |
|
|
|
|
|
|
|
|
// 显示编码的实际布局样式 |
|
|
// 显示编码的实际布局样式 |
|
|
|
|
|
cout << "Show 1A9BF0C00: " << endl; |
|
|
demo.Output_Graph(0x1A9BF0C00, 4, 1, "&%"); |
|
|
demo.Output_Graph(0x1A9BF0C00, 4, 1, "&%"); |
|
|
|
|
|
cout << "---------------------------" << endl; |
|
|
|
|
|
|
|
|
// 解译编码 |
|
|
// 解译编码 |
|
|
demo.Parse_Code(0x1A9BF0C00); |
|
|
demo.Parse_Code(0x1A9BF0C00); |
|
@ -165,21 +190,32 @@ int main() { |
|
|
cout << "---------------------------" << endl; |
|
|
cout << "---------------------------" << endl; |
|
|
|
|
|
|
|
|
// 查看某布局的前后情况 |
|
|
// 查看某布局的前后情况 |
|
|
int layer_num = 29, layer_index = 190; |
|
|
int num = 29, index = 190; |
|
|
// 得到全部父节点 |
|
|
cout << "Case near (num = " << num << ", index = " << index << ")" << endl; |
|
|
for (int k = 0; k < (*(*demo.Layer[layer_num][layer_index]).adjacent).source_case.size(); k++) { |
|
|
|
|
|
cout << " (" << (*(*(*demo.Layer[layer_num][layer_index]).adjacent).source_case[k]).layer_num; |
|
|
// 得到全部父节点数据 |
|
|
cout << "," << (*(*(*demo.Layer[layer_num][layer_index]).adjacent).source_case[k]).layer_index << "):"; |
|
|
for (int k = 0; k < demo.Layer[num][index]->source_case->size(); k++) { |
|
|
cout << demo.Change_str((*(*(*demo.Layer[layer_num][layer_index]).adjacent).source_case[k]).code); |
|
|
cout << "(" << demo.Layer[num][index]->source_case->at(k)->layer_num; |
|
|
|
|
|
cout << "," << demo.Layer[num][index]->source_case->at(k)->layer_index << ") = "; |
|
|
|
|
|
cout << demo.Change_str(demo.Layer[num][index]->source_case->at(k)->code); |
|
|
|
|
|
if (k + 1 != demo.Layer[num][index]->source_case->size()) { |
|
|
|
|
|
cout << " / "; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 得到本节点数据 |
|
|
cout << " -> "; |
|
|
cout << " -> "; |
|
|
cout << " (" << layer_num << "," << layer_index << "):" << demo.Change_str((*demo.Layer[layer_num][layer_index]).code); |
|
|
cout << "(" << num << "," << index << ") = " << demo.Change_str(demo.Layer[num][index]->code); |
|
|
cout << " -> "; |
|
|
cout << " -> "; |
|
|
// 得到全部子节点 |
|
|
|
|
|
for (int k = 0; k < (*(*demo.Layer[layer_num][layer_index]).adjacent).next_case.size(); k++) { |
|
|
// 得到全部子节点数据 |
|
|
cout << " (" << (*(*(*demo.Layer[layer_num][layer_index]).adjacent).next_case[k]).layer_num; |
|
|
for (int k = 0; k < demo.Layer[num][index]->next_case->size(); k++) { |
|
|
cout << "," << (*(*(*demo.Layer[layer_num][layer_index]).adjacent).next_case[k]).layer_index << "):"; |
|
|
cout << "(" << demo.Layer[num][index]->next_case->at(k)->layer_num; |
|
|
cout << demo.Change_str((*(*(*demo.Layer[layer_num][layer_index]).adjacent).next_case[k]).code); |
|
|
cout << "," << demo.Layer[num][index]->next_case->at(k)->layer_index << ") = "; |
|
|
|
|
|
cout << demo.Change_str(demo.Layer[num][index]->next_case->at(k)->code); |
|
|
|
|
|
if (k + 1 != demo.Layer[num][index]->next_case->size()) { |
|
|
|
|
|
cout << " / "; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
cout << endl; |
|
|
cout << endl; |
|
|
cout << "---------------------------" << endl; |
|
|
cout << "---------------------------" << endl; |
|
@ -207,13 +243,16 @@ using namespace std; |
|
|
|
|
|
|
|
|
int main() { |
|
|
int main() { |
|
|
cout << "Klotski batch analyser by Dnomd343" << endl; |
|
|
cout << "Klotski batch analyser by Dnomd343" << endl; |
|
|
|
|
|
cout << "---------------------------" << endl; |
|
|
HRD_group demo; |
|
|
HRD_group demo; |
|
|
|
|
|
|
|
|
// 计算群组中所有元素的具体参数并输出到文件(此处即计算1A9BF0C00所在群的数据) |
|
|
// 计算群组中所有元素的具体参数并输出到文件(此处即计算1A9BF0C00所在群的数据) |
|
|
demo.Batch_Analyse(0x1A9BF0C00, "farthest.csv", "solution.csv", true); |
|
|
demo.Batch_Analyse(0x1A9BF0C00, "farthest.csv", "solution.csv", true); |
|
|
|
|
|
cout << "---------------------------" << endl; |
|
|
|
|
|
|
|
|
// 计算多个群组的分析信息,同时合并输出到文件(编码储存于5-4-0.txt中,最后一行切不可为空) |
|
|
// 计算多个群组的分析信息,同时合并输出到文件(编码储存于5-4-0.txt中,最后一行切不可为空) |
|
|
demo.Multi_Analyse("5-4-0.txt", "farthest_5-4-0.csv", "solution_5-4-0.csv", true); |
|
|
demo.Multi_Analyse("5-4-0.txt", "farthest_5-4-0.csv", "solution_5-4-0.csv", true); |
|
|
|
|
|
cout << "---------------------------" << endl; |
|
|
|
|
|
|
|
|
return 0; |
|
|
return 0; |
|
|
} |
|
|
} |
|
@ -240,13 +279,16 @@ using namespace std; |
|
|
|
|
|
|
|
|
int main() { |
|
|
int main() { |
|
|
cout << "Klotski statistician by Dnomd343" << endl; |
|
|
cout << "Klotski statistician by Dnomd343" << endl; |
|
|
|
|
|
cout << "---------------------------" << endl; |
|
|
HRD_statistic demo; |
|
|
HRD_statistic demo; |
|
|
|
|
|
|
|
|
// 找到全部合法的编码 |
|
|
// 找到全部合法的编码 |
|
|
demo.Find_All_Case("Output-All_Case.txt"); |
|
|
demo.Find_All_Case("Output-All_Case.txt"); |
|
|
|
|
|
cout << "---------------------------" << endl; |
|
|
|
|
|
|
|
|
// 找到全部合法的编码并进行分类输出 |
|
|
// 找到全部合法的编码并进行分类输出 |
|
|
demo.All_Statistic(); |
|
|
demo.All_Statistic(); |
|
|
|
|
|
cout << "---------------------------" << endl; |
|
|
|
|
|
|
|
|
return 0; |
|
|
return 0; |
|
|
} |
|
|
} |