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
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
Last edited by Valdo; 11-12-2012 at 02:51 PM.
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.
Last edited by rogster001; 11-12-2012 at 02:53 PM.
Thought for the day:FLTK: "The most fun you can have with your clothes on.""Are you sure your sanity chip is fully screwed in sir?" (Kryten)
Stroustrup:
"If I had thought of it and had some marketing sense every computer and just about any gadget would have had a little 'C++ Inside' sticker on it'"
"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);
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.