|
|
@ -1,5 +1,6 @@ |
|
|
|
#include "rust_ffi/include/layout.h" |
|
|
|
|
|
|
|
#include <group/group.h> |
|
|
|
#include <mover/mover.h> |
|
|
|
#include <common_code/common_code.h> |
|
|
|
|
|
|
@ -8,6 +9,11 @@ using klotski::codec::CommonCode; |
|
|
|
|
|
|
|
using klotski::mover::MaskMover; |
|
|
|
|
|
|
|
using klotski::group::Group; |
|
|
|
using klotski::group::BLOCK_NUM; |
|
|
|
using klotski::group::GroupCases; |
|
|
|
using klotski::group::GroupUnion; |
|
|
|
|
|
|
|
using klotski::ffi::RsLayout; |
|
|
|
using klotski::ffi::RsShortCode; |
|
|
|
|
|
|
@ -52,6 +58,38 @@ RsLayout RsLayout::to_horizontal_mirror() const noexcept { |
|
|
|
return {CommonCode::unsafe_create(code).to_horizontal_mirror().unwrap()}; |
|
|
|
} |
|
|
|
|
|
|
|
uint8_t RsLayout::n_1x1() const noexcept { |
|
|
|
return std::get<2>(BLOCK_NUM[type_id()]); |
|
|
|
} |
|
|
|
|
|
|
|
uint8_t RsLayout::n_1x2() const noexcept { |
|
|
|
return std::get<0>(BLOCK_NUM[type_id()]) - n_2x1(); |
|
|
|
} |
|
|
|
|
|
|
|
uint8_t RsLayout::n_2x1() const noexcept { |
|
|
|
return std::get<1>(BLOCK_NUM[type_id()]); |
|
|
|
} |
|
|
|
|
|
|
|
uint8_t RsLayout::n_2x2() const noexcept { |
|
|
|
return 1; |
|
|
|
} |
|
|
|
|
|
|
|
uint8_t RsLayout::type_id() const noexcept { |
|
|
|
return GroupUnion::from_common_code(CommonCode::unsafe_create(code)).unwrap(); |
|
|
|
} |
|
|
|
|
|
|
|
uint16_t RsLayout::pattern_id() const noexcept { |
|
|
|
return GroupCases::obtain_group(CommonCode::unsafe_create(code)).pattern_id(); |
|
|
|
} |
|
|
|
|
|
|
|
uint8_t RsLayout::toward_char() const noexcept { |
|
|
|
return GroupCases::obtain_group(CommonCode::unsafe_create(code)).toward_char(); |
|
|
|
} |
|
|
|
|
|
|
|
uint32_t RsLayout::case_id() const noexcept { |
|
|
|
return GroupCases::obtain_info(CommonCode::unsafe_create(code)).case_id(); |
|
|
|
} |
|
|
|
|
|
|
|
rust::Vec<RsLayout> RsLayout::next_cases() const noexcept { |
|
|
|
std::vector<CommonCode> result; |
|
|
|
auto mover = MaskMover([&result](const RawCode code, uint64_t) { |
|
|
|