@ -1,12 +1,7 @@
#include "common.h"
#include "all_cases.h"
const uint32_t ALL_CASES_SIZE[16] = {
2942906, 2260392, 2942906, 0,
2322050, 1876945, 2322050, 0,
};
using namespace klotski;
/// static variable initialize
std::mutex AllCases::building;
@ -5,6 +5,15 @@
#include <cstdint>
#include "basic_ranges.h"
namespace klotski {
/// all cases count
class AllCases : public BasicRanges {
public:
static void build();
@ -18,3 +27,4 @@ private:
static void build_data();
}
@ -3,7 +3,7 @@
const uint32_t BASIC_RANGES_SIZE = 7311921;
std::mutex BasicRanges::building;
@ -4,6 +4,10 @@
#include <vector>
/// basic ranges count
class BasicRanges {
enum Status {
@ -30,3 +34,4 @@ private:
static void generate(generate_t info);
@ -2,6 +2,8 @@
#include "common_code.h"
uint64_t CommonCode::unwrap() const {
return code; // raw uint64_t code
@ -14,7 +14,7 @@ void tmain() {
uint64_t common_code = 0x1A9BC0C00;
Common::range_reverse(common_code);
klotski::Common::range_reverse(common_code);
// uint64_t raw_code = 0x0603EDF5CAFFF5E2;
#include "raw_code.h"
/// RawCode to CommonCode
CommonCode RawCode::to_common_code() const {
if (!RawCode::check(code)) {
@ -6,6 +6,8 @@
#include "basic_ranges_offset.h"
#include "range_prefix_offset.h"
/// ShortCode to CommonCode
CommonCode ShortCode::to_common_code() const { // convert to common code
if (ShortCode::mode() == ShortCode::NORMAL) {
@ -1,6 +1,8 @@
#include "short_code.h"
uint32_t ShortCode::unwrap() const {
return code; // raw uint32_t code
@ -1,5 +1,7 @@
uint32_t Common::range_reverse(uint32_t bin) { // reverse binary every 2-bits
bin = ((bin << 16) & 0xFFFF0000) | ((bin >> 16) & 0x0000FFFF);
bin = ((bin << 8) & 0xFF00FF00) | ((bin >> 8) & 0x00FF00FF);
@ -59,8 +59,10 @@
/// 00 01 10 11 ... => ... 11 10 01 00
/// (high 8-bits) (low 8-bits)
class Common {
static uint32_t range_reverse(uint32_t bin);
static uint8_t check_range(uint32_t head, uint32_t range);