diff --git a/klotski/all_cases.h b/klotski/all_cases.h index 68abeb9..8467b00 100644 --- a/klotski/all_cases.h +++ b/klotski/all_cases.h @@ -13,6 +13,8 @@ public: const std::vector* get_basic_ranges(); const std::vector (*get_all_cases())[16]; + // TODO: add all_cases_list export + private: std::vector basic_ranges; std::vector all_cases[16]; diff --git a/klotski/common_code.cc b/klotski/common_code.cc index 52a50aa..b6593b7 100644 --- a/klotski/common_code.cc +++ b/klotski/common_code.cc @@ -2,6 +2,7 @@ #include "common.h" #include "common_code.h" +/// WARN: bin should not be zero inline uint8_t last_zero_num(uint32_t bin) { // get last zero number bin ^= (bin - 1); return __builtin_popcount(bin >> 1); diff --git a/klotski/main.cc b/klotski/main.cc index 15d4ad3..1d1c2f9 100644 --- a/klotski/main.cc +++ b/klotski/main.cc @@ -35,8 +35,36 @@ int main() { // std::cout << CommonCode::code_to_string(0x4FEA13400, true) << std::endl; // std::cout << CommonCode::code_to_string(0x4FEA13400) << std::endl; - printf("%09lX\n", CommonCode::code_from_string("4FEa134")); - printf("%09lX\n", CommonCode::code_from_string("1A9bf0C0")); +// printf("%09lX\n", CommonCode::code_from_string("4FEa134")); +// printf("%09lX\n", CommonCode::code_from_string("1A9bf0C0")); + + +// std::cout << (int)last_zero_num(0b1) << std::endl; +// std::cout << (int)last_zero_num(0b1000) << std::endl; +// std::cout << (int)last_zero_num(0) << std::endl; +// std::cout << CommonCode::code_to_string(0, true) << std::endl; + + auto a = AllCases(); + std::vector all_cases; + for (int head = 0; head < 16; ++head) { + auto prefix = (uint64_t)head << 32; + for (auto const &range : (*a.get_all_cases())[head]) { + all_cases.emplace_back(prefix | range); + } + } +// std::cout << all_cases.size() << std::endl; + for (auto const &code : all_cases) { +// printf("%s\n", CommonCode::code_to_string(code).c_str()); + std::string code_str = CommonCode::code_to_string(code); + if (CommonCode::code_from_string(code_str) != code) { + std::cout << "ERROR: " << code_str << std::endl; + } + + code_str = CommonCode::code_to_string(code, true); + if (CommonCode::code_from_string(code_str) != code) { + std::cout << "ERROR: " << code_str << std::endl; + } + } return 0; }