1. Home
  2. Computing & Technology
  3. C / C++ / C#
David Bolton
David's C / C++ / C# Blog

By David Bolton, About.com Guide to C / C++ / C#

Algorithms For Falling Sands

Saturday November 14, 2009
In case you haven't seen it, Falling Sands is a Java app that runs in a browser. It's a toy rather than a game. Just streams of sand, oil, water and salt that fall from the top of the screen and you can divert them with walls, ignite them etc. It's very relaxing and there's no aim but to exercise your creativity. It's similar in that way to the Life cellular automation that has only a few rules but generates complex patterns.

It's implemented in Java but no source code is available. I've been thinking about the algorithms used. There seem to be a few thousand grains of sand, oil, etc that are either falling, moving over other particles (eg forming heaps) or being transformed- water turned green by plants, oil and plants being consumed by fire so probably only a few hundred pixels in motion at one time. It uses about 20-25% CPU of my three year old PC's processing power so is fairly intensive. I imagine there might be lists of static points and moving or transforming points but tracking and processing all these points is a clever bit of programming.

Looking around the web I discovered an open source C++ version by developer Owen Piette and that uses the wx Widgets. I'll see how he does it.

Comments

No comments yet. Leave a Comment

Leave a Comment

Line and paragraph breaks are automatic. Some HTML allowed: <a href="" title="">, <b>, <i>, <strike>

Explore C / C++ / C#
About.com Special Features

Holiday Central

What to eat, where to go, fun things to do and how to save money on the perfect gifts. More >

Family Tech Center

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

  1. Home
  2. Computing & Technology
  3. C / C++ / C#

©2009 About.com, a part of The New York Times Company.

All rights reserved.