aboutsummaryrefslogtreecommitdiff
path: root/src/main/api.cpp
blob: fc3da3a49d80039d43eb4f81931e73e5585a8567 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include <cstdint>
#include <vector>
#include <string>

#include "game/move.h"
#include "game/search-state/game_state.h"
#include "solver/solver.h"

bool get_moves(std::vector<move>& moves, game_state& gs,
        uint64_t cache_capacity, uint64_t timeout);
bool 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);
        }
        return true;
    } else {
        return false;
    }
}