Browse Source

feat: RawCode framework

master
Dnomd343 2 years ago
parent
commit
4683ee3d32
  1. 6
      src/CMakeLists.txt
  2. 13
      src/main.cc
  3. 4
      src/raw_code/CMakeLists.txt
  4. 5
      src/raw_code/raw_code.cc
  5. 19
      src/raw_code/raw_code.h

6
src/CMakeLists.txt

@ -2,16 +2,22 @@ cmake_minimum_required(VERSION 3.0)
include_directories(common)
include_directories(all_cases)
include_directories(raw_code)
include_directories(short_code)
include_directories(common_code)
add_subdirectory(common)
add_subdirectory(all_cases)
add_subdirectory(raw_code)
add_subdirectory(short_code)
add_subdirectory(common_code)
add_executable(klotski main.cc)
target_link_libraries(klotski all_cases)
target_link_libraries(klotski raw_code)
target_link_libraries(klotski short_code)
target_link_libraries(klotski common_code)

13
src/main.cc

@ -3,6 +3,7 @@
#include "basic_ranges.h"
#include "common_code.h"
#include "short_code.h"
#include "raw_code.h"
#include <thread>
@ -119,11 +120,15 @@ int main() {
// std::cout << CommonCode(0x6EC0F8800).to_short_code().to_string() << std::endl;
std::cout << CommonCode(ShortCode(14323231)).to_string() << std::endl;
std::cout << ShortCode(14323231).to_common_code().to_string() << std::endl;
// std::cout << CommonCode(ShortCode(14323231)).to_string() << std::endl;
// std::cout << ShortCode(14323231).to_common_code().to_string() << std::endl;
//
// std::cout << ShortCode(CommonCode(0x6EC0F8800)).to_string() << std::endl;
// std::cout << CommonCode(0x6EC0F8800).to_short_code().to_string() << std::endl;
std::cout << ShortCode(CommonCode(0x6EC0F8800)).to_string() << std::endl;
std::cout << CommonCode(0x6EC0F8800).to_short_code().to_string() << std::endl;
auto r = RawCode(0x0E58FC85FFEBC4DB);
printf("%016lX\n", r.unwrap());
return 0;
}

4
src/raw_code/CMakeLists.txt

@ -0,0 +1,4 @@
cmake_minimum_required(VERSION 3.0)
add_library(raw_code raw_code.cc)
target_link_libraries(raw_code common_code)

5
src/raw_code/raw_code.cc

@ -0,0 +1,5 @@
#include "raw_code.h"
uint64_t RawCode::unwrap() const { // get raw uint64_t code
return code;
}

19
src/raw_code/raw_code.h

@ -0,0 +1,19 @@
#pragma once
#include <cstdint>
#include "common_code.h"
class RawCode {
public:
uint64_t unwrap() const;
std::string dump_case() const;
CommonCode to_common_code() const;
RawCode(const CommonCode &common_code);
explicit RawCode(uint64_t raw_code) : code(raw_code) {}
private:
uint64_t code;
};
Loading…
Cancel
Save