From 8c819b9e127d6ca837da214667945634725a66ed Mon Sep 17 00:00:00 2001 From: Tom Harley Date: Fri, 16 Nov 2018 11:09:45 +0000 Subject: wow a thing that works --- src/main/api.cpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 src/main/api.cpp (limited to 'src/main/api.cpp') diff --git a/src/main/api.cpp b/src/main/api.cpp new file mode 100644 index 0000000..fc3da3a --- /dev/null +++ b/src/main/api.cpp @@ -0,0 +1,26 @@ +#include +#include +#include + +#include "game/move.h" +#include "game/search-state/game_state.h" +#include "solver/solver.h" + +bool get_moves(std::vector& moves, game_state& gs, + uint64_t cache_capacity, uint64_t timeout); +bool get_moves(std::vector& 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 nodes = sol.get_frontier(); + for (auto &it : nodes) { + moves.push_back(it.mv); + } + return true; + } else { + return false; + } +} -- cgit v1.2.1