From 12c8d90c775c9bcd1cebfc7df91b2c6179a889a6 Mon Sep 17 00:00:00 2001 From: Dnomd343 Date: Sun, 22 Jan 2023 14:10:23 +0800 Subject: [PATCH] update: build resolve in Analyse --- src/analyse/analyse.cc | 7 +++++++ src/analyse/analyse.h | 7 +++++++ src/main.cc | 19 ++++++++++++------- 3 files changed, 26 insertions(+), 7 deletions(-) diff --git a/src/analyse/analyse.cc b/src/analyse/analyse.cc index 2dbbb68..a6cf559 100644 --- a/src/analyse/analyse.cc +++ b/src/analyse/analyse.cc @@ -1,4 +1,5 @@ #include "analyse.h" +#include "common.h" Analyse::Analyse(const RawCode &code) { this->root = (uint64_t)code; @@ -31,6 +32,12 @@ std::vector> Analyse::layer_export() { return layer_cases; } +std::vector Analyse::build_resolve() { + return build_until([](uint64_t code) { + return ((code >> (3 * 0xD)) & 0b111) == B_2x2; + }); +} + /// memory initialize and return klotski core Core Analyse::init(uint64_t code) { /// reset working data diff --git a/src/analyse/analyse.h b/src/analyse/analyse.h index 406c733..8d78be6 100644 --- a/src/analyse/analyse.h +++ b/src/analyse/analyse.h @@ -21,9 +21,12 @@ public: /// BFS search functions void build(); + std::vector build_resolve(); + // TODO: build_furthest std::vector build_until(const match_t &match); /// analysed layer export + // TODO: ending point search std::vector> layer_export(); std::vector layer_export(uint32_t layer_num); @@ -46,14 +49,18 @@ private: /// backtrack definitions public: struct track_t { + // TODO: try using RawCode uint64_t code; uint32_t layer_num; std::list last; std::list next; }; + // TODO: try using RawCode typedef std::vector> track_data_t; // TODO: using RawCode instead of uint64_t track_data_t backtrack(const std::vector &codes); + // TODO: RawCode enable `hash` and `equal_to` trait in namespace std + }; diff --git a/src/main.cc b/src/main.cc index 8799b56..7b65bd4 100644 --- a/src/main.cc +++ b/src/main.cc @@ -61,15 +61,16 @@ int main() { auto start_time = clock(); -// auto a = Analyse(RawCode::from_common_code("1a9bf0c")); + auto a = Analyse(RawCode::from_common_code("1a9bf0c")); // auto a = Analyse(RawCode::from_common_code("4fea134")); - auto a = Analyse(RawCode::from_common_code("A5D3AF")); +// auto a = Analyse(RawCode::from_common_code("A5D3AF")); // a.build(); - auto ret = a.build_until([](uint64_t code) { - return ((code >> (3 * 0xD)) & 0b111) == B_2x2; - }); +// auto ret = a.build_until([](uint64_t code) { +// return ((code >> (3 * 0xD)) & 0b111) == B_2x2; +// }); + auto ret = a.build_resolve(); // for (const auto &r : ret) { // std::cout << r << std::endl; // } @@ -79,11 +80,15 @@ int main() { std::cerr << (clock() - start_time) * 1000000 / CLOCKS_PER_SEC << "us" << std::endl; - auto g = Graph(); + start_time = clock(); auto svg_ret = a.backtrack(ret); + std::cerr << (clock() - start_time) * 1000000 / CLOCKS_PER_SEC << "us" << std::endl; + + + auto g = Graph(); auto svg_data = g.svg_demo(svg_ret); - std::cout << svg_data << std::endl; +// std::cout << svg_data << std::endl; // std::cout << a.layer_export(81).size() << std::endl;