Created
October 5, 2014 04:42
-
-
Save keyboardspecialist/4a0e23ca39be4d7791e6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
size_t | |
ida_star(const Node_t* root, const Node_t* goal) | |
{ | |
size_t bound = fpH(root, goal); | |
size_t t = 0; | |
while(TRUE) | |
{ | |
g_atree = mktree(g_start); | |
g_dbgNode = 1; | |
t = dfs_contour(g_atree, 0, bound); | |
deltree(g_atree); | |
if(t == found) | |
return found; | |
if(t == notfnd) | |
return notfnd; | |
g_dbgIter++; | |
printf("\nIteration [%d] Bound [%d] Nodes [%d]...", g_dbgIter, bound, g_dbgNode); | |
bound = t; | |
} | |
} | |
size_t | |
dfs_contour(Node_t* n, const size_t g, const size_t b) | |
{ | |
size_t min, i = 0, t; | |
g_f = g + fpH(n, g_end); | |
if(g_f > b) | |
return g_f; | |
if(is_goal(n)) | |
{ | |
g_result = n->cost; | |
return found; | |
} | |
min = UINT_MAX; | |
expand(n); | |
for(; i < n->nchild; i++) | |
{ | |
n->childs[i]->cost = n->cost + 1; | |
t = dfs_contour(n->childs[i], g + n->childs[i]->cost, b); | |
if(t == found) | |
return found; | |
if(t < min) | |
min = t; | |
} | |
return min; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment