Browse Source

chore: update compile structure

master
Dnomd343 2 years ago
parent
commit
12710d3f08
  1. 1
      .gitignore
  2. 70
      legacy/main-old.cc
  3. 225
      legacy/main.cc
  4. 9
      src/CMakeLists.txt
  5. 6
      src/benchmark/CMakeLists.txt
  6. 36
      src/klotski/CMakeLists.txt
  7. 4
      src/klotski/all_cases/CMakeLists.txt
  8. 4
      src/klotski/analyse/CMakeLists.txt
  9. 4
      src/klotski/benchmark/CMakeLists.txt
  10. 0
      src/klotski/benchmark/benchmark.cc
  11. 0
      src/klotski/benchmark/benchmark.h
  12. 2
      src/klotski/benchmark/chore.cc
  13. 4
      src/klotski/common_code/CMakeLists.txt
  14. 2
      src/klotski/core/CMakeLists.txt
  15. 4
      src/klotski/fast_cal/CMakeLists.txt
  16. 1
      src/klotski/ffi/codec.cc
  17. 17
      src/klotski/ffi/klotski.h
  18. 18
      src/klotski/ffi/tmain.cc
  19. 4
      src/klotski/graph/CMakeLists.txt
  20. 4
      src/klotski/raw_code/CMakeLists.txt
  21. 4
      src/klotski/short_code/CMakeLists.txt
  22. 2
      src/klotski/utils/CMakeLists.txt
  23. 10
      src/main.c
  24. 197
      src/main.cc
  25. 6
      test/CMakeLists.txt

1
.gitignore

@ -1,3 +1,4 @@
/bin/
/.idea/
/cmake-build-debug/
/cmake-build-release/

70
legacy/main-old.cc

@ -0,0 +1,70 @@
#include <cstdio>
/*
uint64_t -> 0000 + [xxx] * 20
2x2 2x1 1x2 1x1
# # # # # #
# # #
00 01 02 03
04 05 06 07
08 09 10 11
12 13 14 15
16 17 18 19
x1 (%4) => 0 1 2 3
x3 (%4) => 0 3 2 1
*/
/*
======================================================
1x1 -> 011 000 000 000 -> 0000 0000 0011 -> 0x3
1x2 -> 001 111 000 000 -> 0000 0011 1001 -> 0x39
2x1 -> 010 000 000 000 -> 0000 0000 0010 -> 0x7002
111 000 000 000 -> 0000 0000 0111
2x2 -> 100 111 000 000 -> 0000 0011 1100 -> 0x3F03C
111 111 000 000 -> 0000 0011 1111
======================================================
1x1 -> 111 000 000 000 -> 0000 0000 0111 -> 0x7
1x2 -> 111 111 000 000 -> 0000 0011 1111 -> 0x3F
2x1 -> 111 000 000 000 -> 0000 0000 0111 -> 0x7007
111 000 000 000 -> 0000 0000 0111
2x2 -> 111 111 000 000 -> 0000 0011 1111 -> 0x3F03F
111 111 000 000 -> 0000 0011 1111
======================================================
*/
int main() {
printf("Klotski engine\n");
// 0x4FEA13400
// # # # @ | 011 011 011 010 => 0100 1101 1011 -> 4DB
// * * & @ | 100 111 010 111 => 1110 1011 1100 -> EBC
// * * & $ | 111 111 111 010 => 0101 1111 1111 -> 5FF
// . + + $ | 000 001 111 111 => 1111 1100 1000 -> FC8
// . # ~ ~ | 000 011 001 111 => 1110 0101 1000 -> E58
// 0x0E58FC85FFEBC4DB
// 0x1A9BF0C00
// @ * * @ | 010 100 111 010 => 0101 1110 0010 -> 5E2
// @ * * @ | 111 111 111 111 => 1111 1111 1111 -> FFF
// $ ~ ~ $ | 010 001 111 010 => 0101 1100 1010 -> 5CA
// $ # # $ | 111 011 011 111 => 1110 1101 1111 -> EDF
// # . . # | 011 000 000 011 => 0110 0000 0011 -> 603
// 0x0603EDF5CAFFF5E2
return 0;
}

