mirror of https://github.com/dnomd343/klotski.git
Dnomd343
2 years ago
25 changed files with 330 additions and 304 deletions
@ -1,3 +1,4 @@ |
|||||
|
/bin/ |
||||
/.idea/ |
/.idea/ |
||||
/cmake-build-debug/ |
/cmake-build-debug/ |
||||
/cmake-build-release/ |
/cmake-build-release/ |
||||
|
@ -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; |
||||
|
} |
@ -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 |
//#include "benchmark.h"
|
||||
04 05 06 07 |
|
||||
08 09 10 11 |
|
||||
12 13 14 15 |
|
||||
16 17 18 19 |
|
||||
|
|
||||
x1 (%4) => 0 1 2 3 |
//#include <unistd.h>
|
||||
x3 (%4) => 0 3 2 1 |
|
||||
|
|
||||
*/ |
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 |
// std::vector<RawCode> test_cases;
|
||||
111 111 000 000 -> 0000 0011 1111 |
// {
|
||||
|
// 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 |
// auto fc = FastCal(RawCode::from_common_code("1a9bf0c"));
|
||||
111 111 000 000 -> 0000 0011 1111 |
// 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"); |
// auto start_time = clock();
|
||||
|
|
||||
// 0x4FEA13400
|
// auto a = Analyse(RawCode::from_common_code("1a9bf0c"));
|
||||
// # # # @ | 011 011 011 010 => 0100 1101 1011 -> 4DB
|
// auto a = Analyse(RawCode::from_common_code("4fea134"));
|
||||
// * * & @ | 100 111 010 111 => 1110 1011 1100 -> EBC
|
// auto a = Analyse(RawCode::from_common_code("A5D3AF"));
|
||||
// * * & $ | 111 111 111 010 => 0101 1111 1111 -> 5FF
|
|
||||
// . + + $ | 000 001 111 111 => 1111 1100 1000 -> FC8
|
|
||||
// . # ~ ~ | 000 011 001 111 => 1110 0101 1000 -> E58
|
// a.build();
|
||||
// 0x0E58FC85FFEBC4DB
|
// auto ret = a.build_until([](uint64_t code) {
|
||||
|
// return ((code >> (3 * 0xD)) & 0b111) == B_2x2;
|
||||
// 0x1A9BF0C00
|
// });
|
||||
// @ * * @ | 010 100 111 010 => 0101 1110 0010 -> 5E2
|
// auto ret = a.build_resolve();
|
||||
// @ * * @ | 111 111 111 111 => 1111 1111 1111 -> FFF
|
// for (const auto &r : ret) {
|
||||
// $ ~ ~ $ | 010 001 111 010 => 0101 1100 1010 -> 5CA
|
// std::cout << r << std::endl;
|
||||
// $ # # $ | 111 011 011 111 => 1110 1101 1111 -> EDF
|
// }
|
||||
// # . . # | 011 000 000 011 => 0110 0000 0011 -> 603
|
// std::cout << ret.size() << std::endl;
|
||||
// 0x0603EDF5CAFFF5E2
|
|
||||
|
|
||||
|
// 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; |
return 0; |
||||
} |
} |
||||
|
@ -1,11 +1,8 @@ |
|||||
cmake_minimum_required(VERSION 3.0) |
cmake_minimum_required(VERSION 3.0) |
||||
|
|
||||
include_directories(klotski) |
include_directories(klotski/ffi) |
||||
include_directories(benchmark) |
|
||||
|
|
||||
add_subdirectory(klotski) |
add_subdirectory(klotski) |
||||
add_subdirectory(benchmark) |
|
||||
|
|
||||
add_executable(klotski_bin main.cc) |
add_executable(demo main.c) |
||||
target_link_libraries(klotski_bin benchmark) |
target_link_libraries(demo PUBLIC klotski) |
||||
#target_link_libraries(klotski_bin klotski) |
|
||||
|
@ -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) |
|
@ -1,4 +1,4 @@ |
|||||
cmake_minimum_required(VERSION 3.0) |
cmake_minimum_required(VERSION 3.0) |
||||
|
|
||||
add_library(all_cases all_cases.cc basic_ranges.cc) |
add_library(all_cases STATIC all_cases.cc basic_ranges.cc) |
||||
target_link_libraries(all_cases utils) |
target_link_libraries(all_cases PUBLIC utils) |
||||
|
@ -1,4 +1,4 @@ |
|||||
cmake_minimum_required(VERSION 3.0) |
cmake_minimum_required(VERSION 3.0) |
||||
|
|
||||
add_library(analyse analyse.cc backtrack.cc) |
add_library(analyse STATIC analyse.cc backtrack.cc) |
||||
target_link_libraries(analyse core) |
target_link_libraries(analyse PUBLIC core) |
||||
|
@ -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) |
@ -1,5 +1,7 @@ |
|||||
#include "benchmark.h" |
#include "benchmark.h" |
||||
|
|
||||
|
// TODO: remove std::cout output -> only return benchmark status
|
||||
|
|
||||
/// colorful string
|
/// colorful string
|
||||
std::string Benchmark::color_red(const std::string &str) { |
std::string Benchmark::color_red(const std::string &str) { |
||||
return std::string("\033[31m") + str + "\033[0m"; |
return std::string("\033[31m") + str + "\033[0m"; |
@ -1,4 +1,4 @@ |
|||||
cmake_minimum_required(VERSION 3.0) |
cmake_minimum_required(VERSION 3.0) |
||||
|
|
||||
add_library(common_code convert.cc serialize.cc common_code.cc) |
add_library(common_code STATIC convert.cc serialize.cc common_code.cc) |
||||
target_link_libraries(common_code utils) |
target_link_libraries(common_code PUBLIC utils) |
||||
|
@ -1,3 +1,3 @@ |
|||||
cmake_minimum_required(VERSION 3.0) |
cmake_minimum_required(VERSION 3.0) |
||||
|
|
||||
add_library(core core.cc) |
add_library(core STATIC core.cc) |
||||
|
@ -1,4 +1,4 @@ |
|||||
cmake_minimum_required(VERSION 3.0) |
cmake_minimum_required(VERSION 3.0) |
||||
|
|
||||
add_library(fast_cal cal_core.cc fast_cal.cc) |
add_library(fast_cal STATIC cal_core.cc fast_cal.cc) |
||||
target_link_libraries(fast_cal core) |
target_link_libraries(fast_cal PUBLIC core) |
||||
|
@ -1,5 +1,4 @@ |
|||||
#include "klotski.h" |
#include "klotski.h" |
||||
|
|
||||
#include "short_code.h" |
#include "short_code.h" |
||||
|
|
||||
void short_code_speed_up() { |
void short_code_speed_up() { |
@ -1,12 +1,23 @@ |
|||||
#pragma once |
#pragma once |
||||
|
|
||||
|
#ifdef __cplusplus |
||||
extern "C" { |
extern "C" { |
||||
void _tmain(); |
#endif |
||||
|
|
||||
|
void tmain(); |
||||
|
|
||||
|
#ifdef __cplusplus |
||||
} |
} |
||||
|
#endif |
||||
|
|
||||
|
|
||||
|
#ifdef __cplusplus |
||||
extern "C" { |
extern "C" { |
||||
|
#endif |
||||
|
|
||||
void short_code_speed_up(); |
void short_code_speed_up(); |
||||
void short_code_speed_up_fast(); |
void short_code_speed_up_fast(); |
||||
|
|
||||
|
#ifdef __cplusplus |
||||
} |
} |
||||
|
#endif |
||||
|
@ -1,4 +1,4 @@ |
|||||
cmake_minimum_required(VERSION 3.0) |
cmake_minimum_required(VERSION 3.0) |
||||
|
|
||||
add_library(raw_code convert.cc raw_code.cc) |
add_library(raw_code STATIC convert.cc raw_code.cc) |
||||
target_link_libraries(raw_code utils) |
target_link_libraries(raw_code PUBLIC utils) |
||||
|
@ -1,3 +1,3 @@ |
|||||
cmake_minimum_required(VERSION 3.0) |
cmake_minimum_required(VERSION 3.0) |
||||
|
|
||||
add_library(utils common.cc) |
add_library(utils STATIC common.cc) |
||||
|
@ -0,0 +1,10 @@ |
|||||
|
#include <stdio.h> |
||||
|
#include "klotski.h" |
||||
|
|
||||
|
int main() { |
||||
|
// printf("interface test\n");
|
||||
|
|
||||
|
tmain(); |
||||
|
|
||||
|
return 0; |
||||
|
} |
@ -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; |
|
||||
} |
|
Loading…
Reference in new issue