Browse Source

feat: core next_step demo

master
Dnomd343 2 years ago
parent
commit
d07d715eb9
  1. 3
      src/CMakeLists.txt
  2. 7
      src/common_code/common_code.h
  3. 9
      src/core_demo.cc
  4. 5
      src/core_demo.h
  5. 9
      src/main.cc

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

7
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
};

9
src/core_demo.cc

@ -0,0 +1,9 @@
#include <iostream>
#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);
}

5
src/core_demo.h

@ -0,0 +1,5 @@
#pragma once
#include <cstdint>
void next_step(uint64_t raw_code, uint64_t mask);

9
src/main.cc

@ -5,6 +5,8 @@
#include "short_code.h"
#include "raw_code.h"
#include "core_demo.h"
#include <thread>
//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;
}

Loading…
Cancel
Save