From d07d715eb93882ff2ab3ff582aff687e5a819159 Mon Sep 17 00:00:00 2001 From: Dnomd343 Date: Tue, 10 Jan 2023 10:38:04 +0800 Subject: [PATCH] feat: core next_step demo --- src/CMakeLists.txt | 3 ++- src/common_code/common_code.h | 7 +++++-- src/core_demo.cc | 9 +++++++++ src/core_demo.h | 5 +++++ src/main.cc | 9 +++++++-- 5 files changed, 28 insertions(+), 5 deletions(-) create mode 100644 src/core_demo.cc create mode 100644 src/core_demo.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index d214276..8cd5289 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -14,7 +14,8 @@ add_subdirectory(raw_code) add_subdirectory(short_code) add_subdirectory(common_code) -add_executable(klotski main.cc) +#add_executable(klotski main.cc) +add_executable(klotski main.cc core_demo.cc) target_link_libraries(klotski all_cases) target_link_libraries(klotski raw_code) diff --git a/src/common_code/common_code.h b/src/common_code/common_code.h index 79d66d1..928bb50 100644 --- a/src/common_code/common_code.h +++ b/src/common_code/common_code.h @@ -9,16 +9,19 @@ class ShortCode; class CommonCode { public: uint64_t unwrap() const; - ShortCode to_short_code() const; static bool check(uint64_t common_code); static CommonCode unsafe_create(uint64_t code); + + // TODO: to raw code function + ShortCode to_short_code() const; std::string to_string(bool shorten = false) const; explicit CommonCode(uint64_t common_code); + // TODO: init with const RawCode& explicit CommonCode(const ShortCode &short_code); explicit CommonCode(const std::string &common_code_str); private: uint64_t code; - CommonCode() = default; + CommonCode() = default; // unsafe init }; diff --git a/src/core_demo.cc b/src/core_demo.cc new file mode 100644 index 0000000..069c573 --- /dev/null +++ b/src/core_demo.cc @@ -0,0 +1,9 @@ +#include +#include "raw_code.h" + +void next_step(uint64_t raw_code, uint64_t mask) { + + std::cout << RawCode(raw_code).dump_case(); + printf("mask -> %016lX\n", mask); + +} diff --git a/src/core_demo.h b/src/core_demo.h new file mode 100644 index 0000000..19ded5c --- /dev/null +++ b/src/core_demo.h @@ -0,0 +1,5 @@ +#pragma once + +#include + +void next_step(uint64_t raw_code, uint64_t mask); diff --git a/src/main.cc b/src/main.cc index 9360703..54dd94b 100644 --- a/src/main.cc +++ b/src/main.cc @@ -5,6 +5,8 @@ #include "short_code.h" #include "raw_code.h" +#include "core_demo.h" + #include //void get_status() { @@ -134,8 +136,11 @@ int main() { // printf("%015lX\n", RawCode(CommonCode(0x4FEA13400)).unwrap()); // auto r = RawCode(0x0E58FC85FFEBC4DB); - auto r = RawCode(0x0E58FC85FFEBC4DD); - std::cout << r.dump_case() << std::endl; +// auto r = RawCode(0x0E58FC85FFEBC4DD); // invalid raw code -> only for test +// std::cout << r.dump_case() << std::endl; + + + next_step(0x0E58FC85FFEBC4DB, 0); // mask unset return 0; }