diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a3509c1..a22a93c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 3.0) include_directories(core) -include_directories(common) +include_directories(utils) include_directories(all_cases) include_directories(raw_code) @@ -9,7 +9,7 @@ include_directories(short_code) include_directories(common_code) add_subdirectory(core) -add_subdirectory(common) +add_subdirectory(utils) add_subdirectory(all_cases) add_subdirectory(raw_code) @@ -20,7 +20,7 @@ add_subdirectory(common_code) add_executable(klotski main.cc fast_cal.cc) target_link_libraries(klotski core) -target_link_libraries(klotski common) +target_link_libraries(klotski utils) target_link_libraries(klotski all_cases) target_link_libraries(klotski raw_code) diff --git a/src/all_cases/CMakeLists.txt b/src/all_cases/CMakeLists.txt index cfcce31..29a672f 100644 --- a/src/all_cases/CMakeLists.txt +++ b/src/all_cases/CMakeLists.txt @@ -1,4 +1,4 @@ cmake_minimum_required(VERSION 3.0) -add_library(all_cases basic_ranges.cc all_cases.cc) -target_link_libraries(all_cases common) +add_library(all_cases all_cases.cc basic_ranges.cc) +target_link_libraries(all_cases utils) diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt deleted file mode 100644 index 73c0316..0000000 --- a/src/common/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 3.0) - -add_library(common common.cc) -target_link_libraries(common short_code) diff --git a/src/common/common.h b/src/common/common.h deleted file mode 100644 index 8c80a6c..0000000 --- a/src/common/common.h +++ /dev/null @@ -1,9 +0,0 @@ -#pragma once - -#include - -class Common { -public: - static uint32_t range_reverse(uint32_t bin); - static bool check_case(uint32_t head, uint32_t range); -}; diff --git a/src/common_code/CMakeLists.txt b/src/common_code/CMakeLists.txt index 5b861e0..7b6d129 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 common_code.cc) -target_link_libraries(common_code common) +target_link_libraries(common_code utils) diff --git a/src/core/core.cc b/src/core/core.cc index 00d12fb..a10859f 100644 --- a/src/core/core.cc +++ b/src/core/core.cc @@ -1,5 +1,5 @@ #include "core.h" -#include "raw_code.h" +#include "common.h" #define ALLOW_UP (filter != -UP) #define ALLOW_DOWN (filter != -DOWN) diff --git a/src/core/core.h b/src/core/core.h index 4272cc9..c55de41 100644 --- a/src/core/core.h +++ b/src/core/core.h @@ -7,16 +7,6 @@ #define DOWN (+12) // +4 * 3-bits #define RIGHT (+3) // +1 * 3-bits -#define F_1x1 (uint64_t)0x7 // 111 -#define F_1x2 (uint64_t)0x3F // 111 111 -#define F_2x1 (uint64_t)0x7007 // 111 000 000 000 111 -#define F_2x2 (uint64_t)0x3F03F // 111 111 000 000 111 111 - -#define F_1x1_R (uint64_t)0x38 // 111 000 -#define F_1x1_D (uint64_t)0x7000 // 111 000 000 000 000 -#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 - class Core { public: void next_step(uint64_t code, uint64_t mask); diff --git a/src/fast_cal.cc b/src/fast_cal.cc index df5b749..0066462 100644 --- a/src/fast_cal.cc +++ b/src/fast_cal.cc @@ -4,6 +4,7 @@ #include "core.h" #include "fast_cal.h" #include "raw_code.h" +#include "common.h" struct fast_cal_t { uint64_t code; diff --git a/src/raw_code/CMakeLists.txt b/src/raw_code/CMakeLists.txt index 72c5f65..e7863a0 100644 --- a/src/raw_code/CMakeLists.txt +++ b/src/raw_code/CMakeLists.txt @@ -1,4 +1,4 @@ cmake_minimum_required(VERSION 3.0) add_library(raw_code raw_code.cc) -target_link_libraries(raw_code common common_code) +target_link_libraries(raw_code utils common_code) diff --git a/src/raw_code/raw_code.h b/src/raw_code/raw_code.h index eec1f47..b83e469 100644 --- a/src/raw_code/raw_code.h +++ b/src/raw_code/raw_code.h @@ -3,18 +3,6 @@ #include #include "common_code.h" -#define B_space 0b000 -#define B_fill 0b111 -#define B_1x2 0b001 -#define B_2x1 0b010 -#define B_1x1 0b011 -#define B_2x2 0b100 - -#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 - class CommonCode; class RawCode { diff --git a/src/short_code/CMakeLists.txt b/src/short_code/CMakeLists.txt index 4ff6086..ae2dfcc 100644 --- a/src/short_code/CMakeLists.txt +++ b/src/short_code/CMakeLists.txt @@ -1,4 +1,4 @@ cmake_minimum_required(VERSION 3.0) add_library(short_code convert.cc short_code.cc data_loader.cc) -target_link_libraries(short_code common all_cases) +target_link_libraries(short_code utils all_cases) diff --git a/src/utils/CMakeLists.txt b/src/utils/CMakeLists.txt new file mode 100644 index 0000000..c3481e7 --- /dev/null +++ b/src/utils/CMakeLists.txt @@ -0,0 +1,4 @@ +cmake_minimum_required(VERSION 3.0) + +add_library(utils common.cc) +target_link_libraries(utils short_code) diff --git a/src/common/common.cc b/src/utils/common.cc similarity index 100% rename from src/common/common.cc rename to src/utils/common.cc diff --git a/src/utils/common.h b/src/utils/common.h new file mode 100644 index 0000000..e90ed90 --- /dev/null +++ b/src/utils/common.h @@ -0,0 +1,31 @@ +#pragma once + +#include + +#define B_space 0b000 +#define B_fill 0b111 +#define B_1x2 0b001 +#define B_2x1 0b010 +#define B_1x1 0b011 +#define B_2x2 0b100 + +#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 + +#define F_1x1 (uint64_t)0x7 // 111 +#define F_1x2 (uint64_t)0x3F // 111 111 +#define F_2x1 (uint64_t)0x7007 // 111 000 000 000 111 +#define F_2x2 (uint64_t)0x3F03F // 111 111 000 000 111 111 + +#define F_1x1_R (uint64_t)0x38 // 111 000 +#define F_1x1_D (uint64_t)0x7000 // 111 000 000 000 000 +#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 + +class Common { +public: + static uint32_t range_reverse(uint32_t bin); + static bool check_case(uint32_t head, uint32_t range); +};