Browse Source

docs: using box-drawing characters

legacy
Dnomd343 1 month ago
parent
commit
ca6acd91ce
  1. 50
      src/core/common_code/common_code.h
  2. 36
      src/core/raw_code/raw_code.h
  3. 72
      src/core/short_code/short_code.h

50
src/core/common_code/common_code.h

@ -1,6 +1,6 @@
/// Klotski Engine by Dnomd343 @2024 /// 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` /// 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`, /// block, it is encoded separately. Its upper-left corner is called `head`,
/// which has 12 possible positions and is encoded using 4-bit length. /// 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, /// 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, /// 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 /// which are `00` `01` `10` `11`. Arrange them in ascending order according to
/// size, and we can get a binary sequence. /// the position numbers corresponding to their upper left corners, and we will
/// /// get a binary sequence.
/// -------------------------------------------------------- /// ┌────────────┬──────────┬────────────┬──────────┐
/// | 2x2 -> # # | 2x1 -> # | 1x2 -> # # | 1x1 -> # | /// │ (2x2) ████ │ (2x1) ██ │ (1x2) ████ │ (1x1) ██ │
/// | # # | # | | | /// │ ████ │ ██ │ │ │
/// -------------------------------------------------------- /// └────────────┴──────────┴────────────┴──────────┘
/// This sequence can have up to 16 blocks, aka 32-bit in length. Therefore, in /// This sequence can have up to 16 blocks, aka 32-bit. Therefore, in order to
/// order to be compatible with all klotski cases, the length of this part of /// be compatible with all klotski cases, the length of this part is set to
/// the code is set to 32-bit. In addition, for the convenience of reading, it /// 32-bit. In addition, for the convenience of reading, it is stipulated that
/// is stipulated that the sequence starts from the high bit, and the remaining /// the sequence starts from the high bit, and the remaining bits should be
/// bits should be filled with `0`. /// filled with `0`.
/// Putting the content of the `head` in the upper 4-bit, and the lower 32-bit /// 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 /// to store the sequence content, a 36-bit length code can be obtained, which
@ -38,21 +38,23 @@
/// ----------------------------------------------------------------------------------- /// /// ----------------------------------------------------------------------------------- ///
/// Eg1: /// /// Eg1: ///
/// % # # % 2x2 -> head = 1 /// /// ┏━┳━━━┳━┓ ///
/// % # # % 2x1 2x1 2x1 1x2 2x1 1x1 1x1 1x1 space space 1x1 ... ... ... ... ... /// /// ┃ ┃ ┃ ┃ 2x2 -> head = 1 ///
/// @ $ $ @ 10 10 10 01 10 11 11 11 00 00 11 00 00 00 00 00 /// /// ┣━╋━━━╋━┫ 2x1 2x1 2x1 1x2 2x1 1x1 1x1 1x1 space space 1x1 ... ... ... ... ... ///
/// @ & * @ 1010 1001 1011 1111 0000 1100 0000 0000 /// /// ┃ ┣━┳━┫ ┃ 10 10 10 01 10 11 11 11 00 00 11 00 00 00 00 00 ///
/// * & A 9 B F 0 C 0 0 /// /// ┣━╋━┻━╋━┫ 1010 1001 1011 1111 0000 1100 0000 0000 ///
/// ┗━┛ ┗━┛ A 9 B F 0 C 0 0 ///
/// CommonCode = 0x1A9BF0C00 -> "1A9BF0C" /// /// CommonCode = 0x1A9BF0C00 -> "1A9BF0C" ///
/// ----------------------------------------------------------------------------------- /// /// ----------------------------------------------------------------------------------- ///
/// ----------------------------------------------------------------------------------- /// /// ----------------------------------------------------------------------------------- ///
/// Eg2: /// /// Eg2: ///
/// * @ & % 2x2 -> head = 4 /// /// ┏━┳━┳━┳━┓ ///
/// # # $ % 1x1 1x1 1x1 2x1 2x1 2x1 space 1x2 space 1x1 1x2 ... ... ... ... ... /// /// ┣━┻━╋━┫ ┃ 2x2 -> head = 4 ///
/// # # $ ^ 11 11 11 10 10 10 00 01 00 11 01 00 00 00 00 00 /// /// ┃ ┃ ┣━┫ 1x1 1x1 1x1 2x1 2x1 2x1 space 1x2 space 1x1 1x2 ... ... ... ... ... ///
/// ~ ~ ^ 1111 1110 1010 0001 0011 0100 0000 0000 /// /// ┗━┳━┻━┫ ┃ 11 11 11 10 10 10 00 01 00 11 01 00 00 00 00 00 ///
/// @ % % F E A 1 3 4 0 0 /// /// ┣━┳━┻━┫ 1111 1110 1010 0001 0011 0100 0000 0000 ///
/// ┗━┻━━━┛ F E A 1 3 4 0 0 ///
/// CommonCode = 0x4FEA13400 -> "4FEA134" /// /// CommonCode = 0x4FEA13400 -> "4FEA134" ///
/// ----------------------------------------------------------------------------------- /// /// ----------------------------------------------------------------------------------- ///

