Browse Source

feat: backtrack for furthest cases in FastCal

legacy
Dnomd343 2 years ago
parent
commit
c69b59424a
  1. 13
      src/fast_cal/fast_cal.cc
  2. 9
      src/fast_cal/fast_cal.h
  3. 10
      src/main.cc

13
src/fast_cal/fast_cal.cc

@ -54,6 +54,15 @@ std::vector<std::vector<RawCode>> FastCal::resolve_multi(RawCode start) {
return FastCal::search_multi(start, resolved);
}
std::vector<std::vector<RawCode>> FastCal::to_furthest(RawCode start) {
auto fc = FastCal();
std::vector<std::vector<RawCode>> result;
for (const auto &furthest : fc.furthest(start)) {
result.emplace_back(fc.backtrack(furthest)); // backtrack every furthest cases
}
return result;
}
std::vector<RawCode> FastCal::search(RawCode start, const match_t &match) {
auto fc = FastCal();
auto result = fc.target(start, match);
@ -66,8 +75,8 @@ std::vector<RawCode> FastCal::search(RawCode start, const match_t &match) {
std::vector<std::vector<RawCode>> FastCal::search_multi(RawCode start, const match_t &match) {
auto fc = FastCal();
std::vector<std::vector<RawCode>> result;
for (const auto &c : fc.target_multi(start, match)) {
result.emplace_back(fc.backtrack(c)); // backtrack every target
for (const auto &target : fc.target_multi(start, match)) {
result.emplace_back(fc.backtrack(target)); // backtrack every target
}
return result;
}

9
src/fast_cal/fast_cal.h

@ -28,15 +28,14 @@ public:
std::vector<RawCode> target_multi(RawCode code, const match_t &match);
/// static BFS search functions
// TODO: (RawCode code) -> (const RawCode &code)
// static std::vector<RawCode> get_furthest(RawCode start);
static std::vector<RawCode> resolve(RawCode start);
static std::vector<RawCode> search(RawCode start, const match_t &match);
static std::vector<std::vector<RawCode>> to_furthest(RawCode start);
static std::vector<std::vector<RawCode>> resolve_multi(RawCode start);
static std::vector<RawCode> search(RawCode start, const match_t &match);
static std::vector<std::vector<RawCode>> search_multi(RawCode start, const match_t &match);
// TODO: (RawCode code) -> (const RawCode &code)
private:
struct fast_cal_t {
uint64_t code;

10
src/main.cc

@ -49,11 +49,11 @@ int main() {
// std::cout << c << std::endl;
// }
for (const auto &s : FastCal::resolve_multi(RawCode::from_common_code("1a9bf0c"))) {
// for (const auto &c : s) {
// std::cout << c << std::endl;
// }
// std::cout << "--------------------------------------------" << std::endl;
for (const auto &s : FastCal::to_furthest(RawCode::from_common_code("1a9bf0c"))) {
for (const auto &c : s) {
std::cout << c << std::endl;
}
std::cout << "--------------------------------------------" << std::endl;
}
// std::cout << f.step_num(ret) << std::endl;

Loading…
Cancel
Save