diff --git a/src/core/core.cc b/src/core/core.cc index 18defa1..df1a6aa 100644 --- a/src/core/core.cc +++ b/src/core/core.cc @@ -129,36 +129,33 @@ void Core::move_2x2(uint64_t code, int addr) { // try to move target 2x2 block #include void Core::next_step(uint64_t raw_code) { - - auto temp_code = raw_code; -// uint64_t raw_code = _code; - - for (int addr = 0; temp_code; addr += 3, temp_code >>= 3) { - - switch (temp_code & 0b111) { + auto code = raw_code; + for (int addr = 0; code; addr += 3, code >>= 3) { // traverse every 3-bits + switch (code & 0b111) { // match low 3-bits case B_1x1: - move_1x1(raw_code, addr); + move_1x1(raw_code, addr); // try to move 1x1 block break; case B_1x2: - move_1x2(raw_code, addr); + move_1x2(raw_code, addr); // try to move 1x2 block break; case B_2x1: - move_2x1(raw_code, addr); + move_2x1(raw_code, addr); // try to move 2x1 block break; case B_2x2: - move_2x2(raw_code, addr); + move_2x2(raw_code, addr); // try to move 2x2 block break; default: continue; // B_space or B_fill } - if (cache_size != 1) { + if (cache_size != 1) { // found one or more next cases for (int i = 1; i < cache_size; ++i) { -// std::cout << RawCode(cache[i].code).dump_case(); -// printf("(%016lX)\n\n", cache[i].mask); + + // TODO: release next cases (code and mask) + + std::cout << RawCode(cache[i].code).dump_case(); + printf("(%016lX)\n\n", cache[i].mask); + } -// std::cout << "found: " << cache_size - 1 << std::endl; } } } - - diff --git a/src/core/core.h b/src/core/core.h index a400e69..a94b959 100644 --- a/src/core/core.h +++ b/src/core/core.h @@ -19,36 +19,22 @@ class Core { public: + void next_step(uint64_t raw_code); + +private: struct cache_t { - uint64_t code; // raw code + uint64_t code; // case raw code uint64_t mask; // only 000 or 111 - int filter; - int addr; + int filter; // UP | DOWN | LEFT | RIGHT + int addr; // (0 ~ 19) * 3 }; int cache_size; cache_t cache[16]; - inline void cache_insert(Core::cache_t &next_case); - void move_1x1(uint64_t code, int addr); void move_1x2(uint64_t code, int addr); void move_2x1(uint64_t code, int addr); void move_2x2(uint64_t code, int addr); - -// void move_1x1(int addr); -// void move_1x2(int addr); -// void move_2x1(int addr); -// void move_2x2(int addr); - - void next_step(uint64_t raw_code); - -// void next_step(); - -// uint64_t _code; - -// Core(uint64_t raw_code) : _code(raw_code) {} - + inline void cache_insert(Core::cache_t &next_case); }; - - diff --git a/src/main.cc b/src/main.cc index 812f3c0..3cc5a8a 100644 --- a/src/main.cc +++ b/src/main.cc @@ -148,9 +148,9 @@ int main() { auto c = Core(); // auto c = Core(raw_code); - for (int i = 0; i < 100000000; ++i) { +// for (int i = 0; i < 100000000; ++i) { c.next_step(raw_code); - } +// } return 0; }