CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8

Threaded View

  1. #1
    Join Date
    Nov 2003
    Location
    Portland, OR
    Posts
    894

    Shortest distance out of the maze

    Hi everyone:


    This is not a programming language question, but a question about an algorithm. I'm making a small game and in it I need to know the shortest distance inside the maze for the object to get outside of the maze. Please see the picture attached. Here's how I was intending it to work.

    Say, I need to write a function that on the input will get an object's current coordinates - for the picture example, say (3, 1) - and then the function will return a suggested next move for the shortest way out of the maze. For the example, first it should be "right", then on the next function runs it should return 5 times "down", then 2 times "right" and then 7 times "up".

    It sounds like a simple thing for a human being to see, but I can't put my head around programming it.

    Any help would be appreciated!



    PS. If the shortest distance seems to be an issue, I'd take a suggestion for an algorithm for "any" way out of the maze.
    Attached Images Attached Images

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured