across the network: Kyle Brady: Blog  |  Kyle Brady: Fiction  |  Kyle Brady: Status  |  Kyle Brady: Stream  |  Kyle Brady: Projects  |  Kyle Brady: Profile contact
across the internet: on Twitter | on Facebook | more...

Old Content:

MazePath, in Java




This project is similar to ConnectedComponents and KnightJumps, except that the goal is to find the shortest path between a start and end point, according to directional preference (North-East is preferred over South-East, for example) and move weights (diagonals = sqrt(2), not 1).  There are walls, and you're allowed to move diagonally.  Example mazes can be found in the ProjectDescription, with solutions.

This uses Dijkstra's Algorithm to find the shortest path in reverse:  dijkstra() and checkNeighbors().  After this is completed, the path is traveled forwards in order to mark it:  findPath() and compareNeighbors().  However, this code only works on examples up to somewhere near 70x70 input mazes, as the findPath() was written using recursion and it runs out of memory past a certain point.  A more correct version would be to use a looping mechanism to handle large examples.

Finally, I used the Java PriorityQueue, and not myPriorityQueue.java that is mentioned, even though it's included with the source below for reference.

It was due at midnight tonight, and I was done earlier, so this is a scheduled post.

All code is now available via SVN, and a web browsing utility.

Note:  I am not advocating using this code in place of doing your own homework, or in any situation other than pure interest.  However, in the event that you do, I am not responsible for any resultant issues (legal, moral, or ethical) that may arise.  Finally, I am not presenting these as perfect cases, the best way to approach the problems, nor the fastest.  They are, simply, viable solutions.

Old Content posts are leftovers from a less structured, less civilzed era that are kept for posterity.
Kyle can be found on Twitter and MySpace, or reached via email.

submit to reddit Add to Mixx! Share on Facbeook Retweet
Printable Version Printable Version

More Old Content Pieces

see more...


Commenting Rules

The following is a basic set of rules that are enforced for all commenters.

Any violations of these rules will result in comment deletion, user bans, or both.

  1. No excessively foul language.
  2. No racist remarks.
  3. No SPAMing, unrelated linking, or otherwise unnecessary promotion of outside material.
  4. No trolling.
  5. Be respectful.
  6. Be valuable.
  7. Feel free to respond, argue, or counter-point an article - but do so coherently and intelligently.
  8. Use a personal nickname, commenting account, or moniker. Do not use your business' or website name/account.
  9. Do not trackback/pingback to this post unless your content is relevant.
also available as a standalone page

blog comments powered by Disqus
Kyle Brady: Blog
coherent thoughts on diverse topics


Site Navigation:
About Columns Ethics Rules Contact