aboutsummaryrefslogtreecommitdiff
path: root/src/main/solver/solver.h
diff options
context:
space:
mode:
authorCharlie Blake2018-06-20 10:05:47 +0100
committerGitHub2018-06-20 10:05:47 +0100
commitadb28d39b2d693db3d2cfa2a04d56c3942122e64 (patch)
tree1fb5c123465c39b77c05e6857621bc06bfc34b4f /src/main/solver/solver.h
parentMerge pull request #62 from thecharlesblake/fix-broken-tests (diff)
parentReduce memory taken up by dfs datastructures (diff)
downloadmetasol-adb28d39b2d693db3d2cfa2a04d56c3942122e64.tar.gz
metasol-adb28d39b2d693db3d2cfa2a04d56c3942122e64.zip

Merge pull request #63 from thecharlesblake/improve-mem-performance

Improve mem performance

Diffstat (limited to 'src/main/solver/solver.h')
-rw-r--r--src/main/solver/solver.h17
1 files changed, 8 insertions, 9 deletions
diff --git a/src/main/solver/solver.h b/src/main/solver/solver.h
index 961072f..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<lru_cache::item_list::iterator> = boost::none);
- node* parent;
+ node(move);
const move mv;
- std::vector<node> children;
- boost::optional<lru_cache::item_list::iterator> parent_state_iter; // Optional, as dominance moves aren't cached
+ std::vector<move> child_moves;
+ boost::optional<lru_cache::item_list::iterator> cache_state; // Optional, as dominance moves aren't cached
};
explicit solver(const game_state&, uint64_t);
- ~solver();
sol_state run(boost::optional<std::atomic<bool> &> = boost::none);
@@ -35,15 +33,16 @@ public:
int get_states_searched() const;
int get_unique_states_searched() const;
int get_cache_size() const;
- const node& get_search_tree() const;
+ int get_states_rem_from_cache() const;
+ const std::vector<node> get_frontier() const;
private:
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);
+ void set_to_child();
const game_state init_state;
game_state state;
+ std::vector<node> frontier;
int states_searched;
int unique_states_searched;
@@ -53,7 +52,7 @@ private:
int max_depth;
node root;
- node* current_node;
+ std::vector<node>::iterator current_node;
};