36
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 /// 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 /// 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 /// `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 /// 00 01 02 03
/// 04 05 06 07 fill 20 slots /// 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 /// 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. /// spaces and fills. The remaining 2 states are reserved for now.
/// ///
/// ------------------------------------ /// ┌──────────────┬───────────────────┐
/// | 000 -> space | 100 -> 2x2 | /// │ 000 -> space │ 100 -> 2x2 │
/// | 001 -> 1x2 | 101 -> [reserved] | /// │ 001 -> 1x2 │ 101 -> [reserved] │
/// | 010 -> 2x1 | 110 -> [reserved] | /// │ 010 -> 2x1 │ 110 -> [reserved] │
/// | 011 -> 1x1 | 111 -> fill | /// │ 011 -> 1x1 │ 111 -> fill │
/// ------------------------------------ /// └──────────────┴───────────────────┘
/// ///
/// Here, space is defined as `000` and fill is defined as `111`, which will /// 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 /// facilitate the execution of bit operations of the movement algorithm. Other
@ -29,11 +29,12 @@
/// -------------------------------------------------------------------------------------------------- /// /// -------------------------------------------------------------------------------------------------- ///
/// Eg1: /// /// Eg1: ///
/// % # # % 2x1 2x2 ... 2x1 010 100 111 010 /// /// ┏━┳━━━┳━┓ ///
/// % # # % ... ... ... ... 111 111 111 111 /// /// ┃ ┃ ┃ ┃ 2x1 2x2 ... 2x1 010 100 111 010 ///
/// @ $ $ @ 2x1 1x2 ... 2x1 010 001 111 010 /// /// ┣━╋━━━╋━┫ ... ... ... ... 111 111 111 111 ///
/// @ & * @ ... 1x1 1x1 ... 111 011 011 111 /// /// ┃ ┣━┳━┫ ┃ 2x1 1x2 ... 2x1 010 001 111 010 ///
/// * & 1x1 0x0 0x0 1x1 011 000 000 011 /// /// ┣━╋━┻━╋━┫ ... 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 /// /// | 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 /// /// 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: /// /// Eg2: ///
/// * @ & % 1x1 1x1 1x1 2x1 011 011 011 010 /// /// ┏━┳━┳━┳━┓ ///
/// # # $ % 2x2 ... 2x1 ... 100 111 010 111 /// /// ┣━┻━╋━┫ ┃ 1x1 1x1 1x1 2x1 011 011 011 010 ///
/// # # $ ^ ... ... ... 2x1 111 111 111 010 /// /// ┃ ┃ ┣━┫ 2x2 ... 2x1 ... 100 111 010 111 ///
/// ~ ~ ^ 0x0 1x2 ... ... 000 001 111 111 /// /// ┗━┳━┻━┫ ┃ ... ... ... 2x1 111 111 111 010 ///
/// @ % % 0x0 1x1 1x2 ... 000 011 001 111 /// /// ┣━┳━┻━┫ 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 /// /// | 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 /// /// 0000 | 111 001 011 000 | 111 111 001 000 | 010 111 111 111 | 111 010 111 100 | 010 011 011 011 ///

72
src/core/short_code/short_code.h

@ -15,7 +15,7 @@
/// Coincidentally, log(32, 29334498) is approximately equal to 4.96, so using /// 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 /// 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 /// 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 /// Compared with the CommonCode, although ShortCode saves space, it completely
/// loses readability. The former can directly get the case without the help of /// loses readability. The former can directly get the case without the help of
@ -24,47 +24,39 @@
/// cases, either verbally or handwritten. /// cases, either verbally or handwritten.
/// ShortCode Convert Table /// /// ShortCode Convert Table ///
/// ------------------------------------------------- /// /// ┌─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┐ ///
/// | 00 | 01 | 02 | 03 | 04 | 05 | 06 | 07 | /// /// │ 00 │ 01 │ 02 │ 03 │ 04 │ 05 │ 06 │ 07 │ ///
/// | `1` | `2` | `3` | `4` | `5` | `6` | `7` | `8` | /// /// │ `1` │ `2` │ `3` │ `4` │ `5` │ `6` │ `7` │ `8` │ ///
/// |-----------------------------------------------| /// /// ├─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤ ///
/// | 08 | 09 | 10 | 11 | 12 | 13 | 14 | 15 | /// /// │ 08 │ 09 │ 10 │ 11 │ 12 │ 13 │ 14 │ 15 │ ///
/// | `9` | `A` | `B` | `C` | `D` | `E` | `F` | `G` | /// /// │ `9` │ `A` │ `B` │ `C` │ `D` │ `E` │ `F` │ `G` │ ///
/// |-----------------------------------------------| /// /// ├─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤ ///
/// | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | /// /// │ 16 │ 17 │ 18 │ 19 │ 20 │ 21 │ 22 │ 23 │ ///
/// | `H` | `J` | `K` | `M` | `N` | `P` | `Q` | `R` | /// /// │ `H` │ `J` │ `K` │ `M` │ `N` │ `P` │ `Q` │ `R` │ ///
/// |-----------------------------------------------| /// /// ├─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤ ///
/// | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | /// /// │ 24 │ 25 │ 26 │ 27 │ 28 │ 29 │ 30 │ 31 │ ///
/// | `S` | `T` | `U` | `V` | `W` | `X` | `Y` | `Z` | /// /// │ `S` │ `T` │ `U` │ `V` │ `W` │ `X` │ `Y` │ `Z` │ ///
/// ------------------------------------------------- /// /// └─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┘ ///
/// ------------------------------------------------------------------------------------------ /// /// ------------------------------------------------------------------------------------------------ ///
/// Eg1: /// /// Eg1: ///
/// % # # % /// /// ┏━┳━━━┳━┓ CommonCode = 0x1A9BF0C00 (index 4091296) ///
/// % # # % /// /// ┃ ┃ ┃ ┃ ShortCode = 4091296 ///
/// @ $ $ @ CommonCode = 0x1A9BF0C00 (index 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" ///
/// 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: /// /// Eg2: ///
/// * @ & % /// /// ┏━┳━┳━┳━┓ CommonCode = 0x4FEA13400 (index 10399732) ///
/// # # $ % /// /// ┣━┻━╋━┫ ┃ ShortCode = 10399732 ///
/// # # $ ^ CommonCode = 0x4FEA13400 (index 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" ///
/// 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 #pragma once

Loading…
Cancel
Save