Powered by glolg
Display Preferences Most Recent Entries Chatterbox Blog Links Site Statistics Category Tags About Me, Myself and Gilbert XML RSS Feed
Friday, Mar 23, 2007 - 03:03 SGT
Posted By: Gilbert

- -
Spot The Bug (Not The Dog)

Subject: A code fragment of the A* search (pathfinding) algorithm, coded from scratch.

pa[C+maxcol*R][0] stores the row of the parent node of the node at row R and column C.
pa[C+maxcol*R][1] stores the col of the parent node of the node at row R and column C.
This algorithm desires to begin from the goal node and work backwards, thus printing out the path to the start node.
There is one small mistake that cost me about an hour.
Where is it? (Alvin Award up for grabs!)

while (!(tr==-1 || tc==-1)) {
length++;
printf("NODE: %d %d\n", tr, tc);
if (!(tr == startrow && tc == startcol) && !(tr == endrow && tc == endcol)) {
ma[tr][tc] = 8;
}
trl = tr; tcl = tc;
tr = pa[tc+maxcol*tr][0];
tc = pa[tc+maxcol*tr][1];
}



comments (0) - email - share - print - direct link
trackbacks (0) - trackback url


Next: Projecting Ire


Related Posts:
Bet Or No Bet
Weekend B-activities
The Stars Are Right
GRE
Economics Thus Far

Back to top




Copyright © 2006-2025 GLYS. All Rights Reserved.