Eric Weeks - personal pages - misc

Weird Grass

This is a baby form of diffusion limited aggregation. See the bottom of the page for links to other simple algorithms like this one.
[home] [research]
[software] [pics]
[misc/links] [about me]

weeks@physics.emory.edu

Balls are dropped from the top of the page. They stick to the bottom of the page, or they can stick to the top of other stuck balls. This is actually easy to program, as you only need to keep track of what is at the top of each column. Balls are only dropped in columns (their coordinates are always integers). It is also easy to keep track of the color of the top ball in each column, and make the new ball the color of the ball it sticks to.

This is a baby version of diffusion limited aggregation. Click here for more information about diffusion limited aggregation.

Much to my disappointment, I discovered that other people know about this algorithm. I came up with this about 6 years ago when I was trying to do DLA very quickly on an Apple 2gs computer, and was getting impatient. However, somebody else put it up on the web first, complete with source code and everything. Their work is discussed here.

HOWEVER: I do know one trick they don't mention on that page. By slightly modifying the algorithm, you can get an affect that looks like this:

What you do is you determine if the falling ball is sticking directly on top of a ball, or if it's sticking on the side. If it's sticking on the side, you have allow the program a fixed chance to try a new position. Thus the program favors stacking balls directly on top of each other. The result is less branching and more thin, tendril like structures (rather than the coral looking result up above). The picture above was generated with a retry chance of 80%.

You can combine these two effects:

This was made by setting the retry chance to 90% for the first 10000 balls, and fixing the color shown to be green. Afterwards the retry chance was lowered to 10% and the program continued, using colors. It makes a nice garden.


Of course, for any of this, you can always change the colors to suit your taste.

This picture was generated using the program "grass.c" I wrote (see below for source code) and "psdraw" for the display.

Software

Click here for the source code to this program. As usual, to compile try "gcc -o grass grass.c -lm".

Click here for more information on psdraw.

Links...


Simple trigonometric plot | Double-trigonometric contour plot | Lissajous figures | Simple diffusion limited aggregation | Spiral triangles | Polar flowers

This page created August 23, 1996.


Current address:
Eric R. Weeks
weeks@physics.emory.edu
Department of Physics
Emory University
Atlanta, GA 30322-2430