Build 10 games and learn game development along the way in this fast paced game development course

Get the source code of 12 commercial games, loaded 50+ million times, and learn the secrets of game design

Learn how to make a successful Flash game from a real world example. Fully commented source code

Create realistic Flash physics games from scratch with advanced features, from Angry Birds to Crush the Castle

Breadth-first pathfinding in a randomly generated maze

If you are following the blog for a long time, you should know I love mazes and pathfinding algorithms.

Just to show you a couple of examples, look at the perfect maze generation with AS3, perfect maze generation – tile based version and the basics of pathfinding – animated example.

Today Chevy Ray Johnston shares with us a simple breadth-first search pathfinding system (on a randomly generated maze).

In graph theory, breadth-first search (BFS) is a strategy for searching in a graph when search is limited to essentially two operations: (a) visit and inspect a node of a graph; (b) gain access to visit the nodes that neighbor the currently visited node. The BFS begins at a root node and inspects all the neighboring nodes. Then for each of those neighbor nodes in turn, it inspects their neighbor nodes which were unvisited, and so on. (source: Wikipedia)

Click on 2 black tiles to pathfind between them.

And here is the source code for you to study it:

You can also download the entire project.

Rate this post: 1 Star2 Stars3 Stars4 Stars5 Stars (9 votes, average: 4.78 out of 5)
Loading ... Loading ...
Learn how to make a successful commercial Flash game from a real world example: get the fully commented source code of Globez, a Flash game played millions of times which generated a four figure income. Limited copies available.

Get it now
Be my fan on Facebook and follow me on Twitter! Exclusive content for my Facebook fans and Twitter followers

This post has 2 comments

  1. christian

    on April 5, 2013 at 5:09 pm

    also good to mention that codes are borrowed from wonderfl.net

    http://wonderfl.net/c/yMNn
    http://wonderfl.net/c/fxh8

  2. Lars Eik Grambo

    on October 16, 2013 at 11:20 pm

    Hi. I’m a programming student at Hedmark University College.

    I found this during a random search on pathfinding in flash.
    However, I find understanding your code a bit challenging, since you have not added any documentation. Would you consider adding some documentation in order to make your code more understandable?

Thank you for the download!!

I hope you will find it useful and make something interesting out of it

To keep up to date with the blog, why don't you like my Facebook page and follow me on Twitter?

Want to learn more? Don't miss this:

Learn how to make a successful commercial Flash game from a real world example: get the fully commented source code of Globez, a Flash game played millions of times which generated a four figure income. Limited copies available.

Get it now

×