Browse Source

feat: new namespace klotski

master
Dnomd343 2 years ago
parent
commit
8b67cbbb98
  1. 7
      src/klotski/all_cases/all_cases.cc
  2. 10
      src/klotski/all_cases/all_cases.h
  3. 2
      src/klotski/all_cases/basic_ranges.cc
  4. 5
      src/klotski/all_cases/basic_ranges.h
  5. 2
      src/klotski/common_code/common_code.cc
  6. 2
      src/klotski/ffi/tmain.cc
  7. 2
      src/klotski/raw_code/convert.cc
  8. 2
      src/klotski/short_code/convert.cc
  9. 2
      src/klotski/short_code/short_code.cc
  10. 2
      src/klotski/utils/common.cc
  11. 2
      src/klotski/utils/common.h

7
src/klotski/all_cases/all_cases.cc

@ -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,
2322050, 1876945, 2322050, 0,
2942906, 2260392, 2942906, 0,
};
using namespace klotski;
/// static variable initialize
std::mutex AllCases::building;

10
src/klotski/all_cases/all_cases.h

@ -5,6 +5,15 @@
#include <cstdint>
#include "basic_ranges.h"
namespace klotski {
/// all cases count
const uint32_t ALL_CASES_SIZE[16] = {
2942906, 2260392, 2942906, 0,
2322050, 1876945, 2322050, 0,
2322050, 1876945, 2322050, 0,
2942906, 2260392, 2942906, 0,
};
class AllCases : public BasicRanges {
public:
static void build();
@ -18,3 +27,4 @@ private:
static void build_data();
};
}

2
src/klotski/all_cases/basic_ranges.cc

@ -3,7 +3,7 @@
#include "common.h"
#include "basic_ranges.h"
const uint32_t BASIC_RANGES_SIZE = 7311921;
using namespace klotski;
/// static variable initialize
std::mutex BasicRanges::building;

5
src/klotski/all_cases/basic_ranges.h

@ -4,6 +4,10 @@
#include <vector>
#include <cstdint>
namespace klotski {
/// basic ranges count
const uint32_t BASIC_RANGES_SIZE = 7311921;
class BasicRanges {
public:
enum Status {
@ -30,3 +34,4 @@ private:
static void build_data();
static void generate(generate_t info);
};
}

2
src/klotski/common_code/common_code.cc

@ -2,6 +2,8 @@
#include "common.h"
#include "common_code.h"
using namespace klotski;
uint64_t CommonCode::unwrap() const {
return code; // raw uint64_t code
}

2
src/klotski/ffi/tmain.cc

@ -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;

2
src/klotski/raw_code/convert.cc

@ -2,6 +2,8 @@
#include "common.h"
#include "raw_code.h"
using namespace klotski;
/// RawCode to CommonCode
CommonCode RawCode::to_common_code() const {
if (!RawCode::check(code)) {

2
src/klotski/short_code/convert.cc

@ -6,6 +6,8 @@
#include "basic_ranges_offset.h"
#include "range_prefix_offset.h"
using namespace klotski;
/// ShortCode to CommonCode
CommonCode ShortCode::to_common_code() const { // convert to common code
if (ShortCode::mode() == ShortCode::NORMAL) {

2
src/klotski/short_code/short_code.cc

@ -1,6 +1,8 @@
#include "all_cases.h"
#include "short_code.h"
using namespace klotski;
uint32_t ShortCode::unwrap() const {
return code; // raw uint32_t code
}

2
src/klotski/utils/common.cc

@ -1,5 +1,7 @@
#include "common.h"
using namespace klotski;
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);

2
src/klotski/utils/common.h

@ -59,8 +59,10 @@
/// 00 01 10 11 ... => ... 11 10 01 00
/// (high 8-bits) (low 8-bits)
namespace klotski {
class Common {
public:
static uint32_t range_reverse(uint32_t bin);
static uint8_t check_range(uint32_t head, uint32_t range);
};
}

Loading…
Cancel
Save