From 2bad89dfd8d100145526637c5ef33b8f410014df Mon Sep 17 00:00:00 2001 From: Charlie Blake Date: Tue, 19 Jun 2018 16:48:56 +0100 Subject: Reduce memory taken up by dfs datastructures --- src/main/solver/solver.h | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'src/main/solver/solver.h') diff --git a/src/main/solver/solver.h b/src/main/solver/solver.h index ef0709a..14dedc5 100644 --- a/src/main/solver/solver.h +++ b/src/main/solver/solver.h @@ -18,15 +18,13 @@ public: lru_cache cache; struct node { - node(node*, move, boost::optional = boost::none); - node* parent; + node(move); const move mv; - std::vector children; - boost::optional parent_state_iter; // Optional, as dominance moves aren't cached + std::vector child_moves; + boost::optional cache_state; // Optional, as dominance moves aren't cached }; explicit solver(const game_state&, uint64_t); - ~solver(); sol_state run(boost::optional &> = boost::none); @@ -36,15 +34,15 @@ public: int get_unique_states_searched() const; int get_cache_size() const; int get_states_rem_from_cache() const; - const node& get_search_tree() const; + const std::vector get_frontier() const; 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); + void set_to_child(); const game_state init_state; game_state state; + std::vector frontier; int states_searched; int unique_states_searched; @@ -54,7 +52,7 @@ private: int max_depth; node root; - node* current_node; + std::vector::iterator current_node; }; -- cgit v1.2.1