aboutsummaryrefslogtreecommitdiff
path: root/src/main/api.cpp
diff options
context:
space:
mode:
authorTom Harley2019-01-27 15:37:06 +0000
committerTom Harley2019-01-27 15:37:06 +0000
commita996283af7c21baaff0e114d58c34db820902c6f (patch)
tree2fe5b6f7a800d4a7b8a65ee345f8c98aa138e36b /src/main/api.cpp
parentSplit code into 3 files (diff)
downloadmetasol-a996283af7c21baaff0e114d58c34db820902c6f.tar.gz
metasol-a996283af7c21baaff0e114d58c34db820902c6f.zip

Reorganise repo

All solvitaire content has been shoved into a subdirectory to tidy up the root of the project. This also means solvitaire is treated similarly to other dependencies of the project, and allows other dependencies to be added easily.

There’s also a lot of other work done here, such as usign a thread pool library to manage the running of the voters.

Diffstat (limited to 'src/main/api.cpp')
-rw-r--r--src/main/api.cpp46
1 files changed, 0 insertions, 46 deletions
diff --git a/src/main/api.cpp b/src/main/api.cpp
deleted file mode 100644
index 1709a49..0000000
--- a/src/main/api.cpp
+++ /dev/null
@@ -1,46 +0,0 @@
-#include <cstdint>
-
-#include <vector>
-#include <string>
-
-#include <stdio.h>
-
-#include "game/move.h"
-#include "game/search-state/game_state.h"
-#include "solver/solver.h"
-
-enum finished_state {
- SOLUTION_FOUND, NO_SOLUTION, TIMEOUT, SOLVER_OOM, CANCELLED
-};
-
-finished_state get_moves(std::vector<move>& moves, game_state& gs,
- uint64_t cache_capacity, uint64_t timeout);
-finished_state get_moves(std::vector<move>& moves, game_state& gs,
- uint64_t cache_capacity, uint64_t timeout) {
- moves.clear();
-
- solver sol(gs, cache_capacity);
- solver::result res = sol.run(std::chrono::milliseconds(timeout));
- if (res.sol_type == solver::result::type::SOLVED) {
- std::vector<solver::node> nodes = sol.get_frontier();
- for (auto &it : nodes) {
- moves.push_back(it.mv);
- }
- }
-
- switch (res.sol_type) {
- case solver::result::type::SOLVED:
- return SOLUTION_FOUND;
- case solver::result::type::UNSOLVABLE:
- return NO_SOLUTION;
- case solver::result::type::TIMEOUT:
- return TIMEOUT;
- case solver::result::type::MEM_LIMIT:
- return SOLVER_OOM;
- case solver::result::type::TERMINATED:
- return CANCELLED;
- default:
- assert(false);
- return NO_SOLUTION;
- }
-}