From 39570535ee9fc74b929349551e458686b413348c Mon Sep 17 00:00:00 2001 From: Dnomd343 Date: Wed, 18 Jan 2023 14:22:43 +0800 Subject: [PATCH] update: compile structure --- src/CMakeLists.txt | 23 +++++++++++------------ src/common_code/CMakeLists.txt | 2 +- src/utils/CMakeLists.txt | 1 - src/utils/common.cc | 3 ++- src/utils/common.h | 24 +++++++++++------------- 5 files changed, 25 insertions(+), 28 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 9e4f157..a1b014f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,8 +1,7 @@ cmake_minimum_required(VERSION 3.0) -################################ +################################################ -include_directories(core) include_directories(utils) include_directories(all_cases) @@ -10,12 +9,12 @@ include_directories(raw_code) include_directories(short_code) include_directories(common_code) -include_directories(fast_cal) +include_directories(core) include_directories(analyse) +include_directories(fast_cal) -################################ +################################################ -add_subdirectory(core) add_subdirectory(utils) add_subdirectory(all_cases) @@ -23,17 +22,16 @@ add_subdirectory(raw_code) add_subdirectory(short_code) add_subdirectory(common_code) -add_subdirectory(fast_cal) +add_subdirectory(core) add_subdirectory(analyse) +add_subdirectory(fast_cal) -################################ +################################################ add_executable(klotski main.cc) -#add_executable(klotski main.cc basic_ranges_demo.cc) -################################ +################################################ -target_link_libraries(klotski core) target_link_libraries(klotski utils) target_link_libraries(klotski all_cases) @@ -41,9 +39,10 @@ target_link_libraries(klotski raw_code) target_link_libraries(klotski short_code) target_link_libraries(klotski common_code) -target_link_libraries(klotski fast_cal) +target_link_libraries(klotski core) target_link_libraries(klotski analyse) +target_link_libraries(klotski fast_cal) target_link_libraries(klotski pthread) -################################ +################################################ diff --git a/src/common_code/CMakeLists.txt b/src/common_code/CMakeLists.txt index 0d4ebd2..f4e40fd 100644 --- a/src/common_code/CMakeLists.txt +++ b/src/common_code/CMakeLists.txt @@ -1,4 +1,4 @@ cmake_minimum_required(VERSION 3.0) add_library(common_code convert.cc serialize.cc common_code.cc) -target_link_libraries(common_code utils raw_code) +target_link_libraries(common_code utils) diff --git a/src/utils/CMakeLists.txt b/src/utils/CMakeLists.txt index c3481e7..8686549 100644 --- a/src/utils/CMakeLists.txt +++ b/src/utils/CMakeLists.txt @@ -1,4 +1,3 @@ cmake_minimum_required(VERSION 3.0) add_library(utils common.cc) -target_link_libraries(utils short_code) diff --git a/src/utils/common.cc b/src/utils/common.cc index 1886b76..25f780f 100644 --- a/src/utils/common.cc +++ b/src/utils/common.cc @@ -21,7 +21,8 @@ uint8_t Common::check_range(uint32_t head, uint32_t range) { // check generated int block_offset = 1; uint32_t cache = M_2x2 << head; // fill 2x2 block for (int addr = 0; range; range >>= 2, ++block_offset) { // traverse every 2-bits - while (cache >> addr & 0b1) { + // TODO: will addr >= 32 in some special cases? + while ((cache >> addr) & 0b1) { ++addr; // search next unfilled block } switch (range & 0b11) { diff --git a/src/utils/common.h b/src/utils/common.h index da713c2..ec038bc 100644 --- a/src/utils/common.h +++ b/src/utils/common.h @@ -2,6 +2,7 @@ #include +/// 0b101 and 0b110 reserved #define B_space 0b000 #define B_fill 0b111 #define B_1x2 0b001 @@ -9,13 +10,18 @@ #define B_1x1 0b011 #define B_2x2 0b100 +/// C_1x1 | C_1x2 | C_2x1 | C_2x2 +/// 011 000 000 000 | 001 111 000 000 | 010 000 000 000 | 100 111 000 000 +/// 000 000 000 000 | 000 000 000 000 | 111 000 000 000 | 111 111 000 000 +/// ... | ... | ... | ... + #define C_1x1 (uint64_t)0x3 // 011 #define C_1x2 (uint64_t)0x39 // 111 001 #define C_2x1 (uint64_t)0x7002 // 111 000 000 000 010 #define C_2x2 (uint64_t)0x3F03C // 111 111 000 000 111 100 -/// C_1x1 | C_1x2 | C_2x1 | C_2x2 -/// 011 000 000 000 | 001 111 000 000 | 010 000 000 000 | 100 111 000 000 +/// F_1x1 | F_1x2 | F_2x1 | F_2x2 +/// 111 000 000 000 | 111 111 000 000 | 111 000 000 000 | 111 111 000 000 /// 000 000 000 000 | 000 000 000 000 | 111 000 000 000 | 111 111 000 000 /// ... | ... | ... | ... @@ -24,9 +30,9 @@ #define F_2x1 (uint64_t)0x7007 // 111 000 000 000 111 #define F_2x2 (uint64_t)0x3F03F // 111 111 000 000 111 111 -/// F_1x1 | F_1x2 | F_2x1 | F_2x2 -/// 111 000 000 000 | 111 111 000 000 | 111 000 000 000 | 111 111 000 000 -/// 000 000 000 000 | 000 000 000 000 | 111 000 000 000 | 111 111 000 000 +/// F_1x1_R | F_1x1_D | F_2x1_R | F_1x2_D +/// 000 111 000 000 | 000 000 000 000 | 000 111 000 000 | 000 000 000 000 +/// 000 000 000 000 | 111 000 000 000 | 000 111 000 000 | 111 111 000 000 /// ... | ... | ... | ... #define F_1x1_R (uint64_t)0x38 // 111 000 @@ -34,16 +40,8 @@ #define F_2x1_R (uint64_t)0x38038 // 111 000 000 000 111 000 #define F_1x2_D (uint64_t)0x3F000 // 111 111 000 000 000 000 -/// F_1x1_R | F_1x1_D | F_2x1_R | F_1x2_D -/// 000 111 000 000 | 000 000 000 000 | 000 111 000 000 | 000 000 000 000 -/// 000 000 000 000 | 111 000 000 000 | 000 111 000 000 | 111 111 000 000 -/// ... | ... | ... | ... - class Common { public: static uint32_t range_reverse(uint32_t bin); -// static bool check_case(uint32_t head, uint32_t range); - - // TODO: with broken block offset return static uint8_t check_range(uint32_t head, uint32_t range); };