225
legacy/main.cc

@ -1,70 +1,197 @@
#include <cstdio>
#include <iostream>
/*
#include "ffi/klotski.h"
uint64_t -> 0000 + [xxx] * 20
//#include "utils/common.h"
//#include "all_cases/all_cases.h"
//
//#include "raw_code/raw_code.h"
//#include "short_code/short_code.h"
//#include "common_code/common_code.h"
//
//#include "core/core.h"
//#include "analyse/analyse.h"
//#include "fast_cal/fast_cal.h"
2x2 2x1 1x2 1x1
# # # # # #
# # #
//#include "graph.h"
00 01 02 03
04 05 06 07
08 09 10 11
12 13 14 15
16 17 18 19
//#include "benchmark.h"
x1 (%4) => 0 1 2 3
x3 (%4) => 0 3 2 1
//#include <unistd.h>
*/
int main() {
// std::cout << "start test" << std::endl;
// std::cout << (uint32_t)Common::check_range(1, Common::range_reverse(0xA9BF0C00)) << std::endl;
//
// AllCases::build();
// for (const auto &a : AllCases::fetch()) {
// std::cout << a.size() << std::endl;
// }
//
// std::cout << RawCode::from_common_code("1a9bf0c") << std::endl;
// std::cout << RawCode::create(0x0603EDF5CAFFF5E2) << std::endl;
//
// std::cout << CommonCode::create(0x1A9BF0C00) << std::endl;
// std::cout << CommonCode::from_string("1a9bf0c") << std::endl;
// std::cout << CommonCode::from_short_code(4091296) << std::endl;
// std::cout << CommonCode::from_raw_code(0x0603EDF5CAFFF5E2) << std::endl;
//
// std::cout << ShortCode::create(4091296) << std::endl;
// std::cout << ShortCode::from_string("4WVE1") << std::endl;
// std::cout << ShortCode::from_common_code(0x1A9BF0C00) << std::endl;
//
// auto core = Core([](uint64_t code, uint64_t mask) {
// printf("new case -> code = %015lX | mask = %015lX\n", code, mask);
// });
// core.next_cases(RawCode::from_common_code("1a9bf0c").unwrap(), 0);
//
// for (const auto &c : FastCal::resolve(RawCode::from_common_code("1a9bf0c"))) {
// std::cout << c << std::endl;
// }
//
// auto a = Analyse(RawCode::from_common_code("1a9bf0c"));
// for (const auto &s : a.build_resolve()) {
// std::cout << s << std::endl;
// }
// Benchmark::basic_ranges(std::cout);
auto start = clock();
_tmain();
std::cerr << (clock() - start) * 1000000 / CLOCKS_PER_SEC << "us" << std::endl;
// std::cout << "end test" << std::endl;
// BasicRanges::build();
// Benchmark::basic_ranges(std::cout);
// std::cout << std::endl;
// Benchmark::all_cases(std::cout);
// std::cout << std::endl;
// Benchmark::basic_ranges(std::cout);
/*
======================================================
return 0;
1x1 -> 011 000 000 000 -> 0000 0000 0011 -> 0x3
1x2 -> 001 111 000 000 -> 0000 0011 1001 -> 0x39
// BasicRanges::build();
// AllCases::build();
2x1 -> 010 000 000 000 -> 0000 0000 0010 -> 0x7002
111 000 000 000 -> 0000 0000 0111
2x2 -> 100 111 000 000 -> 0000 0011 1100 -> 0x3F03C
111 111 000 000 -> 0000 0011 1111
// std::vector<RawCode> test_cases;
// {
// AllCases::build();
// std::vector<uint64_t> all_cases;
// for (uint64_t head = 0; head < 16; ++head) {
// for (const auto &range : AllCases::fetch()[head]) {
// all_cases.emplace_back(head << 32 | range);
// }
// }
// for (uint32_t i = 0; i < 100; ++i) {
// test_cases.emplace_back(
// RawCode::from_common_code(all_cases.at(i * 293344))
// );
// }
// }
// std::cout << "test size -> " << test_cases.size() << std::endl;
======================================================
1x1 -> 111 000 000 000 -> 0000 0000 0111 -> 0x7
// std::cout << "wait 3s" << std::endl;
// sleep(3);
1x2 -> 111 111 000 000 -> 0000 0011 1111 -> 0x3F
// std::cout << "start benchmark" << std::endl;
// auto start_time = clock();
2x1 -> 111 000 000 000 -> 0000 0000 0111 -> 0x7007
111 000 000 000 -> 0000 0000 0111
2x2 -> 111 111 000 000 -> 0000 0011 1111 -> 0x3F03F
111 111 000 000 -> 0000 0011 1111
// auto fc = FastCal(RawCode::from_common_code("1a9bf0c"));
// fc.solve();
======================================================
*/
// {
// auto fc = FastCal(RawCode::unsafe_create(0));
// for (auto code : test_cases) {
// fc.set_root(code);
// fc.solve();
// }
// }
int main() {
printf("Klotski engine\n");
// 0x4FEA13400
// # # # @ | 011 011 011 010 => 0100 1101 1011 -> 4DB
// * * & @ | 100 111 010 111 => 1110 1011 1100 -> EBC
// * * & $ | 111 111 111 010 => 0101 1111 1111 -> 5FF
// . + + $ | 000 001 111 111 => 1111 1100 1000 -> FC8
// . # ~ ~ | 000 011 001 111 => 1110 0101 1000 -> E58
// 0x0E58FC85FFEBC4DB
// 0x1A9BF0C00
// @ * * @ | 010 100 111 010 => 0101 1110 0010 -> 5E2
// @ * * @ | 111 111 111 111 => 1111 1111 1111 -> FFF
// $ ~ ~ $ | 010 001 111 010 => 0101 1100 1010 -> 5CA
// $ # # $ | 111 011 011 111 => 1110 1101 1111 -> EDF
// # . . # | 011 000 000 011 => 0110 0000 0011 -> 603
// 0x0603EDF5CAFFF5E2
// auto start_time = clock();
// auto a = Analyse(RawCode::from_common_code("1a9bf0c"));
// auto a = Analyse(RawCode::from_common_code("4fea134"));
// auto a = Analyse(RawCode::from_common_code("A5D3AF"));
// a.build();
// auto ret = a.build_until([](uint64_t code) {
// return ((code >> (3 * 0xD)) & 0b111) == B_2x2;
// });
// auto ret = a.build_resolve();
// for (const auto &r : ret) {
// std::cout << r << std::endl;
// }
// std::cout << ret.size() << std::endl;
// std::cerr << (clock() - start_time) * 1000000 / CLOCKS_PER_SEC << "us" << std::endl;
// start_time = clock();
// auto svg_ret = a.backtrack(ret);
// std::cerr << (clock() - start_time) * 1000000 / CLOCKS_PER_SEC << "us" << std::endl;
// auto g = Graph();
// auto svg_data = g.svg_demo(svg_ret);
// std::cout << svg_data << std::endl;
// std::cout << a.layer_export(81).size() << std::endl;
// std::cout << a.layer_export()[81].size() << std::endl;
// std::vector<uint64_t> raw_codes = {
// CommonCode(0xDAAF4CC00).to_raw_code().unwrap(),
// CommonCode(0xDAA7F3000).to_raw_code().unwrap(),
// };
// a.backtrack(raw_codes);
// std::vector<uint64_t> raw_codes = {
// CommonCode("DE77D80").to_raw_code().unwrap(),
// CommonCode("DF6DD80").to_raw_code().unwrap(),
// CommonCode("DF69730").to_raw_code().unwrap(),
// CommonCode("DE76D30").to_raw_code().unwrap(),
// CommonCode("D5AF730").to_raw_code().unwrap(),
// CommonCode("D5B43BC").to_raw_code().unwrap(),
// };
// std::vector<uint64_t> raw_codes = {
// CommonCode("EF697C0").to_raw_code().unwrap(),
// };
// TODO: FATAL ERROR -> don't using mask in Analyse
// a.backtrack(raw_codes);
// std::cout << ShortCode("EP4HZ") << std::endl;
// std::cout << ShortCode(14323231) << std::endl;
// std::cout << RawCode::from_common_code("4fea134") << std::endl;
// std::cout << CommonCode::from_raw_code(0xE58FC85FFEBC4DB) << std::endl;
// std::cout << ShortCode::from_common_code("4fea134") << std::endl;
// std::cout << CommonCode::from_short_code("AXCZN") << std::endl;
// std::cerr << (clock() - start_time) / CLOCKS_PER_SEC << "s" << std::endl;
// std::cerr << (clock() - start_time) * 1000 / CLOCKS_PER_SEC << "ms" << std::endl;
// std::cerr << (clock() - start_time) * 1000000 / CLOCKS_PER_SEC << "us" << std::endl;
// std::cout << "complete benchmark" << std::endl;
// pause();
return 0;
}

9
src/CMakeLists.txt

@ -1,11 +1,8 @@
cmake_minimum_required(VERSION 3.0)
include_directories(klotski)
include_directories(benchmark)
include_directories(klotski/ffi)
add_subdirectory(klotski)
add_subdirectory(benchmark)
add_executable(klotski_bin main.cc)
target_link_libraries(klotski_bin benchmark)
#target_link_libraries(klotski_bin klotski)
add_executable(demo main.c)
target_link_libraries(demo PUBLIC klotski)

6
src/benchmark/CMakeLists.txt

@ -1,6 +0,0 @@
cmake_minimum_required(VERSION 3.0)
include_directories(../klotski/all_cases)
add_library(benchmark chore.cc benchmark.cc)
target_link_libraries(benchmark klotski)

36
src/klotski/CMakeLists.txt

@ -1,6 +1,10 @@
cmake_minimum_required(VERSION 3.0)
################################################
project(klotski-core LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 14)
################################################################
include_directories(utils)
include_directories(all_cases)
@ -13,7 +17,7 @@ include_directories(core)
include_directories(analyse)
include_directories(fast_cal)
################################################
################################################################
add_subdirectory(utils)
add_subdirectory(all_cases)
@ -26,22 +30,24 @@ add_subdirectory(core)
add_subdirectory(analyse)
add_subdirectory(fast_cal)
################################################
################################################################
add_library(klotski-core OBJECT ffi/codec.cc ffi/tmain.cc)
#add_library(klotski STATIC klotski_ffi.cc)
add_library(klotski SHARED ffi/klotski_ffi.cc ffi/tmain.cc)
target_link_libraries(klotski-core utils)
target_link_libraries(klotski-core all_cases)
################################################
target_link_libraries(klotski-core raw_code)
target_link_libraries(klotski-core short_code)
target_link_libraries(klotski-core common_code)
target_link_libraries(klotski utils)
target_link_libraries(klotski all_cases)
target_link_libraries(klotski-core core)
target_link_libraries(klotski-core analyse)
target_link_libraries(klotski-core fast_cal)
target_link_libraries(klotski raw_code)
target_link_libraries(klotski short_code)
target_link_libraries(klotski common_code)
################################################################
target_link_libraries(klotski core)
target_link_libraries(klotski analyse)
target_link_libraries(klotski fast_cal)
#add_library(klotski SHARED $<TARGET_OBJECTS:klotski-core>)
add_library(klotski STATIC $<TARGET_OBJECTS:klotski-core>)
################################################
################################################################

4
src/klotski/all_cases/CMakeLists.txt

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.0)
add_library(all_cases all_cases.cc basic_ranges.cc)
target_link_libraries(all_cases utils)
add_library(all_cases STATIC all_cases.cc basic_ranges.cc)
target_link_libraries(all_cases PUBLIC utils)

