diff --git a/README.md b/README.md new file mode 100644 index 0000000..aa676cc --- /dev/null +++ b/README.md @@ -0,0 +1,264 @@ +## 基本定义 + +### 华容道布局 + ++ 棋盘大小为4 x 5 + ++ 棋子为2 x 2,2 x 1(1 x 2),1 x 1三种 + ++ 棋子间不能重叠,且至少存在两个空格 + ++ 有且仅有一个2 x 2块,其他类型不限定 + + *(一个合法的华容道布局必须满足以上四点)* + + 合法华容道布局共有29334498种 + + +### 合法布局举例: + +legal_1legal_2legal_3legal_4 + + +### 非法布局举例: + +illegal_1illegal_2illegal_3illegal_4 + + +### 布局间的关系 + ++ 移动原则:棋子只能平行移动,不能进行旋转; + ++ **一步**:某一棋子做任意步移动后的结果; + ++ **子布局**:某一布局通过一步移动可以得到的布局称为子布局; + +​ (相对的,布局A是布局B的子布局,同时必有布局B是布局A的子布局) + ++ **相邻布局**:两布局互为对方子布局时,两者为相邻布局; + +​ (充要条件:布局与其子布局间的关系) + + +### 步的举例 +step_exp_1 + +step_exp_2 + +step_exp_3 + + +### 标准情况 + +标准布局:存在5个2 x 1(或1 x 2),4个1 x 1棋子的合法华容道布局(363480种) + +非标准布局:除标准布局外的全部合法华容道布局(28971018种) + + + +### 编码 + +合法华容道均有编码,长度9位,每一位是单个16进制数(0~9与A~F);同一布局只能有唯一编码,同一编码亦对应唯一布局,即编码与布局一一对应; + +**位置编号** + +address + +2 x 2棋子的左上角在棋盘中的位置编号有12种情况,对应编码分别为:0、1、2、4、5、6、8、9、A(10)、C(12)、D(13)、E(14),将其置于编码第一位;剩余8位十六进制位储存其他棋子信息。 + +其余棋子(空格此时暂时视为棋子)按从左到右,从上到下的顺序排列(取左上角排序) + +它们对应的代号(二进制)如下: + +| 棋子类型 | 代号 | +| ---- | ---- | +| 空格 | 00 | +| 1 x 2 | 01 | +| 2 x 1 | 10 | +| 1 x 1 | 11 | + +十六进制可按位转为二进制,对应关系如下: + +| 十六进制 | 二进制 | 十进制 | +| ---- | ---- | ---- | +| 0 | 0000 | 0 | +| 1 | 0001 | 1 | +| 2 | 0010 | 2 | +| 3 | 0011 | 3 | +| 4 | 0100 | 4 | +| 5 | 0101 | 5 | +| 6 | 0110 | 6 | +| 7 | 0111 | 7 | +| 8 | 1000 | 8 | +| 9 | 1001 | 9 | +| A | 1010 | 10 | +| B | 1011 | 11 | +| C | 1100 | 12 | +| D | 1101 | 13 | +| E | 1110 | 14 | +| F | 1111 | 15 | + +8个十六进制位相当于32个二进制位,由于每个棋子占用2个二进制位,因此最多储存16个棋子信息;将其依次填入,若有空余则补0填;按此操作即可将布局转化为编码,规定编码最后的0可以省略。 + +**编码举例** + +**例1:** + +exp-1A9BF0C00 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
2 x 21234567891011补0
000110101001101111110000110000000000
1A9BF0C00
+因此,布局编码为***1A9BF0C00***,可简写为***1A9BF0C*** + +**例2:** + +exp-4FEA13400 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
2 x 21234567891011补0
010011111110101000010011010000000000
4FEA13400
+因此,布局编码为***4FEA13400***,可简写为***4FEA134*** + +**例3:** + +exp-5DC02F800 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
2 x 212345678910111213补0
010111011100000000101111100000000000
5DC02F800
+因此,布局编码为***5DC02F800***,可简写为***5DC02F8*** \ No newline at end of file diff --git a/images/address.png b/images/address.png new file mode 100644 index 0000000..b80d6f5 Binary files /dev/null and b/images/address.png differ diff --git a/images/code_exp_1.png b/images/code_exp_1.png new file mode 100644 index 0000000..1c740e3 Binary files /dev/null and b/images/code_exp_1.png differ diff --git a/images/code_exp_2.png b/images/code_exp_2.png new file mode 100644 index 0000000..c66ee7c Binary files /dev/null and b/images/code_exp_2.png differ diff --git a/images/code_exp_3.png b/images/code_exp_3.png new file mode 100644 index 0000000..334f97c Binary files /dev/null and b/images/code_exp_3.png differ diff --git a/images/illegal_1.png b/images/illegal_1.png new file mode 100644 index 0000000..6bed17a Binary files /dev/null and b/images/illegal_1.png differ diff --git a/images/illegal_2.png b/images/illegal_2.png new file mode 100644 index 0000000..02d0f3e Binary files /dev/null and b/images/illegal_2.png differ diff --git a/images/illegal_3.png b/images/illegal_3.png new file mode 100644 index 0000000..ad95f3a Binary files /dev/null and b/images/illegal_3.png differ diff --git a/images/illegal_4.png b/images/illegal_4.png new file mode 100644 index 0000000..2b345e3 Binary files /dev/null and b/images/illegal_4.png differ diff --git a/images/legal_1.png b/images/legal_1.png new file mode 100644 index 0000000..8e78a29 Binary files /dev/null and b/images/legal_1.png differ diff --git a/images/legal_2.png b/images/legal_2.png new file mode 100644 index 0000000..907f76f Binary files /dev/null and b/images/legal_2.png differ diff --git a/images/legal_3.png b/images/legal_3.png new file mode 100644 index 0000000..67e2670 Binary files /dev/null and b/images/legal_3.png differ diff --git a/images/legal_4.png b/images/legal_4.png new file mode 100644 index 0000000..184c800 Binary files /dev/null and b/images/legal_4.png differ diff --git a/images/step_exp_1.png b/images/step_exp_1.png new file mode 100644 index 0000000..0877ecb Binary files /dev/null and b/images/step_exp_1.png differ diff --git a/images/step_exp_2.png b/images/step_exp_2.png new file mode 100644 index 0000000..90181aa Binary files /dev/null and b/images/step_exp_2.png differ diff --git a/images/step_exp_3.png b/images/step_exp_3.png new file mode 100644 index 0000000..a456c22 Binary files /dev/null and b/images/step_exp_3.png differ