Sorry, this page requires the HTML "canvas" element, which your browser doesn't seem to support.

Browsers that should work include the latest versions of Firefox, Google Chrome, Safari and Opera. Version 9.0 of Internet Explorer may also work.

Walk Directions

Sticky Directions

1.00
1.5
100000

The bit-player banner illustrates a process called diffusion-limited aggregation. Particles drift freely through a two-dimensional space until they hit the bottom or touch another particle that is already in contact—directly or indirectly—with the substrate. When thousands of particles are deposited in this way, the result is a feathery or frondlike pattern, resembling a number of structures seen in nature. The colors reflect the particle sequence, from deep purple (earliest) to bright yellow (latest). The deposition process is animated on the front page of the bit-player site; elsewhere the banner is just a static image. Here on this page, you can play with the simulation for yourself.

I wrote about diffusion-limited aggregation in one of my early "Computing Science" columns: "Nature's Algorithms," American Scientist, Vol. 82, No. 3, May-June 1994, pages 206-210 (PDF). Recently, in reading over the source code of programs I wrote while working on that article, I discovered a typo that seemed apt in a story about algorithms and agglomeration, and so I have made it the title of this page.

The JavaScript program given here can reproduce most of the aggregation patterns described in the 1994 article, and others besides. The simulation has two main modes, controlled by the radio buttons at bottom left. In a random walk, each particle chooses a new direction after each step. In a ballistic walk, the initial direction is chosen randomly, but once the particle is launched, it moves in a straight line.

In the case of the random walk, the eight check boxes labeled "walk directions" determine the set of choices for each step. For example, activating just the up, down, left and right boxes outlaws all diagonal moves. In a similar way, the "sticky directions" determine when a moving particle is deemed to touch a stationary one. If you check only the right and down boxes, a particle adheres only to matter below it or to its right.

The ballistic walk is different. The check boxes for random-walk directions are ignored. Instead, each particle is released on a straight-line trajectory with a direction chosen randomly in the 180-degree range from left through down to right. (There's not much point in sending ballistic particles upward, since they'll never return.)

The topmost slider controls the probability that a particle sticks when it touches another particle. The particle-size slider determines the overall scale of the graphic; a setting of 1.0 implies one particle per screen pixel. Ordinarily, the deposit keeps accreting until it reaches 85 percent of the height of the image area, but there is also a limit on the maximum number of particles, governed by the third slider.

The meaning of the "Run" and "Erase" buttons is surely obvious. "Defaults" restores the parameters to match those of the bit-player front page. "Capture" will open a new window or tab with a PNG image of the current canvas, which you can save to a file, in case you'd like a souvenir of your visit here.

Note: It's not hard to find settings that will cause the program to run for a very long time, use lots of cpu cycles, and do nothing, if you're into that sort of thing.