From 1cb6e58ee4bfd31939175bf67c613b33c30d5c0f Mon Sep 17 00:00:00 2001 From: Dnomd343 Date: Sun, 14 Jul 2024 12:34:25 +0800 Subject: [PATCH] docs: update AllCases description --- src/core/all_cases/all_cases.h | 18 ++++++++++-------- src/core/all_cases/internal/constant.inl | 8 +++++--- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/core/all_cases/all_cases.h b/src/core/all_cases/all_cases.h index 8164546..8f5e15c 100644 --- a/src/core/all_cases/all_cases.h +++ b/src/core/all_cases/all_cases.h @@ -8,17 +8,19 @@ /// As we all know, a space or 1x1 block will occupy 1 slot, 1x2 and 2x1 block /// will occupy 2 slots, and together they fill 16 positions, so all possible -/// combinations can be calculated, this number is 204, each combination can -/// produce different permutations. After mathematical calculations, there are -/// a total of 7311921 possible permutations. The goal of BasicRanges is to -/// find these permutations, sort them and store in a uint32_t array. +/// combinations can be calculated, the number is 204. Since there are no cases +/// with seven 2x1 blocks, we need to remove one combination, which leaves 203 +/// situations. Therefore, each combination can produce different permutations, +/// after mathematical calculations, there are a total of `7311885` possible +/// permutations. The goal of BasicRanges is to find these permutations, sort +/// them and store in a uint32_t array. /// AllCases is used to generate all valid CommonCodes, its works based on all /// permutations generated by BasicRanges, which will use different 2x2 block /// positions to check respectively. On the 5x4 chessboard, it has 12 possible /// positions, and the numbers are distributed in 0 ~ 15, witch called `head`. -/// For the convenience of calculation, here use an array of length 16 for -/// storage, of course, the position of 3/7/11/15 will be empty. +/// For the convenience of calculation, here we use an array of length 16 for +/// storage, note that the position of 3/7/11/15 will be empty. /// 00 01 02 03 /// 04 05 06 07 00 01 02 @@ -27,8 +29,8 @@ /// 16 17 18 19 12 13 14 /// After all the work is done, we will have 29334498 cases, distributed in 16 -/// arrays. Each of them is a uint32_t array storing the ranges, this is to -/// save memory, otherwise the 64-bit length must be consumed. +/// arrays. Each of them is a uint32_t array storing the ranges, which can be +/// used to save memory, otherwise the 64-bit length must be consumed. /// By the way, due to the performance considerations of the checking process, /// the resulting data of BasicRanges will be flipped every 2-bit, which will diff --git a/src/core/all_cases/internal/constant.inl b/src/core/all_cases/internal/constant.inl index 3847fec..e9bd570 100644 --- a/src/core/all_cases/internal/constant.inl +++ b/src/core/all_cases/internal/constant.inl @@ -4,8 +4,9 @@ namespace klotski::cases { -// ------------------------------------------------------------------------------------- // +// ----------------------------------------------------------------------------------------- // +/// Number of cases corresponding to the head value. constexpr auto ALL_CASES_NUM = std::to_array({ 2942906, 2260392, 2942906, 0, 2322050, 1876945, 2322050, 0, @@ -17,8 +18,9 @@ constexpr auto ALL_CASES_NUM_ = array_sum(ALL_CASES_NUM); constexpr auto ALL_CASES_OFFSET = to_offset(ALL_CASES_NUM); -// ------------------------------------------------------------------------------------- // +// ----------------------------------------------------------------------------------------- // +/// Number of ranges corresponding to the type_id. constexpr auto BASIC_RANGES_NUM = std::to_array({ 1 , 16 , 120 , 560 , 1820 , 4368 , 8008 , 11440 , 12870 , 11440 , 8008 , 4368 , 1820 , 560 , 120 , 15 , @@ -52,6 +54,6 @@ constexpr auto BASIC_RANGES_NUM_ = array_sum(BASIC_RANGES_NUM); constexpr auto BASIC_RANGES_OFFSET = to_offset(BASIC_RANGES_NUM); -// ------------------------------------------------------------------------------------- // +// ----------------------------------------------------------------------------------------- // } // namespace klotski::cases