From 6372a3a875ba84330f13b15970aecac92a269ed0 Mon Sep 17 00:00:00 2001 From: Dnomd343 Date: Fri, 13 Jan 2023 20:42:54 +0800 Subject: [PATCH] fix: search max step in case list --- src/analyse/analyse.cc | 10 +++++++++- src/main.cc | 16 ++++++++++------ 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/analyse/analyse.cc b/src/analyse/analyse.cc index f08aeed..b0361c4 100644 --- a/src/analyse/analyse.cc +++ b/src/analyse/analyse.cc @@ -64,7 +64,15 @@ void Analyse::backtrack(const std::vector &raw_code_list) { /// layer init // auto max_step = cases[code].step; // TODO: update max step cal // auto max_step = 81; - auto max_step = 14; // TODO: search max_step value + + uint32_t max_step = 0; + for (const auto &code : raw_code_list) { + // TODO: check whether cases include code + if (cases[code].step > max_step) { + max_step = cases[code].step; + } + } + layer_data.resize(max_step + 1); /// init track begin cases diff --git a/src/main.cc b/src/main.cc index ee83fdb..2cf2b77 100644 --- a/src/main.cc +++ b/src/main.cc @@ -212,14 +212,18 @@ int main() { // }; // a.backtrack(raw_codes); +// std::vector raw_codes = { +// CommonCode("DE77D80").to_raw_code().unwrap(), +// CommonCode("DF6DD80").to_raw_code().unwrap(), +// CommonCode("DF69730").to_raw_code().unwrap(), +// CommonCode("DE76D30").to_raw_code().unwrap(), +// CommonCode("D5AF730").to_raw_code().unwrap(), +// CommonCode("D5B43BC").to_raw_code().unwrap(), +// }; std::vector raw_codes = { - CommonCode("DE77D80").to_raw_code().unwrap(), - CommonCode("DF6DD80").to_raw_code().unwrap(), - CommonCode("DF69730").to_raw_code().unwrap(), - CommonCode("DE76D30").to_raw_code().unwrap(), - CommonCode("D5AF730").to_raw_code().unwrap(), - CommonCode("D5B43BC").to_raw_code().unwrap(), + CommonCode("EF697C0").to_raw_code().unwrap(), }; + // TODO: FATAL ERROR -> don't using mask in Analyse a.backtrack(raw_codes);