4
src/klotski/analyse/CMakeLists.txt

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.0)
add_library(analyse analyse.cc backtrack.cc)
target_link_libraries(analyse core)
add_library(analyse STATIC analyse.cc backtrack.cc)
target_link_libraries(analyse PUBLIC core)

4
src/klotski/benchmark/CMakeLists.txt

@ -0,0 +1,4 @@
cmake_minimum_required(VERSION 3.0)
add_library(benchmark STATIC chore.cc benchmark.cc)
target_link_libraries(benchmark PUBLIC all_cases)

0
src/benchmark/benchmark.cc → src/klotski/benchmark/benchmark.cc

0
src/benchmark/benchmark.h → src/klotski/benchmark/benchmark.h

2
src/benchmark/chore.cc → src/klotski/benchmark/chore.cc

@ -1,5 +1,7 @@
#include "benchmark.h"
// TODO: remove std::cout output -> only return benchmark status
/// colorful string
std::string Benchmark::color_red(const std::string &str) {
return std::string("\033[31m") + str + "\033[0m";

4
src/klotski/common_code/CMakeLists.txt

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.0)
add_library(common_code convert.cc serialize.cc common_code.cc)
target_link_libraries(common_code utils)
add_library(common_code STATIC convert.cc serialize.cc common_code.cc)
target_link_libraries(common_code PUBLIC utils)

