From ca6acd91cecc996af13c807ab073f66cc314cfd3 Mon Sep 17 00:00:00 2001 From: Dnomd343 Date: Sun, 24 Nov 2024 11:28:34 +0800 Subject: [PATCH] docs: using box-drawing characters --- src/core/common_code/common_code.h | 50 ++++++++++---------- src/core/raw_code/raw_code.h | 36 +++++++------- src/core/short_code/short_code.h | 76 +++++++++++++----------------- 3 files changed, 79 insertions(+), 83 deletions(-) diff --git a/src/core/common_code/common_code.h b/src/core/common_code/common_code.h index d089f2e..26a2dc1 100644 --- a/src/core/common_code/common_code.h +++ b/src/core/common_code/common_code.h @@ -1,6 +1,6 @@ /// Klotski Engine by Dnomd343 @2024 -/// CommonCode is a generic klotski encoding that records an valid case using +/// CommonCode is a generic klotski encoding that records a valid case using /// 36-bit lengths, and stored in a `uint64_t`. Since there is only one `2x2` /// block, it is encoded separately. Its upper-left corner is called `head`, /// which has 12 possible positions and is encoded using 4-bit length. @@ -13,19 +13,19 @@ /// Treat spaces as special blocks, there can be four kinds of blocks in total, /// namely `space`, `1x2`, `2x1`, `1x1`. Each of them is represented by 2-bit, -/// which are `00` `01` `10` `11`. Arrange them according to their position and -/// size, and we can get a binary sequence. -/// -/// -------------------------------------------------------- -/// | 2x2 -> # # | 2x1 -> # | 1x2 -> # # | 1x1 -> # | -/// | # # | # | | | -/// -------------------------------------------------------- - -/// This sequence can have up to 16 blocks, aka 32-bit in length. Therefore, in -/// order to be compatible with all klotski cases, the length of this part of -/// the code is set to 32-bit. In addition, for the convenience of reading, it -/// is stipulated that the sequence starts from the high bit, and the remaining -/// bits should be filled with `0`. +/// which are `00` `01` `10` `11`. Arrange them in ascending order according to +/// the position numbers corresponding to their upper left corners, and we will +/// get a binary sequence. +/// ┌────────────┬──────────┬────────────┬──────────┐ +/// │ (2x2) ████ │ (2x1) ██ │ (1x2) ████ │ (1x1) ██ │ +/// │ ████ │ ██ │ │ │ +/// └────────────┴──────────┴────────────┴──────────┘ + +/// This sequence can have up to 16 blocks, aka 32-bit. Therefore, in order to +/// be compatible with all klotski cases, the length of this part is set to +/// 32-bit. In addition, for the convenience of reading, it is stipulated that +/// the sequence starts from the high bit, and the remaining bits should be +/// filled with `0`. /// Putting the content of the `head` in the upper 4-bit, and the lower 32-bit /// to store the sequence content, a 36-bit length code can be obtained, which @@ -38,21 +38,23 @@ /// ----------------------------------------------------------------------------------- /// /// Eg1: /// -/// % # # % 2x2 -> head = 1 /// -/// % # # % 2x1 2x1 2x1 1x2 2x1 1x1 1x1 1x1 space space 1x1 ... ... ... ... ... /// -/// @ $ $ @ 10 10 10 01 10 11 11 11 00 00 11 00 00 00 00 00 /// -/// @ & * @ 1010 1001 1011 1111 0000 1100 0000 0000 /// -/// * & A 9 B F 0 C 0 0 /// +/// ┏━┳━━━┳━┓ /// +/// ┃ ┃ ┃ ┃ 2x2 -> head = 1 /// +/// ┣━╋━━━╋━┫ 2x1 2x1 2x1 1x2 2x1 1x1 1x1 1x1 space space 1x1 ... ... ... ... ... /// +/// ┃ ┣━┳━┫ ┃ 10 10 10 01 10 11 11 11 00 00 11 00 00 00 00 00 /// +/// ┣━╋━┻━╋━┫ 1010 1001 1011 1111 0000 1100 0000 0000 /// +/// ┗━┛ ┗━┛ A 9 B F 0 C 0 0 /// /// CommonCode = 0x1A9BF0C00 -> "1A9BF0C" /// /// ----------------------------------------------------------------------------------- /// /// ----------------------------------------------------------------------------------- /// /// Eg2: /// -/// * @ & % 2x2 -> head = 4 /// -/// # # $ % 1x1 1x1 1x1 2x1 2x1 2x1 space 1x2 space 1x1 1x2 ... ... ... ... ... /// -/// # # $ ^ 11 11 11 10 10 10 00 01 00 11 01 00 00 00 00 00 /// -/// ~ ~ ^ 1111 1110 1010 0001 0011 0100 0000 0000 /// -/// @ % % F E A 1 3 4 0 0 /// +/// ┏━┳━┳━┳━┓ /// +/// ┣━┻━╋━┫ ┃ 2x2 -> head = 4 /// +/// ┃ ┃ ┣━┫ 1x1 1x1 1x1 2x1 2x1 2x1 space 1x2 space 1x1 1x2 ... ... ... ... ... /// +/// ┗━┳━┻━┫ ┃ 11 11 11 10 10 10 00 01 00 11 01 00 00 00 00 00 /// +/// ┣━┳━┻━┫ 1111 1110 1010 0001 0011 0100 0000 0000 /// +/// ┗━┻━━━┛ F E A 1 3 4 0 0 /// /// CommonCode = 0x4FEA13400 -> "4FEA134" /// /// ----------------------------------------------------------------------------------- /// diff --git a/src/core/raw_code/raw_code.h b/src/core/raw_code/raw_code.h index 7f5cd7b..bf51ceb 100644 --- a/src/core/raw_code/raw_code.h +++ b/src/core/raw_code/raw_code.h @@ -4,7 +4,7 @@ /// calculation. It encodes the `5x4` chessboard as 0 ~ 19, and using 3-bit to /// represent each position, occupying a total of 60-bit, and store them in a /// `uint64_t` variable. In addition, the upper 4-bit of RawCode are reserved -/// and must filled with `0`. +/// and must be filled with `0`. /// /// 00 01 02 03 /// 04 05 06 07 fill 20 slots @@ -16,12 +16,12 @@ /// four blocks corresponds to 4 of them, and 2 more states are needed to mark /// spaces and fills. The remaining 2 states are reserved for now. /// -/// ------------------------------------ -/// | 000 -> space | 100 -> 2x2 | -/// | 001 -> 1x2 | 101 -> [reserved] | -/// | 010 -> 2x1 | 110 -> [reserved] | -/// | 011 -> 1x1 | 111 -> fill | -/// ------------------------------------ +/// ┌──────────────┬───────────────────┐ +/// │ 000 -> space │ 100 -> 2x2 │ +/// │ 001 -> 1x2 │ 101 -> [reserved] │ +/// │ 010 -> 2x1 │ 110 -> [reserved] │ +/// │ 011 -> 1x1 │ 111 -> fill │ +/// └──────────────┴───────────────────┘ /// /// Here, space is defined as `000` and fill is defined as `111`, which will /// facilitate the execution of bit operations of the movement algorithm. Other @@ -29,11 +29,12 @@ /// -------------------------------------------------------------------------------------------------- /// /// Eg1: /// -/// % # # % 2x1 2x2 ... 2x1 010 100 111 010 /// -/// % # # % ... ... ... ... 111 111 111 111 /// -/// @ $ $ @ 2x1 1x2 ... 2x1 010 001 111 010 /// -/// @ & * @ ... 1x1 1x1 ... 111 011 011 111 /// -/// * & 1x1 0x0 0x0 1x1 011 000 000 011 /// +/// ┏━┳━━━┳━┓ /// +/// ┃ ┃ ┃ ┃ 2x1 2x2 ... 2x1 010 100 111 010 /// +/// ┣━╋━━━╋━┫ ... ... ... ... 111 111 111 111 /// +/// ┃ ┣━┳━┫ ┃ 2x1 1x2 ... 2x1 010 001 111 010 /// +/// ┣━╋━┻━╋━┫ ... 1x1 1x1 ... 111 011 011 111 /// +/// ┗━┛ ┗━┛ 1x1 0x0 0x0 1x1 011 000 000 011 /// /// /// /// | 19 18 17 16 | 15 14 13 12 | 11 10 09 08 | 07 06 05 04 | 03 02 01 00 /// /// 0000 | 011 000 000 011 | 111 011 011 111 | 010 111 001 010 | 111 111 111 111 | 010 111 100 010 /// @@ -45,11 +46,12 @@ /// -------------------------------------------------------------------------------------------------- /// /// Eg2: /// -/// * @ & % 1x1 1x1 1x1 2x1 011 011 011 010 /// -/// # # $ % 2x2 ... 2x1 ... 100 111 010 111 /// -/// # # $ ^ ... ... ... 2x1 111 111 111 010 /// -/// ~ ~ ^ 0x0 1x2 ... ... 000 001 111 111 /// -/// @ % % 0x0 1x1 1x2 ... 000 011 001 111 /// +/// ┏━┳━┳━┳━┓ /// +/// ┣━┻━╋━┫ ┃ 1x1 1x1 1x1 2x1 011 011 011 010 /// +/// ┃ ┃ ┣━┫ 2x2 ... 2x1 ... 100 111 010 111 /// +/// ┗━┳━┻━┫ ┃ ... ... ... 2x1 111 111 111 010 /// +/// ┣━┳━┻━┫ 0x0 1x2 ... ... 000 001 111 111 /// +/// ┗━┻━━━┛ 0x0 1x1 1x2 ... 000 011 001 111 /// /// /// /// | 19 18 17 16 | 15 14 13 12 | 11 10 09 08 | 07 06 05 04 | 03 02 01 00 /// /// 0000 | 111 001 011 000 | 111 111 001 000 | 010 111 111 111 | 111 010 111 100 | 010 011 011 011 /// diff --git a/src/core/short_code/short_code.h b/src/core/short_code/short_code.h index 5b226f5..61965fa 100644 --- a/src/core/short_code/short_code.h +++ b/src/core/short_code/short_code.h @@ -15,7 +15,7 @@ /// Coincidentally, log(32, 29334498) is approximately equal to 4.96, so using /// 5-bit base32 can make good use of space, so any valid klotski cases can be /// represented by a 5-bit length code. As in CommonCode, the characters here -/// are case insensitive, but uppercase is still recommended. +/// are case-insensitive, but uppercase is still recommended. /// Compared with the CommonCode, although ShortCode saves space, it completely /// loses readability. The former can directly get the case without the help of @@ -24,47 +24,39 @@ /// cases, either verbally or handwritten. /// ShortCode Convert Table /// -/// ------------------------------------------------- /// -/// | 00 | 01 | 02 | 03 | 04 | 05 | 06 | 07 | /// -/// | `1` | `2` | `3` | `4` | `5` | `6` | `7` | `8` | /// -/// |-----------------------------------------------| /// -/// | 08 | 09 | 10 | 11 | 12 | 13 | 14 | 15 | /// -/// | `9` | `A` | `B` | `C` | `D` | `E` | `F` | `G` | /// -/// |-----------------------------------------------| /// -/// | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | /// -/// | `H` | `J` | `K` | `M` | `N` | `P` | `Q` | `R` | /// -/// |-----------------------------------------------| /// -/// | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | /// -/// | `S` | `T` | `U` | `V` | `W` | `X` | `Y` | `Z` | /// -/// ------------------------------------------------- /// - -/// ------------------------------------------------------------------------------------------ /// -/// Eg1: /// -/// % # # % /// -/// % # # % /// -/// @ $ $ @ CommonCode = 0x1A9BF0C00 (index 4091296) /// -/// @ & * @ /// -/// * & /// -/// /// -/// 4091296 => 3 * (32 ^ 4) + 28 * (32 ^ 3) + 27 * (32 ^ 2) + 13 * (32 ^ 1) + 0 * (32 ^ 0) /// -/// => (3), (28), (27), (13), (0) /// -/// => `4`, `W`, `V`, `E`, `1` /// -/// => "4WVE1" /// -/// ------------------------------------------------------------------------------------------ /// - -/// -------------------------------------------------------------------------------------------- /// -/// Eg2: /// -/// * @ & % /// -/// # # $ % /// -/// # # $ ^ CommonCode = 0x4FEA13400 (index 10399732) /// -/// ~ ~ ^ /// -/// @ % % /// -/// /// -/// 10399732 => 9 * (32 ^ 4) + 29 * (32 ^ 3) + 11 * (32 ^ 2) + 31 * (32 ^ 1) + 20 * (32 ^ 0) /// -/// => (9), (29), (11), (31), (20) /// -/// => `A`, `X`, `C`, `Z`, `N` /// -/// => "AXCZN" /// -/// -------------------------------------------------------------------------------------------- /// +/// ┌─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┐ /// +/// │ 00 │ 01 │ 02 │ 03 │ 04 │ 05 │ 06 │ 07 │ /// +/// │ `1` │ `2` │ `3` │ `4` │ `5` │ `6` │ `7` │ `8` │ /// +/// ├─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤ /// +/// │ 08 │ 09 │ 10 │ 11 │ 12 │ 13 │ 14 │ 15 │ /// +/// │ `9` │ `A` │ `B` │ `C` │ `D` │ `E` │ `F` │ `G` │ /// +/// ├─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤ /// +/// │ 16 │ 17 │ 18 │ 19 │ 20 │ 21 │ 22 │ 23 │ /// +/// │ `H` │ `J` │ `K` │ `M` │ `N` │ `P` │ `Q` │ `R` │ /// +/// ├─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤ /// +/// │ 24 │ 25 │ 26 │ 27 │ 28 │ 29 │ 30 │ 31 │ /// +/// │ `S` │ `T` │ `U` │ `V` │ `W` │ `X` │ `Y` │ `Z` │ /// +/// └─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┘ /// + +/// ------------------------------------------------------------------------------------------------ /// +/// Eg1: /// +/// ┏━┳━━━┳━┓ CommonCode = 0x1A9BF0C00 (index 4091296) /// +/// ┃ ┃ ┃ ┃ ShortCode = 4091296 /// +/// ┣━╋━━━╋━┫ => 3 * (32 ^ 4) + 28 * (32 ^ 3) + 27 * (32 ^ 2) + 13 * (32 ^ 1) + 0 * (32 ^ 0) /// +/// ┃ ┣━┳━┫ ┃ => (3), (28), (27), (13), (0) /// +/// ┣━╋━┻━╋━┫ => `4`, `W`, `V`, `E`, `1` /// +/// ┗━┛ ┗━┛ => "4WVE1" /// +/// ------------------------------------------------------------------------------------------------ /// + +/// ------------------------------------------------------------------------------------------------- /// +/// Eg2: /// +/// ┏━┳━┳━┳━┓ CommonCode = 0x4FEA13400 (index 10399732) /// +/// ┣━┻━╋━┫ ┃ ShortCode = 10399732 /// +/// ┃ ┃ ┣━┫ => 9 * (32 ^ 4) + 29 * (32 ^ 3) + 11 * (32 ^ 2) + 31 * (32 ^ 1) + 20 * (32 ^ 0) /// +/// ┗━┳━┻━┫ ┃ => (9), (29), (11), (31), (20) /// +/// ┣━┳━┻━┫ => `A`, `X`, `C`, `Z`, `N` /// +/// ┗━┻━━━┛ => "AXCZN" /// +/// ------------------------------------------------------------------------------------------------- /// #pragma once