Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The book <a href="http://oreilly.com/catalog/9780596005559/" rel="nofollow noreferrer">AI for Game Developers</a> has a very good explanation of A*. I was actually going to write an implementation today... if I do I'll throw the code up here.</p> <p>The code is done, it is too big to put here, so you can grab it from: <a href="https://chaos.bcit.ca/svn/public/astar/" rel="nofollow noreferrer">https://chaos.bcit.ca/svn/public/astar/</a> (self signed certificate, but the server doesn't do anything evil).</p> <p>I followed the pseudo-code in the book for the most part, but I made everything much more object oriented than anything I have seen thus far for A*. </p> <p>You have a Maze that consists of Tiles. Each Tile has a Location and an Obstacle (null if there is no obstacle). </p> <p>You can use a PathFinder (like AStar) to find th shortest path between a given start and end location. You get a Path back which includes the Tiles you need to go through to get from the start to the end. </p> <p>You can change the heuristic calculation by providing a different HeuristicCalculator (the current one just checks to see if there is an Obstacle or not and figures out the shortest number of Tiles to go through, you could add weights to different Obstacles for instance if you don't like the default).</p> <p>The code is license under the LGPL, so if you make changes and distribute the app you have to make the changes available. Feel free to send bug reports/fixes to the email address in the license comment (found in each header). </p> <p>I'll (never did) get around to commenting it after exams, but I think it is pretty straight forward.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload