9 #ifndef HeuristicError_h
10 #define HeuristicError_h
18 template <
class environment,
class state,
typename func>
23 std::unordered_map<state, int> table;
24 std::vector<state> succ;
26 for (
int x = 0; x < regressionDistance; x++)
28 for (
auto iter = table.begin(); iter != table.end(); iter++)
31 if (iter->second == x)
33 e->GetSuccessors(iter->first, succ);
34 for (
auto &itm : succ)
36 if (table.find(itm) == table.end())
46 std::function<int (
const state&,
int)>
DFS;
47 DFS = [h,&s,&f,e,&
DFS,&table](
const state &i,
int depth)->
int {
49 return f(h->
HCost(i, s))?1:0;
50 std::vector<state> neighbors;
51 e->GetSuccessors(i, neighbors);
53 for (
const state &succ : neighbors)
57 count +=
DFS(succ, depth-1);
65 for (
auto iter = table.begin(); iter != table.end(); iter++)
68 if (iter->second == regressionDistance)
71 int res =
DFS(iter->first, forwardDistance);
77 printf(
"%d of %d match condition. Avg %1.2f per state\n", (
int)pass, (
int)total, children/total);