Browse Source

update: compile structure

master
Dnomd343 2 years ago
parent
commit
39570535ee
  1. 23
      src/CMakeLists.txt
  2. 2
      src/common_code/CMakeLists.txt
  3. 1
      src/utils/CMakeLists.txt
  4. 3
      src/utils/common.cc
  5. 24
      src/utils/common.h

23
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)
################################
################################################

2
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)

1
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)

3
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) {

24
src/utils/common.h

@ -2,6 +2,7 @@
#include <cstdint>
/// 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);
};

Loading…
Cancel
Save