From 0684148d54e8839ced859e63906449368188d46e Mon Sep 17 00:00:00 2001 From: Charlie Blake Date: Mon, 11 Jun 2018 17:23:05 +0100 Subject: Speedup build and add lru cache --- src/main/solver/solver.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/main/solver/solver.h') diff --git a/src/main/solver/solver.h b/src/main/solver/solver.h index 21b8d6e..dedce39 100644 --- a/src/main/solver/solver.h +++ b/src/main/solver/solver.h @@ -15,7 +15,7 @@ class solver { public: enum class sol_state {solved, unsolvable, timed_out}; - global_cache cache; + std::unique_ptr cache; struct node { node(node*, move); -- cgit v1.2.1 From 43a11ee2ee7827290d631698ea25b6724c8a1c29 Mon Sep 17 00:00:00 2001 From: Charlie Blake Date: Tue, 12 Jun 2018 16:57:32 +0100 Subject: Add lru cache with elems limit --- src/main/solver/solver.h | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'src/main/solver/solver.h') diff --git a/src/main/solver/solver.h b/src/main/solver/solver.h index dedce39..73d5e41 100644 --- a/src/main/solver/solver.h +++ b/src/main/solver/solver.h @@ -15,13 +15,14 @@ class solver { public: enum class sol_state {solved, unsolvable, timed_out}; - std::unique_ptr cache; + lru_cache cache; struct node { - node(node*, move); + node(node*, move, boost::optional = boost::none); node* parent; const move mv; std::vector children; + boost::optional parent_state_iter; // Optional, as dominance moves aren't cached }; explicit solver(const game_state&); @@ -35,9 +36,9 @@ public: const node& get_search_tree() const; private: - bool revert_to_last_node_with_children(); - void add_children(std::vector&); - void add_child(move); + bool revert_to_last_node_with_children(boost::optional = boost::none); + void add_children(std::vector&, boost::optional = boost::none); + void add_child(move, boost::optional = boost::none); std::vector get_next_moves(); const game_state init_state; @@ -48,6 +49,7 @@ private: int backtracks; int dominance_moves; int depth; + int max_depth; node root; node* current_node; -- cgit v1.2.1 From fb3e96a333cc9b27529f5d2c7866a2f7c4d43ec2 Mon Sep 17 00:00:00 2001 From: Charlie Blake Date: Wed, 13 Jun 2018 15:08:11 +0100 Subject: Add cache capacity command line option --- src/main/solver/solver.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/main/solver/solver.h') diff --git a/src/main/solver/solver.h b/src/main/solver/solver.h index 73d5e41..bc3af0a 100644 --- a/src/main/solver/solver.h +++ b/src/main/solver/solver.h @@ -25,7 +25,7 @@ public: boost::optional 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 &> = boost::none); @@ -39,7 +39,6 @@ private: bool revert_to_last_node_with_children(boost::optional = boost::none); void add_children(std::vector&, boost::optional = boost::none); void add_child(move, boost::optional = boost::none); - std::vector get_next_moves(); const game_state init_state; game_state state; -- cgit v1.2.1