Thread: Pathfinding problem

  1. #1
    Registered User
    Join Date
    Mar 2012
    Posts
    13

    Pathfinding problem

    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.

  2. #2
    Registered User rogster001's Avatar
    Join Date
    Aug 2006
    Location
    Liverpool UK
    Posts
    1,472
    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:
    "Are you sure your sanity chip is fully screwed in sir?" (Kryten)
    FLTK: "The most fun you can have with your clothes on."

    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'"

  3. #3
    Registered User
    Join Date
    Mar 2012
    Posts
    13
    Quote Originally Posted by rogster001 View Post
    crash when it compiles? - it can crash when it runs - so what are you error(s) when you try and build? To save having to read through everything
    "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...

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    Code:
                    // generate a child node
                    m0=new node( xdx, ydy, n0->getLevel(),
                                 n0->getPriority());
                    delete m0;
                    m0->nextLevel(i);
                    m0->updatePriority(xFinish, yFinish);
    Erm, you create it, delete it, then try and use it.
    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.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Pathfinding
    By nasser in forum C Programming
    Replies: 5
    Last Post: 05-20-2011, 12:13 AM
  2. fun with pathfinding
    By BobMcGee123 in forum Game Programming
    Replies: 11
    Last Post: 06-15-2006, 02:28 PM
  3. A* pathfinding: Has anyone here used it?
    By Stan100 in forum Game Programming
    Replies: 2
    Last Post: 10-11-2003, 01:46 PM
  4. AI (Pathfinding)
    By jdinger in forum Game Programming
    Replies: 7
    Last Post: 04-16-2003, 10:20 AM
  5. A* pathfinding
    By minesweeper in forum C++ Programming
    Replies: 3
    Last Post: 11-30-2002, 04:56 PM