Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I recently found these two gems:

My question is: How are the physics with so many elements efficiently handled? Am I just severely underestimating modern computing power or is it possible to 'just' have a two-dimensional array, each cell of which describes what is placed at the according position and simulate each cell in every step. Or are there more complex things being done like summarising large areas of the same kind into a single data set and separating said set as needed?

Are there any open-source games like this I could look at?

share|improve this question
I've asked similar question about sand simulation on original Stackowerflow The answers might help you. – Evgeny Vinnik Jan 4 '11 at 20:29
up vote 5 down vote accepted

There's certainly quite a few; I used to mod them. Note the links are for forum threads and source downloads. The two I have the best memories of are:

EngimaSand by xavierenigma (C++ | Java ) The Java one is newer.

BurningSand by sieben (C++) This one is very fast physics-wise.

The site is unfortunately close to death, but there's several threads here about physics.

EDIT: For anyone interested, I have mediafire'd the Java source for EnigmaSand here.

share|improve this answer
Much appreciated. Links are down at the moment, though. I'll try it again in a few hours. – Marc Müller Jan 4 '11 at 21:22
They are? They're all working fine for me. – The Communist Duck Jan 4 '11 at 21:23
Mediafire uploaded and edited into the answer. – The Communist Duck Jan 4 '11 at 21:42

The physics in these games is simulated by use of a system based on a complex cellular automaton. It's significantly more complicated than the one used in, say, the Game of Life, and incorporates features that mean it's probably not a proper CA, but it's still relatively simple to calculate and has been for years. Not to go into too much detail, but the complexity of the algorithm is going to be quite small, perhaps even O(area).

It looks like there's also some swarm intelligence in there, which is also surprisingly efficient for the interesting effects it can create.

share|improve this answer
"and incorporates features that mean it's probably not a proper CA"...what do you mean by that? Do these CA's only differ on having more rules or something more? – Gastón Jan 6 '11 at 2:09
A canonical CA has each cell's state in generation N+1 defined by a function that depends on the states of the cell's close neighborhood in generation N, and the function is generally the same for each cell. Many "powder" games contain things like boids or constraint-based physics objects, which don't really fall under this definition. I doubt they're coded entirely as a CA. Even if they are, at some point, the neighborhood gets large enough and the transition function gets complex enough that you're really not dealing with a CA. – Gregory Avery-Weir Jan 7 '11 at 16:50
Good answer and comment Gregory, thanks for your insights. – Arcane Engineer Oct 5 '11 at 10:40
Although cellular automaton might be part of it, it's definitely not the whole answer. There is a fluid solver in there as well, which is what makes it look so 'realistic' – bobobobo Feb 13 '13 at 0:29
@bobobobo: Yeah, it definitely goes beyond the bounds of proper cellular automata. – Gregory Avery-Weir Feb 13 '13 at 14:14

Many years ago Jos Stam started putting out his source code for fluid solvers. There is a very short bit of code that sets up a grid and solves the Navier-Stokes equations very fast. The full source is available on his page as well.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.