diff --git a/README.md b/README.md index 0a9e70b..0434110 100644 --- a/README.md +++ b/README.md @@ -75,10 +75,12 @@ ![visual_tool](./docs/images/visual_tool.png) -使用方法 +工具介绍 + 通过鼠标拖拽画出棋子 ++ 绘制时违反规则会出现提示 + + 通过单击删除棋子 + 下方文本框输入编码自动生成布局 @@ -91,6 +93,12 @@ + 完成按钮可补0生成九位编码 +下载 + +[Github仓库](./res/HRD_Virual.exe) + +[备用链接](https://hrd.dnomd343.top/download/HRD_Virual.exe) + ### 计算引擎 @@ -98,7 +106,7 @@ 源码编译后是命令行程序,需输入指定命令进行运算工作,具体[使用方法](./docs/usage.md)将在这篇文档中阐述。 -引擎封装了多个类实现不同功能,如果你有其他需求可以直接调用它的封装函数实现,这是它库函数的[使用演示](./docs/class.md)。 +引擎封装了多个类实现不同功能,如果你有其他需求可以直接调用它的封装函数实现,这是它库函数的[使用演示](./docs/demo.md)。 ### 如何运行这个项目 diff --git a/docs/class.md b/docs/demo.md similarity index 71% rename from docs/class.md rename to docs/demo.md index 8013ddf..d33723c 100644 --- a/docs/class.md +++ b/docs/demo.md @@ -1,6 +1,6 @@ ## 库的调用 -代码已封装为四个类 +代码已封装为四个类,介绍如下 + HRD_cal: 华容道快速计算器 @@ -37,9 +37,10 @@ using namespace std; int main() { cout << "Klotski fast calculator by Dnomd343" << endl; + cout << "----------------" << endl; vector dat; HRD_cal demo; - + // 将编码转为文本(参数为unsigned long long 返回string类) cout << "4FEA13400 is " << demo.Change_str(0x4FEA13400) << endl; cout << "----------------" << endl; @@ -49,10 +50,14 @@ int main() { cout << "----------------" << endl; // 检测编码的正确性 + cout << "Check the code: 123456789 -> "; if (demo.Check_Code(0x123456789) == false) { cout << "Code error!" << endl; + } else { + cout << "No problem" << endl; } - + cout << "----------------" << endl; + // 计算最少步数(参数为unsigned long long 返回vector类) dat = demo.Calculate(0x1A9BF0C00); cout << demo.Change_str(0x1A9BF0C00) << "'s solution"; @@ -88,6 +93,8 @@ int main() { + 检查编码是否合法 ++ 检测编码是否左右对称 + + 根据起始布局分析出层级结构,包括各层间的链接关系 + 得到布局的具体参数,包括全部最远布局、全部最少步解、全部合法解及其步数 @@ -105,10 +112,28 @@ using namespace std; int main() { cout << "Klotski Analyser by Dnomd343" << endl; + cout << "---------------------------" << endl; 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, "&%"); + cout << "---------------------------" << endl; // 解译编码 demo.Parse_Code(0x1A9BF0C00); @@ -165,25 +190,36 @@ int main() { cout << "---------------------------" << endl; // 查看某布局的前后情况 - int layer_num = 29, layer_index = 190; - // 得到全部父节点 - 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 << "):"; - cout << demo.Change_str((*(*(*demo.Layer[layer_num][layer_index]).adjacent).source_case[k]).code); + int num = 29, index = 190; + cout << "Case near (num = " << num << ", index = " << index << ")" << endl; + + // 得到全部父节点数据 + for (int k = 0; k < demo.Layer[num][index]->source_case->size(); k++) { + 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 << " (" << layer_num << "," << layer_index << "):" << demo.Change_str((*demo.Layer[layer_num][layer_index]).code); - 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; - cout << "," << (*(*(*demo.Layer[layer_num][layer_index]).adjacent).next_case[k]).layer_index << "):"; - cout << demo.Change_str((*(*(*demo.Layer[layer_num][layer_index]).adjacent).next_case[k]).code); + + // 得到本节点数据 + cout << " -> "; + cout << "(" << num << "," << index << ") = " << demo.Change_str(demo.Layer[num][index]->code); + cout << " -> "; + + // 得到全部子节点数据 + for (int k = 0; k < demo.Layer[num][index]->next_case->size(); k++) { + cout << "(" << demo.Layer[num][index]->next_case->at(k)->layer_num; + 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; - + return 0; } ``` @@ -207,13 +243,16 @@ using namespace std; int main() { cout << "Klotski batch analyser by Dnomd343" << endl; + cout << "---------------------------" << endl; HRD_group demo; // 计算群组中所有元素的具体参数并输出到文件(此处即计算1A9BF0C00所在群的数据) demo.Batch_Analyse(0x1A9BF0C00, "farthest.csv", "solution.csv", true); - + cout << "---------------------------" << endl; + // 计算多个群组的分析信息,同时合并输出到文件(编码储存于5-4-0.txt中,最后一行切不可为空) demo.Multi_Analyse("5-4-0.txt", "farthest_5-4-0.csv", "solution_5-4-0.csv", true); + cout << "---------------------------" << endl; return 0; } @@ -240,14 +279,17 @@ using namespace std; int main() { cout << "Klotski statistician by Dnomd343" << endl; + cout << "---------------------------" << endl; HRD_statistic demo; // 找到全部合法的编码 demo.Find_All_Case("Output-All_Case.txt"); - + cout << "---------------------------" << endl; + // 找到全部合法的编码并进行分类输出 demo.All_Statistic(); - + cout << "---------------------------" << endl; + return 0; } ``` \ No newline at end of file diff --git a/docs/group_num.md b/docs/group_num.md index f8871a7..dd7f3eb 100644 --- a/docs/group_num.md +++ b/docs/group_num.md @@ -1,6 +1,6 @@ ## 群的数量统计 -| jiang_num | bing_num | style_num | 群的数量 | +| jiang_num | bing_num | style_num | COUNT | | :-: | :-: | :-: | :-: | | 0 | 0 | 0 | 1 | | 0 | 1 | 0 | 1 | diff --git a/docs/usage.md b/docs/usage.md index 588fa80..a00184e 100644 --- a/docs/usage.md +++ b/docs/usage.md @@ -4,47 +4,47 @@ ```bash --show [square_width] Purpose: Visualize the - exp: ./engine --show 1A9BF0C00 - ./engine --show 1A9BF0C00 4 + eg: ./engine --show 1A9BF0C00 + ./engine --show 1A9BF0C00 5 ``` + cal命令:计算输入布局的最少步解法 ```bash --cal [file_name] Purpose: Find the minimum step solution of - exp: ./engine --cal 1A9BF0C00 - ./engine --cal 1A9BF0C00 demo.txt + eg: ./engine --cal 1A9BF0C00 + ./engine --cal 1A9BF0C00 demo.txt ``` + cal-target命令:计算两布局之间的最短路径 ```bash --cal-target [file_name] Purpose: Find the shortest path from to - exp: ./engine --cal-target 4FEA13400 43EA73400 - ./engine --cal-target 4FEA13400 43EA73400 demo.txt + eg: ./engine --cal-target 4FEA13400 43EA73400 + ./engine --cal-target 4FEA13400 43EA73400 demo.txt ``` + group命令:计算起始布局的所有衍生情况,即计算其所在群的全部元素 ```bash --group [file_name] Purpose: Find all elements of the group where located - exp: ./engine --group 4FEA13400 - ./engine --group 4FEA13400 demo.txt + eg: ./engine --group 4FEA13400 + ./engine --group 4FEA13400 demo.txt ``` + analy命令:分析布局的具体参数,包括层级结构,层间链接,解与最少步解,最远布局等 ```bash --analy [file_name] Purpose: Detailed analysis of the - exp: ./engine --analy 1A9BF0C00 - ./engine --analy 1A9BF0C00 demo.txt + eg: ./engine --analy 1A9BF0C00 + ./engine --analy 1A9BF0C00 demo.txt ``` + analy-quiet命令:同analy命令,但不输出计算过程 ```bash --analy-quiet Purpose: The same function as --analy, but doesn't show the specific process - exp: ./engine --analy-quiet 1A9BF0C00 demo.txt + eg: ./engine --analy-quiet 1A9BF0C00 demo.txt ``` + analy-group命令:分析`code`衍生出的群中所有元素的具体参数,并输出到`最远布局信息`和`解的信息`两张csv表格中 @@ -53,14 +53,14 @@ : As the output file of "farthest" : As the output file of "solution" Purpose: Analyze the whole group where located - exp: ./engine --analy-group 1A9BF0C00 farthest.csv solution.csv + eg: ./engine --analy-group 1A9BF0C00 farthest.csv solution.csv ``` + analy-group-integral命令:同analy-group命令,但`解的信息`中将会输出全部解的编码及步数 ```bash --analy-group-integral Purpose: The same function as --analy-group, but all solution case will be output - exp: ./engine --analy-group-integral 1A9BF0C00 farthest.csv solution.csv + eg: ./engine --analy-group-integral 1A9BF0C00 farthest.csv solution.csv ``` + analy-multi-group命令:多群组同时分析,相当于多次执行analy-group命令,结果合并输出到`最远布局信息`和`解的信息`两张csv表格中 @@ -70,35 +70,35 @@ : As the output file of "farthest" : As the output file of "solution" Purpose: Analyze the whole group where each seed located - exp: ./engine --analy-multi-group 5-4-0.txt farthest.csv solution.csv + eg: ./engine --analy-multi-group 5-4-0.txt farthest.csv solution.csv ``` + analy-multi-group-integral命令:同analy-multi-group命令,但`解的信息`中将会输出全部解的编码及步数 ```bash --analy-multi-group-integral Purpose: The same function as --analy-multi-group, but all solution case will be output - exp: ./engine --analy-multi-group-integral 5-4-0.txt farthest.csv solution.csv + eg: ./engine --analy-multi-group-integral 5-4-0.txt farthest.csv solution.csv ``` + all命令:找到所有可能的布局,同时得到其分类情况及群组关系,计算结果会输出到All_Case.txt(所有布局的编码),main.csv(所有布局的编码及其分类),\*-\*-\*.txt(各群组的第一个子布局集合) ```bash --all Purpose: Find all the cases of klotski with detail - exp: ./engine --all + eg: ./engine --all ``` + all-code命令:简化版的all命令,仅输出全部布局的编码 ```bash --all-code Purpose: Find all the code of klotski - exp: ./engine --all-code All_Case.txt + eg: ./engine --all-code All_Case.txt ``` + help命令:显示所有命令的使用方法 ```bash --help Purpose: Display instructions for use - exp: ./engine --help + eg: ./engine --help ``` ## 编译