aboutsummaryrefslogtreecommitdiff
path: root/cpp/examples
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano@tronto.net>2025-12-14 15:12:36 +0100
committerSebastiano Tronto <sebastiano@tronto.net>2025-12-14 16:09:31 +0100
commitbcd52547af58b15868e24f3904e307548d1fd505 (patch)
treecda0a871f65575bb15fb4536c7b103c13caf433e /cpp/examples
parent21fdf9697ddfab0a9c082a91ae0a79b1b574774c (diff)
downloadnissy-core-bcd52547af58b15868e24f3904e307548d1fd505.tar.gz
nissy-core-bcd52547af58b15868e24f3904e307548d1fd505.zip
Cleanup, update documentation, fix examples
Diffstat (limited to 'cpp/examples')
-rw-r--r--cpp/examples/solve.cpp (renamed from cpp/examples/solve_h48h3k2.cpp)18
1 files changed, 9 insertions, 9 deletions
diff --git a/cpp/examples/solve_h48h3k2.cpp b/cpp/examples/solve.cpp
index 2a226ba..c25a088 100644
--- a/cpp/examples/solve_h48h3k2.cpp
+++ b/cpp/examples/solve.cpp
@@ -28,24 +28,24 @@ int main() {
28 std::cin >> maxmoves; 28 std::cin >> maxmoves;
29 29
30 // Load the solver 30 // Load the solver
31 auto h48h3k2 = std::get<nissy::solver>(nissy::solver::get("h48h3k2")); 31 auto h48h3 = std::get<nissy::solver>(nissy::solver::get("h48h3"));
32 std::filesystem::path tableDir("tables"); 32 std::filesystem::path tableDir("tables");
33 std::filesystem::create_directories(tableDir); // Ignored if dir exists 33 std::filesystem::create_directories(tableDir); // Ignored if dir exists
34 std::filesystem::path tableFile("tables/" + h48h3k2.id); 34 std::filesystem::path tableFile("tables/" + h48h3.id);
35 35
36 // If the table is not present, generate it 36 // If the table is not present, generate it
37 if (!std::filesystem::exists(tableFile)) { 37 if (!std::filesystem::exists(tableFile)) {
38 std::cout << "Data for h48h3k2 solver was not found, " 38 std::cout << "Data for h48h3 solver was not found, "
39 << "generating it..." << std::endl; 39 << "generating it..." << std::endl;
40 auto err = h48h3k2.generate_data(); 40 auto err = h48h3.generate_data();
41 if (!err.ok()) { 41 if (!err.ok()) {
42 std::cout << "Unexpected error! Error code: " 42 std::cout << "Unexpected error! Error code: "
43 << err.value << std::endl; 43 << err.value << std::endl;
44 return 1; 44 return 1;
45 } 45 }
46 std::ofstream ofs(tableFile, std::ios::binary); 46 std::ofstream ofs(tableFile, std::ios::binary);
47 ofs.write(reinterpret_cast<char *>(h48h3k2.data.data()), 47 ofs.write(reinterpret_cast<char *>(h48h3.data.data()),
48 h48h3k2.size); 48 h48h3.size);
49 std::cout << "Table generated and written to " 49 std::cout << "Table generated and written to "
50 << tableFile << std::endl; 50 << tableFile << std::endl;
51 ofs.close(); 51 ofs.close();
@@ -54,10 +54,10 @@ int main() {
54 else { 54 else {
55 std::cout << "Loading data table from file" << std::endl; 55 std::cout << "Loading data table from file" << std::endl;
56 std::ifstream ifs(tableFile, std::ios::binary); 56 std::ifstream ifs(tableFile, std::ios::binary);
57 h48h3k2.read_data(ifs); 57 h48h3.read_data(ifs);
58 ifs.close(); 58 ifs.close();
59 std::cout << "Data loaded, checking table..." << std::endl; 59 std::cout << "Data loaded, checking table..." << std::endl;
60 auto err = h48h3k2.check_data(); 60 auto err = h48h3.check_data();
61 if (!err.ok()) { 61 if (!err.ok()) {
62 std::cout << "Error reading data table from file! " 62 std::cout << "Error reading data table from file! "
63 << "Error code: " << err.value << std::endl; 63 << "Error code: " << err.value << std::endl;
@@ -67,7 +67,7 @@ int main() {
67 } 67 }
68 68
69 // Solve 69 // Solve
70 auto solve_result = h48h3k2.solve(c, nissy::nissflag::NORMAL, 70 auto solve_result = h48h3.solve(c, nissy::nissflag::NORMAL,
71 0, maxmoves, 1, 20, 8, NULL, NULL); 71 0, maxmoves, 1, 20, 8, NULL, NULL);
72 72
73 // Write the result 73 // Write the result

Generated with cgit - Back to sebastiano.tronto.net