15 #include <unordered_map>
20 template <
class state,
class action>
26 std::vector<state> &thePath);
28 std::vector<action> &thePath);
46 std::deque<state> ¤tOpenList,
48 std::deque<state> &nextOpenList,
62 template <
class state,
class action>
66 nodesExpanded = nodesTouched = 0;
73 mOpen1.push_back(from);
77 template <
class state,
class action>
79 std::vector<state> &from)
81 nodesExpanded = nodesTouched = 0;
88 for (
unsigned int x = 0; x < from.size(); x++)
89 mOpen1.push_back(from[x]);
93 template <
class state,
class action>
96 uint64_t n = nodesExpanded;
97 if ((mOpen1.size() != 0) || (mOpen2.size() != 0))
100 if (mOpen1.size() == 0)
102 std::cout << mOpen2.front() << std::endl << mOpen2.back() << std::endl;
103 ExpandLevel(env, mOpen2, mClosed2, mOpen1, mClosed1);
107 std::cout << mOpen1.front() << std::endl << mOpen1.back() << std::endl;
108 ExpandLevel(env, mOpen1, mClosed1, mOpen2, mClosed2);
116 printf(
"Depth %d complete; nodes expanded %lld (%lld new); %lu in memory\n", depth, nodesExpanded, nodesExpanded - n,
117 mOpen1.size()+mOpen2.size()+mClosed1.size()+mClosed2.size());
118 if ((mOpen1.size() == 0) && (mOpen2.size() == 0))
124 template <
class state,
class action>
126 state &from, state &to,
127 std::vector<state> &thePath)
129 nodesExpanded = nodesTouched = 0;
136 mOpen1.push_back(from);
139 uint64_t n = nodesExpanded;
140 while ((mOpen1.size() != 0) || (mOpen2.size() != 0))
142 printf(
"Depth %d; nodes expanded %lld (%lld new); %d in memory\n", depth, nodesExpanded, nodesExpanded - n,
143 mOpen1.size()+mOpen2.size()+mClosed1.size()+mClosed2.size());
145 if (mOpen1.size() == 0)
147 ExpandLevel(env, mOpen2, mClosed2, mOpen1, mClosed1);
151 ExpandLevel(env, mOpen1, mClosed1, mOpen2, mClosed2);
158 template <
class state,
class action>
160 std::deque<state> ¤tOpenList,
162 std::deque<state> &nextOpenList,
165 static std::vector<state> neighbors;
167 while (currentOpenList.size() > 0)
169 state s = currentOpenList.front();
170 currentOpenList.pop_front();
172 if (currentClosedList.find(env->
GetStateHash(s)) != currentClosedList.end())
187 for (
unsigned int x = 0; x < neighbors.size(); x++)
189 if (currentClosedList.find(env->
GetStateHash(neighbors[x])) != currentClosedList.end())
191 if (lastClosedList.find(env->
GetStateHash(neighbors[x])) != lastClosedList.end())
194 nextOpenList.push_back(neighbors[x]);
199 template <
class state,
class action>
201 state &from, state &to,
202 std::vector<action> &thePath)
204 assert(!
"not defined");