home subscribe to email updates subscribe to RSS updates

Experiment: The Amazing Renderer

Quite a while ago, I stumbled across some documentation that described a simple maze generation algorithm. A few days ago I decided to play around with it and this is where I ended up.

Michael Battle - the Amazing Renderer

If you’re familiar with what makes me tick, you’ll know that I really enjoy watching how complex and interesting patterns can evolve from a few simple rules. What you’ll see when you click through, I hope, is precisely that.

The Algorithm

So a little info on the maze drawing algorithm before I discuss what you see unfolding below. For the full explanation make sure you check out this page - it’s what I used. What’s happening in the first demo below is:

  • After starting at position 2,2 on the grid, the algorithm randomly chooses an adjacent target location (up, down, left or right) that is exactly two cells away.
  • After making its choice, it connects its current position with that location.
  • When it successfully makes a choice, it remembers the new location and chooses again.
  • When no locations are available - it has hit a dead end - it grabs the last successful position and tries again.
  • When there are no available positions left to try, the maze is complete.

The result is a maze with exactly one path between any two possible points.

The Twist

I was initially thinking that it would be interesting to bias the maze by using the mouse to influence the likelihood of it growing in a particular direction - effectively enabling the user to paint the maze. This would have been interesting, but nothing special. After chatting about the project with James (the designer at work) I got thinking about how using a greyscale bitmap to influence the maze would be a novel way to make resulting pattern actually resemble something… as you’ll see… it almost does.

So I adjusted the algorithm to refer to a base bitmap and to choose direction based on the lightest (most white) of its current options. More than the end result, I think watching it render is the most interesting part of the experiment - almost hypnotic.

Instructions

Pretty straight forward…

  • There are six images in the following demo - the first being a plain grey canvas and the original random algorithm
  • Click at any time to snap-render the current image (it may take a second or two)
  • Click again to jump to the next image

I’ve included mainly greyscale, high-contrast images as these seem to produce the best results. There is a demo in there with some colour, you’ll see that it still renders in colour bands, though the paths are much shorter.

Check it out (click to progress through the six images)

The next step is to decrease the resolution and play with it using the webcam as input. I think motion may make the visual boundaries more obvious. You’ll probably see it here in a few days.

I hope the demo performs well enough on your machine - it runs much faster locally than through the browser.

Link: The original maze algorithm explained
Link: Lots of info on many more maze algorithms


« Flash Player 9 Penetration
AddThis Social Bookmark Button

Related Posts:

Comments:

Ryan Taylor said,

September 5, 2007 @ 2:32 pm

That’s awesome man; very nice indeed. Reminds me of a cellular automata. Are you familiar with the Wolfram rulesets?

David Novakovic said,

September 6, 2007 @ 6:42 am

Make it look a few pixels around it and choose the path of least resistance. Sorta like what it does now, but looking ahead a few more pixels ;) You’ll probably need to give it a counter so that if it eliminates all options it’ll pick something….

Jono said,

September 6, 2007 @ 9:00 am

Very cool Mike, it runs well on my machine, slow enough to see it working. It would be cool if you could highlight the path through the maze too.

c.moore said,

September 26, 2007 @ 8:14 pm

bella bella…

Really creative way to trace, I wonder if it would offer any advantages to existing computer vision algorithms…

gencha said,

October 1, 2007 @ 9:07 pm

Thanks for the inspiration :)
I took the liberty of implementing my own solution.

http://fuqr.de/dump/Flashmaze.swf?stencil=stencil13.png&delta=2

Michael said,

October 2, 2007 @ 3:49 pm

Hey gencha - nice one!

I really like http://tinyurl.com/2hgrfk - the contrast plays with your eyes.

Great stuff.

hxflyer said,

November 23, 2007 @ 11:19 am

hi,Michael ,great work! I like it very much
I am also interesting in computergraph and flash ,this is my website
http://www.hxflyer.com/

I hope I can make friends with you.
I have watched all of you work ,you are very good~

Michael said,

November 23, 2007 @ 11:48 am

Hey hxflyer - you’ve got some really impressive work too! Congratulations!

I’m sure we’ll be great friends :)

hxflyer said,

December 1, 2007 @ 7:00 am

hi Michael~
It’s really enjoy when watch the maze auto-generate, When I saw you works, I just tried to code it in the same algorithm , I found a very useful infomation from you link and this is my simple works:
http://godson.blueidea.com/archives/2007/5778.shtml

now I am trying to develop a 3D maze ~,still in learning~

Michael Battle - Work & Play » Experiment: Impressionist Image Renderer (again) - Flash and Actionscript Experiments! said,

June 25, 2008 @ 9:51 pm

[…] put, the following demo showcases my impressionist image renderer. It takes an image and, using the maze rendering algorithm that we’ve seen before, plots the detail at three levels of […]

RSS feed for comments on this post · TrackBack URI

Leave a Comment



« Flash Player 9 Penetration