aboutsummaryrefslogtreecommitdiff
path: root/src/main/solver/solver.h
diff options
context:
space:
mode:
authorCharlie Blake2018-06-13 15:38:20 +0100
committerGitHub2018-06-13 15:38:20 +0100
commitccb1232a48deef855d0e0f3ea0f69382494975cc (patch)
treebcc8fe29ea84abbd6682c1a880064a90dd65f959 /src/main/solver/solver.h
parentMerge pull request #59 from thecharlesblake/paper-tidy-up (diff)
parentAdd default cache capacity of 100,000,000 (diff)
downloadmetasol-ccb1232a48deef855d0e0f3ea0f69382494975cc.tar.gz
metasol-ccb1232a48deef855d0e0f3ea0f69382494975cc.zip

Merge pull request #60 from thecharlesblake/cache-mem-limit

Cache mem limit

Diffstat (limited to 'src/main/solver/solver.h')
-rw-r--r--src/main/solver/solver.h15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/main/solver/solver.h b/src/main/solver/solver.h
index 21b8d6e..bc3af0a 100644
--- a/src/main/solver/solver.h
+++ b/src/main/solver/solver.h
@@ -15,16 +15,17 @@
class solver {
public:
enum class sol_state {solved, unsolvable, timed_out};
- global_cache cache;
+ lru_cache cache;
struct node {
- node(node*, move);
+ node(node*, move, boost::optional<lru_cache::item_list::iterator> = boost::none);
node* parent;
const move mv;
std::vector<node> children;
+ boost::optional<lru_cache::item_list::iterator> parent_state_iter; // Optional, as dominance moves aren't cached
};
- explicit solver(const game_state&);
+ explicit solver(const game_state&, uint64_t);
~solver();
sol_state run(boost::optional<std::atomic<bool> &> = boost::none);
@@ -35,10 +36,9 @@ public:
const node& get_search_tree() const;
private:
- bool revert_to_last_node_with_children();
- void add_children(std::vector<move>&);
- void add_child(move);
- std::vector<move> get_next_moves();
+ bool revert_to_last_node_with_children(boost::optional<lru_cache::item_list::iterator> = boost::none);
+ void add_children(std::vector<move>&, boost::optional<lru_cache::item_list::iterator> = boost::none);
+ void add_child(move, boost::optional<lru_cache::item_list::iterator> = boost::none);
const game_state init_state;
game_state state;
@@ -48,6 +48,7 @@ private:
int backtracks;
int dominance_moves;
int depth;
+ int max_depth;
node root;
node* current_node;