2
src/klotski/core/CMakeLists.txt

@ -1,3 +1,3 @@
cmake_minimum_required(VERSION 3.0)
add_library(core core.cc)
add_library(core STATIC core.cc)

4
src/klotski/fast_cal/CMakeLists.txt

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.0)
add_library(fast_cal cal_core.cc fast_cal.cc)
target_link_libraries(fast_cal core)
add_library(fast_cal STATIC cal_core.cc fast_cal.cc)
target_link_libraries(fast_cal PUBLIC core)

1
src/klotski/ffi/klotski_ffi.cc → src/klotski/ffi/codec.cc

@ -1,5 +1,4 @@
#include "klotski.h"
#include "short_code.h"
void short_code_speed_up() {

17
src/klotski/ffi/klotski.h

@ -1,12 +1,23 @@
#pragma once
#ifdef __cplusplus
extern "C" {
void _tmain();
#endif
void tmain();
#ifdef __cplusplus
}
#endif
#ifdef __cplusplus
extern "C" {
#endif
void short_code_speed_up();
void short_code_speed_up_fast();
void short_code_speed_up();
void short_code_speed_up_fast();
#ifdef __cplusplus
}
#endif

18
src/klotski/ffi/tmain.cc

@ -3,17 +3,17 @@
#include "core.h"
void _tmain() {
// std::cout << "test" << std::endl;
void tmain() {
std::cout << "tmain start" << std::endl;
uint64_t raw_code = 0x0603EDF5CAFFF5E2;
// uint64_t raw_code = 0x0603EDF5CAFFF5E2;
auto core = Core([](uint64_t code, uint64_t mask) {
return;
});
// auto core = Core([](uint64_t code, uint64_t mask) {
// return;
// });
for (uint32_t i = 0; i < 1000000; ++i) {
core.next_cases(raw_code, 0);
}
// for (uint32_t i = 0; i < 1000000; ++i) {
// core.next_cases(raw_code, 0);
// }
}

4
src/klotski/graph/CMakeLists.txt

@ -2,7 +2,9 @@ cmake_minimum_required(VERSION 3.0)
include_directories(svg)
# TODO: svg compile together
add_subdirectory(svg)
# TODO: STATIC flag
add_library(graph case.cc graph.cc)
target_link_libraries(graph analyse svg)
target_link_libraries(graph PUBLIC analyse svg)

4
src/klotski/raw_code/CMakeLists.txt

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.0)
add_library(raw_code convert.cc raw_code.cc)
target_link_libraries(raw_code utils)
add_library(raw_code STATIC convert.cc raw_code.cc)
target_link_libraries(raw_code PUBLIC utils)

4
src/klotski/short_code/CMakeLists.txt

@ -2,5 +2,5 @@ cmake_minimum_required(VERSION 3.0)
include_directories(offset)
add_library(short_code convert.cc serialize.cc short_code.cc)
target_link_libraries(short_code utils all_cases)
add_library(short_code STATIC convert.cc serialize.cc short_code.cc)
target_link_libraries(short_code PUBLIC utils all_cases)

2
src/klotski/utils/CMakeLists.txt

@ -1,3 +1,3 @@
cmake_minimum_required(VERSION 3.0)
add_library(utils common.cc)
add_library(utils STATIC common.cc)

10
src/main.c

@ -0,0 +1,10 @@
#include <stdio.h>
#include "klotski.h"
int main() {
// printf("interface test\n");
tmain();
return 0;
}

197
src/main.cc

@ -1,197 +0,0 @@
#include <iostream>
#include "ffi/klotski.h"
//#include "utils/common.h"
//#include "all_cases/all_cases.h"
//
//#include "raw_code/raw_code.h"
//#include "short_code/short_code.h"
//#include "common_code/common_code.h"
//
//#include "core/core.h"
//#include "analyse/analyse.h"
//#include "fast_cal/fast_cal.h"
//#include "graph.h"
//#include "benchmark.h"
//#include <unistd.h>
int main() {
// std::cout << "start test" << std::endl;
// std::cout << (uint32_t)Common::check_range(1, Common::range_reverse(0xA9BF0C00)) << std::endl;
//
// AllCases::build();
// for (const auto &a : AllCases::fetch()) {
// std::cout << a.size() << std::endl;
// }
//
// std::cout << RawCode::from_common_code("1a9bf0c") << std::endl;
// std::cout << RawCode::create(0x0603EDF5CAFFF5E2) << std::endl;
//
// std::cout << CommonCode::create(0x1A9BF0C00) << std::endl;
// std::cout << CommonCode::from_string("1a9bf0c") << std::endl;
// std::cout << CommonCode::from_short_code(4091296) << std::endl;
// std::cout << CommonCode::from_raw_code(0x0603EDF5CAFFF5E2) << std::endl;
//
// std::cout << ShortCode::create(4091296) << std::endl;
// std::cout << ShortCode::from_string("4WVE1") << std::endl;
// std::cout << ShortCode::from_common_code(0x1A9BF0C00) << std::endl;
//
// auto core = Core([](uint64_t code, uint64_t mask) {
// printf("new case -> code = %015lX | mask = %015lX\n", code, mask);
// });
// core.next_cases(RawCode::from_common_code("1a9bf0c").unwrap(), 0);
//
// for (const auto &c : FastCal::resolve(RawCode::from_common_code("1a9bf0c"))) {
// std::cout << c << std::endl;
// }
//
// auto a = Analyse(RawCode::from_common_code("1a9bf0c"));
// for (const auto &s : a.build_resolve()) {
// std::cout << s << std::endl;
// }
// Benchmark::basic_ranges(std::cout);
auto start = clock();
_tmain();
std::cerr << (clock() - start) * 1000000 / CLOCKS_PER_SEC << "us" << std::endl;
// std::cout << "end test" << std::endl;
// BasicRanges::build();
// Benchmark::basic_ranges(std::cout);
// std::cout << std::endl;
// Benchmark::all_cases(std::cout);
// std::cout << std::endl;
// Benchmark::basic_ranges(std::cout);
return 0;
// BasicRanges::build();
// AllCases::build();
// std::vector<RawCode> test_cases;
// {
// AllCases::build();
// std::vector<uint64_t> all_cases;
// for (uint64_t head = 0; head < 16; ++head) {
// for (const auto &range : AllCases::fetch()[head]) {
// all_cases.emplace_back(head << 32 | range);
// }
// }
// for (uint32_t i = 0; i < 100; ++i) {
// test_cases.emplace_back(
// RawCode::from_common_code(all_cases.at(i * 293344))
// );
// }
// }
// std::cout << "test size -> " << test_cases.size() << std::endl;
// std::cout << "wait 3s" << std::endl;
// sleep(3);
// std::cout << "start benchmark" << std::endl;
// auto start_time = clock();
// auto fc = FastCal(RawCode::from_common_code("1a9bf0c"));
// fc.solve();
// {
// auto fc = FastCal(RawCode::unsafe_create(0));
// for (auto code : test_cases) {
// fc.set_root(code);
// fc.solve();
// }
// }
// auto start_time = clock();
// auto a = Analyse(RawCode::from_common_code("1a9bf0c"));
// auto a = Analyse(RawCode::from_common_code("4fea134"));
// auto a = Analyse(RawCode::from_common_code("A5D3AF"));
// a.build();
// auto ret = a.build_until([](uint64_t code) {
// return ((code >> (3 * 0xD)) & 0b111) == B_2x2;
// });
// auto ret = a.build_resolve();
// for (const auto &r : ret) {
// std::cout << r << std::endl;
// }
// std::cout << ret.size() << std::endl;
// std::cerr << (clock() - start_time) * 1000000 / CLOCKS_PER_SEC << "us" << std::endl;
// start_time = clock();
// auto svg_ret = a.backtrack(ret);
// std::cerr << (clock() - start_time) * 1000000 / CLOCKS_PER_SEC << "us" << std::endl;
// auto g = Graph();
// auto svg_data = g.svg_demo(svg_ret);
// std::cout << svg_data << std::endl;
// std::cout << a.layer_export(81).size() << std::endl;
// std::cout << a.layer_export()[81].size() << std::endl;
// std::vector<uint64_t> raw_codes = {
// CommonCode(0xDAAF4CC00).to_raw_code().unwrap(),
// CommonCode(0xDAA7F3000).to_raw_code().unwrap(),
// };
// a.backtrack(raw_codes);
// std::vector<uint64_t> raw_codes = {
// CommonCode("DE77D80").to_raw_code().unwrap(),
// CommonCode("DF6DD80").to_raw_code().unwrap(),
// CommonCode("DF69730").to_raw_code().unwrap(),
// CommonCode("DE76D30").to_raw_code().unwrap(),
// CommonCode("D5AF730").to_raw_code().unwrap(),
// CommonCode("D5B43BC").to_raw_code().unwrap(),
// };
// std::vector<uint64_t> raw_codes = {
// CommonCode("EF697C0").to_raw_code().unwrap(),
// };
// TODO: FATAL ERROR -> don't using mask in Analyse
// a.backtrack(raw_codes);
// std::cout << ShortCode("EP4HZ") << std::endl;
// std::cout << ShortCode(14323231) << std::endl;
// std::cout << RawCode::from_common_code("4fea134") << std::endl;
// std::cout << CommonCode::from_raw_code(0xE58FC85FFEBC4DB) << std::endl;
// std::cout << ShortCode::from_common_code("4fea134") << std::endl;
// std::cout << CommonCode::from_short_code("AXCZN") << std::endl;
// std::cerr << (clock() - start_time) / CLOCKS_PER_SEC << "s" << std::endl;
// std::cerr << (clock() - start_time) * 1000 / CLOCKS_PER_SEC << "ms" << std::endl;
// std::cerr << (clock() - start_time) * 1000000 / CLOCKS_PER_SEC << "us" << std::endl;
// std::cout << "complete benchmark" << std::endl;
// pause();
return 0;
}

6
test/CMakeLists.txt

@ -7,14 +7,14 @@ enable_testing()
################################################################
include_directories(../third_party/md5)
add_library(md5 ../third_party/md5/md5.cpp)
add_library(md5 STATIC ../third_party/md5/md5.cpp)
################################################################
include_directories(../src/klotski/all_cases)
add_executable(test_all_cases all_cases.cc)
target_link_libraries(test_all_cases gtest gtest_main)
target_link_libraries(test_all_cases md5 all_cases)
target_link_libraries(test_all_cases PUBLIC gtest gtest_main)
target_link_libraries(test_all_cases PUBLIC md5 all_cases)
add_test(NAME all_cases COMMAND test_all_cases)
################################################################

Loading…
Cancel
Save