diff --git a/src/klotski_core/group/CMakeLists.txt b/src/klotski_core/group/CMakeLists.txt index 45df20a..e23a160 100644 --- a/src/klotski_core/group/CMakeLists.txt +++ b/src/klotski_core/group/CMakeLists.txt @@ -1,3 +1,3 @@ cmake_minimum_required(VERSION 3.0) -add_library(group OBJECT group.cc build_cases.cc block_num.cc) +add_library(group OBJECT group.cc block_num.cc build_cases.cc group_info.cc) diff --git a/src/klotski_core/group/build_cases.cc b/src/klotski_core/group/build_cases.cc index fa91e04..42c95f6 100644 --- a/src/klotski_core/group/build_cases.cc +++ b/src/klotski_core/group/build_cases.cc @@ -74,6 +74,11 @@ std::vector Group::group_cases(const RawCode &seed) { return result; } +// TODO: test this function +std::vector Group::group_cases(const CommonCode &seed) { + return group_cases(RawCode::from_common_code(seed)); +} + std::vector Group::build_group(uint32_t type_id, uint32_t group_id) { uint32_t group_num = 0; auto all_cases = Group::all_cases(type_id); // load all cases of type_id diff --git a/src/klotski_core/group/group.h b/src/klotski_core/group/group.h index b2fb9e5..a540c8e 100644 --- a/src/klotski_core/group/group.h +++ b/src/klotski_core/group/group.h @@ -9,7 +9,7 @@ namespace klotski { const uint32_t TYPE_ID_LIMIT = 203; class Group { -/// ---------------------------- block statistics ----------------------------- +/// -------------------------------- block statistics --------------------------------- public: /// 1. n_1x1 + (n_1x2 + n_2x1) * 2 <= 14 /// 2. (n_1x1 != 0) && (n_2x1 != 7) @@ -29,13 +29,14 @@ public: static block_num_t block_num(const RawCode &raw_code); static block_num_t block_num(const CommonCode &common_code); -/// ----------------------------- cases expansion ----------------------------- +/// --------------------------------- cases expansion --------------------------------- /// Search for all cases of the specified type_id. static std::vector all_cases(uint32_t type_id); /// Search for all derivatives that a case can produce. static std::vector group_cases(const RawCode &seed); + static std::vector group_cases(const CommonCode &seed); /// Calculate all groups in the specified type_id. static std::vector> build_groups(uint32_t type_id); @@ -43,15 +44,34 @@ public: /// Calculate the specified group using type_id and group_id. static std::vector build_group(uint32_t type_id, uint32_t group_id); -/// ---------------------------- xxxxxxxxxxxxxxxxx ---------------------------- +/// ----------------------------------- group info ------------------------------------ + struct group_info_t { + uint16_t type_id; + uint16_t group_id; + uint32_t group_index; + }; + + /// Get group info according to RawCode. + static group_info_t group_info(const RawCode &raw_code); + + /// Get group info according to CommonCode. + static group_info_t group_info(const CommonCode &common_code); + + /// Get the CommonCode according to the group info. + static CommonCode group_case(const group_info_t &group_info); + +/// -------------------------------- xxxxxxxxxxxxxxxxx -------------------------------- + + // TODO: update max_group_size in TYPE_ID_MAX_GROUP // static uint32_t max_group_size(uint32_t type_id); + static uint32_t max_group_size(const RawCode &raw_code) { return 65535 * 8; }; - +// static uint32_t max_group_size(const CommonCode &common_code); }; diff --git a/src/klotski_core/group/group_info.cc b/src/klotski_core/group/group_info.cc new file mode 100644 index 0000000..cc103be --- /dev/null +++ b/src/klotski_core/group/group_info.cc @@ -0,0 +1,26 @@ +#include "group.h" + +namespace klotski { + +Group::group_info_t Group::group_info(const RawCode &raw_code) { + + // TODO: function body + + return Group::group_info_t(); +} + +Group::group_info_t Group::group_info(const CommonCode &common_code) { + + // TODO: function body + + return Group::group_info_t(); +} + +CommonCode Group::group_case(const Group::group_info_t &group_info) { + + // TODO: function body + + return CommonCode(0); +} + +} // namespace klotski diff --git a/src/klotski_core/group/type_id.h b/src/klotski_core/group/type_id.h index 034c029..1478e98 100644 --- a/src/klotski_core/group/type_id.h +++ b/src/klotski_core/group/type_id.h @@ -47,4 +47,7 @@ const uint32_t TYPE_ID_SIZE[203] = { 1036, 464, 342, }; +// TODO: TYPE_ID_MAX_GROUP_SIZE +// TODO: TYPE_ID_GROUP_NUM + } // namespace klotski