|
@ -31,22 +31,31 @@ void FastCal::new_case(uint64_t code, uint64_t mask) { // callback function for |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
std::vector<uint64_t> FastCal::search(uint64_t code) { |
|
|
std::vector<uint64_t> FastCal::solve() { |
|
|
|
|
|
|
|
|
|
|
|
auto resolved = [](uint64_t code) { |
|
|
|
|
|
return ((code >> (3 * 0xD)) & 0b111) == B_2x2; |
|
|
|
|
|
}; |
|
|
|
|
|
return target(resolved); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
std::vector<uint64_t> FastCal::target(const std::function<bool(uint64_t)> &match) { |
|
|
|
|
|
|
|
|
auto core = import_core(); |
|
|
auto core = import_core(); |
|
|
|
|
|
|
|
|
// clear data
|
|
|
// clear data
|
|
|
cases.clear(); |
|
|
cases.clear(); |
|
|
|
|
|
|
|
|
auto empty = std::queue<fast_cal_t*>{}; |
|
|
std::queue<fast_cal_t*>{}.swap(cache); |
|
|
std::swap(empty, cache); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// auto empty = std::queue<fast_cal_t*>{};
|
|
|
|
|
|
// std::swap(empty, cache);
|
|
|
|
|
|
|
|
|
cases.reserve(65536); |
|
|
cases.reserve(65536); |
|
|
|
|
|
|
|
|
|
|
|
cache.emplace(&cases.emplace(root, fast_cal_t { |
|
|
cache.emplace(&cases.emplace(code, fast_cal_t { |
|
|
.code = root, |
|
|
.code = code, |
|
|
|
|
|
.mask = 0, |
|
|
.mask = 0, |
|
|
.last = nullptr, |
|
|
.last = nullptr, |
|
|
}).first->second); |
|
|
}).first->second); |
|
@ -54,8 +63,7 @@ std::vector<uint64_t> FastCal::search(uint64_t code) { |
|
|
while (!cache.empty()) { |
|
|
while (!cache.empty()) { |
|
|
|
|
|
|
|
|
/// break check point
|
|
|
/// break check point
|
|
|
if (((cache.front()->code >> (3 * 0xD)) & 0b111) == B_2x2) { |
|
|
if (match(cache.front()->code)) { |
|
|
std::cout << "Resolved" << std::endl; |
|
|
|
|
|
break; |
|
|
break; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -65,6 +73,10 @@ std::vector<uint64_t> FastCal::search(uint64_t code) { |
|
|
|
|
|
|
|
|
std::cout << "size: " << cases.size() << std::endl; |
|
|
std::cout << "size: " << cases.size() << std::endl; |
|
|
|
|
|
|
|
|
|
|
|
// TODO: single backtrack function
|
|
|
|
|
|
|
|
|
|
|
|
// TODO: cache may empty -> never found
|
|
|
|
|
|
|
|
|
auto solution = cache.front(); |
|
|
auto solution = cache.front(); |
|
|
|
|
|
|
|
|
std::vector<uint64_t> solution_path; |
|
|
std::vector<uint64_t> solution_path; |
|
|