Browse Source

feat: add group mirror support

legacy
Dnomd343 3 months ago
parent
commit
f7f5440887
  1. 6
      src/core/group/group.h
  2. 8
      src/core/group/internal/constant/group.h
  3. 1
      src/core/group/internal/constant/mirror_h.inc
  4. 1
      src/core/group/internal/constant/mirror_v.inc
  5. 10
      src/core/group/internal/group.inl
  6. 16
      src/core/main.cc

6
src/core/group/group.h

@ -186,6 +186,12 @@ public:
// ------------------------------------------------------------------------------------- // // ------------------------------------------------------------------------------------- //
// TODO: add `is_xxx_mirror` interface
[[nodiscard]] Group to_vertical_mirror() const;
[[nodiscard]] Group to_horizontal_mirror() const;
private: private:
uint32_t type_id_; uint32_t type_id_;
uint32_t group_id_; uint32_t group_id_;

8
src/core/group/internal/constant/group.h

@ -13,4 +13,12 @@ constexpr auto GROUP_SEED = std::to_array<uint64_t>({
#include "seeds.inc" #include "seeds.inc"
}); });
constexpr auto GROUP_MIRROR_H = std::to_array<uint16_t>({
#include "mirror_h.inc"
});
constexpr auto GROUP_MIRROR_V = std::to_array<uint16_t>({
#include "mirror_v.inc"
});
} // namespace klotski::cases } // namespace klotski::cases

1
src/core/group/internal/constant/mirror_h.inc

File diff suppressed because one or more lines are too long

1
src/core/group/internal/constant/mirror_v.inc

File diff suppressed because one or more lines are too long

10
src/core/group/internal/group.inl

@ -24,6 +24,16 @@ constexpr uint32_t Group::flat_id() const {
// ----------------------------------------------------------------------------------------- // // ----------------------------------------------------------------------------------------- //
Group Group::to_vertical_mirror() const {
return Group::unsafe_create(type_id_, GROUP_MIRROR_V[flat_id()]);
}
Group Group::to_horizontal_mirror() const {
return Group::unsafe_create(type_id_, GROUP_MIRROR_H[flat_id()]);
}
// ----------------------------------------------------------------------------------------- //
inline Group Group::from_common_code(codec::CommonCode common_code) { inline Group Group::from_common_code(codec::CommonCode common_code) {
return from_raw_code(common_code.to_raw_code()); return from_raw_code(common_code.to_raw_code());
} }

16
src/core/main.cc

@ -30,6 +30,7 @@ using klotski::cases::Group;
using klotski::cases::GroupCases; using klotski::cases::GroupCases;
using klotski::cases::GroupUnion; using klotski::cases::GroupUnion;
using klotski::cases::TYPE_ID_LIMIT;
using klotski::codec::SHORT_CODE_LIMIT; using klotski::codec::SHORT_CODE_LIMIT;
int main() { int main() {
@ -43,13 +44,18 @@ int main() {
// const auto common_code = CommonCode::unsafe_create(0x1A9BF0C00); // const auto common_code = CommonCode::unsafe_create(0x1A9BF0C00);
// const auto group = Group::from_common_code(common_code); // const auto group = Group::from_common_code(common_code);
GroupCases::build(); // GroupCases::build();
//
// std::cout << GroupCases::fast_parse({169, 1, 7472}) << std::endl;
// std::cout << GroupCases::fast_parse({164, 0, 30833}) << std::endl;
//
// std::cout << GroupCases::fast_obtain(CommonCode::unsafe_create(0x1A9BF0C00)) << std::endl;
// std::cout << GroupCases::fast_obtain(CommonCode::unsafe_create(0x4FEA13400)) << std::endl;
std::cout << GroupCases::fast_parse({169, 1, 7472}) << std::endl; auto group = Group::unsafe_create(123, 1446);
std::cout << GroupCases::fast_parse({164, 0, 30833}) << std::endl;
std::cout << GroupCases::fast_obtain(CommonCode::unsafe_create(0x1A9BF0C00)) << std::endl; std::cout << group.to_horizontal_mirror().group_id() << std::endl;
std::cout << GroupCases::fast_obtain(CommonCode::unsafe_create(0x4FEA13400)) << std::endl; std::cout << group.to_vertical_mirror().group_id() << std::endl;
std::cerr << std::chrono::system_clock::now() - start << std::endl; std::cerr << std::chrono::system_clock::now() - start << std::endl;

Loading…
Cancel
Save