Had to make a path finding program using the a* algorithm but when I compile it just crashes, anyone got any idea where I'm going wrong?
Cheers
Printable View
Had to make a path finding program using the a* algorithm but when I compile it just crashes, anyone got any idea where I'm going wrong?
Cheers
crash when it compiles? - it can crash when it runs - so what are your errors when you try and build? To save having to read through everything
enclose your switch cases in curly braces - and dont stuff things onto one line like that just for the sake of saving a bit of file length.
It is advisable to enumerate your directions (the result of rand) so you are not just checking for = 0 = 1 = 2 etc, and instead can read = UP_LEFT = UP = UP_RIGHT etc, its just better practice that way - despite it being failry clear what is going on
Storing the result of division in an integer is not a good idea unless you are certain that the rounding does not impact what you need to do.
"Windows has triggered a breakpoint in algorithm.exe.
This may be due to a corruption of the heap, which indicates a bug in algorithm.exe or any of the DLLs it has loaded.
This may also be due to the user pressing F12 while algorithm.exe has focus.
The output window may have more diagnostic information."
But I can't see why it's breaking...
Erm, you create it, delete it, then try and use it.Code:// generate a child node
m0=new node( xdx, ydy, n0->getLevel(),
n0->getPriority());
delete m0;
m0->nextLevel(i);
m0->updatePriority(xFinish, yFinish);