
Sandspiel – A falling sand game built in Rust and WebGL - 15DCFA8F
https://sandspiel.club/
======
chime
Wow! This thread brings back some fond memories. Long ago, I came across a
tiny Java applet linked on Fark to a Japanese forum post. Everyone loved it
but I found it annoyingly small. It was barely 300px x 400px. I had been
coding my senior thesis in Java and had recently learned how to use a Java
decompiler.

So I downloaded the applet, decompiled it, spent a few minutes figuring out
exactly where the dimensions were setup, changed them to 960x640, compiled it
all, and hosted it on my site:
[http://chir.ag/stuff/sand/](http://chir.ag/stuff/sand/)

I'm always apprehensive about taking any credit for the Falling Sand Game
because I DID NOT make it but I'm always glad to see it in the wild. First it
was Fark, then a few months later Digg, then Reddit. At one point someone
created a Wikipedia page linking to the enlarged version I was hosting, then
it got deleted as not-notable, then someone wrote a song about FSG, then a
hundred different versions of FSG popped up, many non-Java and functioning
much better than the applet, then the Wikipedia page came back up.

I've long stopped getting giddy emails from office slackers about how much
time they waste on my site but even though I didn't really create this amazing
game/toy/zen-garden, I feel lucky to have been a tiny part of the arcane pop-
culture movement.

~~~
faitswulff
Wow, what a great look into internet history. Do you still have the original
forum post? I wonder who the original author was.

~~~
glaberficken
Maybe this is the original author? World of Sand by DOFI (2005)

[http://ishi.blog2.fc2.com/blog-
entry-158.html](http://ishi.blog2.fc2.com/blog-entry-158.html)

can anyone find an earlier falling sand type game?

edit: Found this after some googling:
[http://cowboyprogramming.com/2007/03/05/falling-sand-game-
fr...](http://cowboyprogramming.com/2007/03/05/falling-sand-game-from-
the-80s/)

very interesting! (includes assembly source code)

~~~
tom_
There was a similar Archimedes program printed in Acorn user in the March 1992
issue.

Atari ST game, in the same genre, from the Jan 1993 issue of ST Format:
[https://www.youtube.com/watch?v=SHZB9nIzZ64](https://www.youtube.com/watch?v=SHZB9nIzZ64)

~~~
glaberficken
Fantastic! For those wondering how such a program was printed (and then had to
be typed by hand from the magazine), here's a scan cap of the page in question
[https://imgur.com/a/Mng21o3](https://imgur.com/a/Mng21o3)

And here you can find the full issue:
[http://8bs.com/aumags.htm](http://8bs.com/aumags.htm)

------
dTal
A nice bit of web programming. The smoke effects look cool. Pity solids don't
conduct heat - the first thing I always try and do in these is boil a pot of
water.

If you've never seen this kind of thing before, the canonical PC example is
The Powder Toy, which is so amazing I wish there a 3D Minecraft-like version.
But it's really CPU-heavy even in 2d.

~~~
make3
also.. mites don't reproduce..

~~~
swirepe
and water doesn't pool

~~~
kristianp
and the water turns into plants as fast as fire burns the plants.

~~~
jabl
And the water seem spectacularly incapable of putting out fires.

~~~
heavenlyblue
There's no way to put out a fire burning on top of the cloner.

~~~
heavenlyblue
I mean - if you already managed to put plants in the cloner.

------
ullarah
This is great, I love falling sand games.

The only downfall is that the Pythagorean Cup didn't work?

[https://i.imgur.com/ejqBwR4.png](https://i.imgur.com/ejqBwR4.png)

[https://sandspiel.club/#cCZB5Un0exri2UajMjcu](https://sandspiel.club/#cCZB5Un0exri2UajMjcu)

~~~
lfam
Are there any falling sand games where it does work?

~~~
HoppyHaus
The Powder Toy with water equalization

~~~
Doxin
The Powder Toy wouldn't simulate the vacuum required for it to work. It'd get
closer than most other falling sand games if you turn on water equalisation
though.

------
phaedrus
Several years ago I wrote a falling sand game for the Parallax Propeller chip,
which is an 8-core microcontroller. One core was needed to drive the video
output, and I had up to 7 other cores running a simple ruleset:

1\. If a sand pixel had an empty pixel below it, exchange them. 2\. If more
than two sand pixels are stacked but there's space to the side, kick one sand
grain out to that side.

These rules were enough to make the sand form simple hill shapes. All of the
cores bash on the same shared memory array; rather than use locks or
synchronization I just had each core start in a different column of the screen
and all move left to right by columns - in theory there should be enough
separation that they'd never conflict.

However - and this is the part I thought interesting to post about - somehow
after a few seconds or minutes the 7 cores would catch up with each other and
start running in lockstep (effectively reducing the speed of the simulation to
equivalent of 1 core).

Barring a bug that was simply crashing cores, what I think was happening was
that not every control flow path took the same number of cycles, so a core
processing a column with a complex sand pattern might slow down and allow
another core to catch up to it. Once two cores were operating on exactly the
same data, they'd be doing the same deterministic logic on the same inputs and
writing out the same result, effectively just duplicating the work in
lockstep.

------
NextHendrix
I wasted hours on these types of games back in the flash era, people were
constantly releasing new ones with more types of sand and various effects and
combinations, its a shame that whole segment of internet history was
deprecated along with flash, good times.

~~~
hyperpallium
Well... castle crusher "became" angry birds... so we've got that going for
us...

~~~
lostsock
I think you mean Crush the Castle :)
[https://en.wikipedia.org/wiki/Crush_the_Castle](https://en.wikipedia.org/wiki/Crush_the_Castle)

------
tapirl
What's the performance difference from a pure JavaScript version?

Recently, I made a particle game which originally planned to be implemented
with WASM. However, I decided to implement it with pure JS firstly. The result
is some surprising that the JS version runs so smoothly that I think a WASM
version is not essential any more.

~~~
zaq_xsw
I'm interested in this too. The dev would probably have a good answer since
they previously made a pure JS sand game too:
[https://github.com/MaxBittker/dust](https://github.com/MaxBittker/dust)

------
GolDDranks
This brings to mind a game that many people here might enjoy once it gets
released – Noita: a magical action roguelite where every pixel is physically
simulated.

[https://store.steampowered.com/app/881100/Noita/](https://store.steampowered.com/app/881100/Noita/)

(Disclosure: it's being developed by a bunch of my old co-workers.)

~~~
glaberficken
My big hope for this game is that it does not go the Spelunky way in terms of
game design. In Spelunky you have all these toys that are fun to use, but the
punishment for using them "wrong" just takes all the fun out of the game.

I hope they can find a balance that allows you to take risks with the physics
interactions without loosing your entire run.

------
jasonkester
Fun feature: on mobile, if you drop a bunch of lava on a bunch of fireworks,
your phone gets hot.

Nice work.

------
napsterbr
Brings me back some good old memories from this game:

[https://dan-ball.jp/en/javagame/dust/](https://dan-ball.jp/en/javagame/dust/)

------
lhball
Got tired of all the phalic-volcanoes so I made something nice for you
[https://sandspiel.club/#2scDpZpyMACGp65FrkPT](https://sandspiel.club/#2scDpZpyMACGp65FrkPT)

~~~
carbocation
What I enjoy about this one is that it's a beautiful scene... that immediately
ignites when you press play :)

------
btschaegg
This very strongly reminds me of a game called "Hydroxis" (or at least I think
so) for the Amiga. You started with water pooling in some cavity in an
otherwise static level and had to move it to a target location by means of
enabling and disabling some blocking segments in the level. That was fun!

I had remembered that one a decade or so ago and it turned out to be the
single hardest thing I tried to find for my WinUAE collection :-(

~~~
exlurker
This must be it; Hydrocis:
[http://www.lemonamiga.com/?game_id=4277](http://www.lemonamiga.com/?game_id=4277)

~~~
btschaegg
YES!

Funny how one misremembered character can make an internet search _that_ hard.
:-)

You most certainly made my day! Thank you very much!

------
ummonk
Grow some plants. Light a fire. Frantically try to put it out with water and
watch helplessly as the plants grow due to water, providing more and more fuel
for the growing flames, until you have an unstoppable conflagration on your
hands. There must be some moral lesson to learn from this.

~~~
KnightOfWords
People in flammable houses shouldn't complete the fire triangle?

------
jetrink
Make a lake of oil, set it aflame and then pour water on it. A small amount of
water causes the burning oil to flare and spread. A large amount of water
extinguishes the fire. Very cool!

~~~
mindcrime
_A small amount of water causes the burning oil to flare and spread. A large
amount of water extinguishes the fire._

Interestingly enough, while we've all been taught "never use water on an oil
fire", this is actually pretty similar to real life. Generally speaking, using
water on a flammable liquids fire will just spread the fire and make it worse.
But if the fire is small enough and the application rate of the water is
sufficient, you can sometimes extinguish such a fire with water.

Note: do NOT take this as advice to ever try to extinguish a kitchen fire or
something like that with water. When I talk about "application rate" above,
I'm thinking of the 100+ gallons per minute you get from a 1-3/4" (or larger)
handline from a fire engine. If your frying pan catches on fire, call 911 and
then use a class B rated fire extinguisher, or smother the fire by putting a
lid on the container. If you have any doubts whatsoever about your ability to
extinguish the fire, exit the structure and let the fire department handle it.

~~~
BenjiWiebe
For an oil fire in the kitchen, use baking soda.

~~~
mindcrime
Baking soda can work, but it can take quite a lot of it. Depending on how big
the fire is, you might not have enough in your kitchen. It may also be packed
away in a cabinet somewhere out of reach. Of course the same might be true of
the fire extinguisher as well... :-(

------
sorenjan
I wish fire or lava would make steam out of water, but I love the smoke
effect. It was a really nice surprise when the rest of it was so low
resolution, great combo.

~~~
freehunter
My wish is always to create a self-sustaining environment with clouds and
rainfall but it never works...

~~~
GistNoesis
Have you tried the "cloner" type ? I managed clouds that rain, using a cloner
with ice above a cloner with fire. The cloner with fire make the ice melt
which release some water which reduce the fire and help the plant grow. Once
the plant below grow enough to reach the fire almost all the plant burn and
the cycle begins again. You can then add mites which will eat the plants and
reproduce and be almost destroyed by the cycling catastrophe yet survive
thanks to the wanderers. Mites usually eat the bottom plants so sometimes for
plants to start again from the ground you need to accumulate enough water to
form a lake which will reach the preserved from the mites plants. Once the
lake reach the plants it is consumed by them, and allow mites to have close to
the ground food.

~~~
jdlshore
Here's my take on this idea:

[https://sandspiel.club/#52oSclzynCddZWyelRsm](https://sandspiel.club/#52oSclzynCddZWyelRsm)

------
gambler
If you like this game, you might find this project interesting:

[http://tinlizzie.org/~ohshima/shadama2/live2017/](http://tinlizzie.org/~ohshima/shadama2/live2017/)

[http://tinlizzie.org/~ohshima/shadama2/](http://tinlizzie.org/~ohshima/shadama2/)

It's a bit similar, but uses GPU and spawns millions of particles. On the
other hand, it's less of a sandbox and more of a demo. You can write your own
code in the browser too, but it's a bit tricky to program, because it compiles
to shader language and it has some weird limitations.

------
t3hprogrammer
This is awesome! A few years ago I built a more rudimentary version of a
falling sand game with just Javascript and WebGL:
[http://ericleong.me/sand.js/](http://ericleong.me/sand.js/)

I tried to embed the "scripting" language as a texture in WebGL to keep the
implementation very fast (note that every pixel is a cell), but I think I
worked myself into a corner.

Source code here:
[https://github.com/ericleong/sand.js](https://github.com/ericleong/sand.js)

------
jacobdp
Any source code for this? I'm learning rust right now and it would be really
cool to see how this was made

~~~
Impossible
[https://github.com/maxbittker/sandspiel](https://github.com/maxbittker/sandspiel)

------
spdustin
Once I realized that pausing the FSG was a thing...

[https://sandspiel.club/#Mt35KuNUFTZW9ITyWDxe](https://sandspiel.club/#Mt35KuNUFTZW9ITyWDxe)

------
tokyodude
This is a perfect example of why I'm still in Chrome. At least for me this
runs at 60fps in Chrome on my Mac but 30-45 in Firefox. I see this often in
animated sites.

~~~
zzleeper
Another data point: on Windows I get 60 fps on both Chrome and FF

~~~
tokyodude
That would arguably mean your machine is fast enough to get 60fps since the
browser basically throttles to 60. So a slower machine would show the
difference but an even faster machine would still show 60

~~~
justwalt
In my experience, FF performance is much better in Windows than in Mac or
Linux, unfortunately.

------
city41
Thousands of particles and the worst frame rate I saw on my iPhone 6 was
25fps. Impressive.

------
lousken
Not seeing vaporizing water when lava was put into it was a bit of a bummer,
otherwise it's great

------
Ezku
Love the performance, no trouble with 60fps. The swirly wind, fire, and smoke
effects are beautiful! It’s also the only part here with which I would not
know how to get started building, could anyone share their thoughts on the
implementation?

~~~
preommr
I was interested in this too so I took a dive in.

The smoke effects are based on another project about Fluid simulation
[https://github.com/PavelDoGreat/WebGL-Fluid-
Simulation](https://github.com/PavelDoGreat/WebGL-Fluid-Simulation)

It also has a working demo with controls (it's collapsed by default I think,
and kind of hard to see if you're not looking for it in the upper right hand
corner). It's pretty astonishing how beautiful it is.

As far as I can tell, the filters and the code isn't too complicated. I am
just wondering how they got those values to begin with because that's where
the real magic is. There are some references there as well. One of them links
to a gpu gems page that I am pretty sure I've seen before that looks really
similar to this. So it's really just incremental improvements from previous
works. But this version looks a lot more polished.

------
flaque
This feels wayyy smoother than I remember this game being.

~~~
mlindner
Because this is in Rust and WebGL, not flash.

~~~
black-tea
No, it's because computers are many times faster.

~~~
kozak
Actually, both.

------
nagyadam2092
A question to the creator: is the fungus growing respecting the rules of
Conway's Game of Life? It seems very much like that. Very nice app!

------
mlindner
My current map set up, paused.
[https://imgur.com/71p1H8W](https://imgur.com/71p1H8W)

~~~
pluma
Try setting a gas cloner on fire.

------
devilmoon
Holy shit, I remember playing something very similar to this for hours on end
in the early 90s as a kid; it might have even been an early version of the
powder toy (another user mentioned it), not entirely sure, but regardless this
thread is making me go back down memory lane and now I'd love to get into the
insides of a game like this one and understand how it works!

~~~
Doxin
You might have played one of Burning sand II, WXSand, or danbal. There's a
fairly rich history of these games, but The Powder Toy basically ate everyones
lunch at this point.

------
Tade0
You can get some interesting effects if you put a grid of one-pixel cloners,
make them clone gas and put some lava at the bottom.

------
Semaphor
Literally unplayable, exploding gas goes through thick solid walls without
even damaging the wall.

Awesome game, I love the options :)

------
emilfihlman
There's an off by one error on sides, fire and it's effects can go along the
sides.

------
Kye
You can create a little self-sustaining motion with a cloner covered in
something that falls over a lake of acid.

[https://sandspiel.club/#IbQHF3edJmCy1dLJAWO8](https://sandspiel.club/#IbQHF3edJmCy1dLJAWO8)

------
lstodd
This is great. I'm almost tempted to redo this with believable thermodynamics.

~~~
nichochar
lol the arrogance of your phrasing is weird. Just stick with the compliment,
and then maybe: I think we could improve thermodynamics, not "I'm almost
tempted", which sounds like "I'm a god, and could really outdo this but I'm
not sure I have time since I'm SO important and busy".

~~~
Retr0spectrum
Doesn't really come across as arrogance to me, just interest in the project.

~~~
mannycalavera42
same

------
glitchc
Working in Safari on iOS 12

------
itsjustme321
Reminds me of The Powder Toy, which is great by the way, lots of fun!

------
sj4nz
Drop oil on lava.

The effect is worth it.

~~~
PavlovsCat
have you tried dust yet?

~~~
bsg75
Dust is volatile, and too much fun:
[https://sandspiel.club/#l9z7gueXwwTAHj6hI0Zh](https://sandspiel.club/#l9z7gueXwwTAHj6hI0Zh)

------
jl6
I remember watching Confetti Factory on After Dark, which I think of as a
primitive precursor to this. Must have been very early 1990s. Any earlier
examples?

------
johnisgood
I love fungus. It makes the plant grow. Pour some acid on it, it will regrow!
On the other hand, fire is pretty destructive.

You know what feature I miss? Fast-forwarding!

------
neves
Does this game have any objective? I didn't get it.

~~~
detaro
no, it doesn't have an objective. It's a sandbox game.

------
mcnichol
This was mesmerizing. Well done, thoroughly enjoyed it.

------
avip
Wind effect is beautiful and looks like a Julia set.

------
anoncow
Really liked lava and fire. I don’t know why gravity doesn’t affect the blue
stuff. Can you disable page swipe gestures on mobile chrome?

------
ok-repl
I've always been fascinated by these simulations. Can anybody give a rough
overview of how these (I guess?) fluid simulations work?

------
mgoetzke
Great ! Was just looking for something like this for a snow effect. I used to
do something with falling snow on text for Christmas.

------
sadjad
It's weird, but I can't share the link on Twitter, and goo.gl shortlink
doesn't work either.

Does anyone have the same problem?

------
mattdeboard
Weird, I was just looking at this today. Very cool project! I have a feature
idea on my stack of ideas I hope to get to

------
windlessstorm
Site is got down of big HN hug I guess

------
skykooler
This is excellent fun. I'm kind of curious though as to why blowing wind at
the dust ignites it?

~~~
b4d
Check for dust explosion. Pretty dangerous event in silo storages etc.

~~~
skykooler
That's usually caused by a spark or something though, not just air movement. I
understand why fire/lava ignites the dust, but not why the wind does.

------
shittyadmin
The smoke and explosion effects are amazing, better than any other FSG I've
tried. Very cool.

------
ddingus
I had fun with this. Great effects. Lava, lol.

I got a lot going, 25fps Samsung Note 8, Power Saving Mode

32 fps Performance Mode

------
Santosh83
Will activating WebRender improve framerates?

Not that it needs improving anyway... just curious.

~~~
pcwalton
WebRender is a mapping from CSS (and perhaps SVG and Canvas 2D in the future)
to the GPU. But this game is already built on the GPU, so there's nothing for
WR to do. :)

------
gigatexal
Fun little game! 42FPS on my iPhone X, too. And best of all no excessive heat

~~~
SlowRobotAhead
Weird, I am getting almost all 60fps on iphone8.

------
ecabuk
Lava cannot melt ice? :D

------
profalseidol
Ice can hold lava?

btw, adding oil over lava produces a very cool smoke effect.

------
miguelmota
This is incredible. Runs flawlessly and surprisingly smooth

------
nablaoperator
Reminds me of Clonk!

------
jtsiskin
I get 1-2 FPS running this in Chrome on macOS Mojave.

~~~
sgt
I'm getting good speeds but it seems terribly inefficient. Taking 60% CPU and
now it's busy spinning up my fan. I have an i7 MBP.

------
jeffrallen
Lava should make water turn to gas and blow up!

------
bredren
I like the smoke when you burn the fungus.

------
geitir
This is fun

------
omani
nothing happens on mobile

~~~
sitzkrieg
Working fine in Firefox Android

~~~
hyperpallium
Not for me (android firefox). If webGL uses facilities not available on your
GPU, it well doesn't work. That's likely it, and we've just not seeing the
error message.

e.g. my phone lacks float textures (i.e, to render-to-texture to output
floating point calculations), so this fluid simulation doesn't work
[http://jamie-wong.com/2016/08/05/webgl-fluid-simulation/](http://jamie-
wong.com/2016/08/05/webgl-fluid-simulation/) (not a guess; I've been through
the source, reimplemented some in java)

------
Evidlo
Fun, but a bit blurry.

------
hujun
create some plants, and drop some seed on it

------
gworf
This is fun!

------
hyperpallium
Is it really a "game" if there's no goal or "win" condition? Or is it a
"webtoy" or "simulation" (or... "sandbox". Think it's a sandbox).

~~~
deathanatos
It is unfortunate that you're downvoted. At one point, there was an article on
HN discussing games, including what made a "game" a "game" — and one of the
article's requirements was that there must exist some risk of losing.
Otherwise, you're just messing around or following predefined steps towards an
end, but there is no challenge. Not that that can't _entertain_ , but plenty
of things entertain that aren't games. (E.g., a movie.)

The article also discussed some weird things that existed outside of the
definition that the article arrived at, such as ClickerHeros and similar
"grinding" "games".

(I wish I could find a link to it. Perhaps someone else here remembers and can
find it…)

~~~
fenomas
Not unfortunate at all; arguing definitions is rarely useful or interesting,
and "game" has dozens of worthy contenders that disagree with GP and with the
article you read.

E g.: Sid Meier's famous definition: "a series of interesting decisions". (But
what would he know?)

~~~
hyperpallium
Says "arguing definitions is rarely useful"; argues a definition usefully. :-)

FWIW I asked the question because I'm designing a simulation "game" without
explicit win-conditions, but I'm concerned it won't be very engaging without
them. e.g. Minecraft added monsters (to survive the night), and the
enderverse.

~~~
fenomas
Don't get me wrong, the question of whether this or that game is better with
or without win conditions is perfectly interesting. It's just the raw "is it a
game or not?" that's not useful. It's like asking whether comic books are
books - the answer is "yes under some definitions, no under others", simple as
that.

For the case of your game[0] specifically, one option is to expose game stats
that the player can form their own challenges around. E.g. if the game UI
shows how many times you've jumped, that implicitly lets the player form "do X
without jumping more than Y times" sorts of challenges, etc. Or the more
formal way to do it is like e.g. Minecraft achievements - there's no "win
condition" for putting a saddle on a pig or whatever, but the mere fact that
there's a piece of UI tracking whether you've done it or not, creates a
challenge by itself.

[0] yeah I said it! ;)

~~~
hyperpallium
I've thought about that - and it's not that big a jump to have a GUI that
allows a user to specify a win condition (and locations to traverse, other
conditions etc). Then, the user can share it online. I haven't played GTA V
online, but I think it does something like that.

But actually, I don't want those sort of win-conditions for this particular
game, not even DIY stats. It's just an immersive simulation. Guess I'm just
not too sure it WILL be immersive or engaging - even for me to play! Just have
to see, I guess.

Taking your lead, I suppose if a movie can be immersive, why not a "game"
which has no win-condition? But the moment I say that, I immediately realize
that movies _do_ have "win-conditions" \- just of the protagonist, not the
viewer/player. Goals, stakes, motivation, obstacles are all important
narrative components.

Can you have an immersive _movie_ without narrative? Sort of maybe, some
experimental/arthouse, but they aren't very popular (and arguably do have some
kind of narrative).

You're probably right about definitions, but they do inevitably lead to the
components of a game/non-game, and whether they are engaging, and what _makes_
them engaging... and they're easy to ask.

------
PavlovsCat
[https://sandspiel.club/#A6xPmAP4TSEpcwThAFSB](https://sandspiel.club/#A6xPmAP4TSEpcwThAFSB)

erase the thingy to the right, and the planets on the left grow upwards again.

~~~
PavlovsCat
flower pixel sort hurricane

[https://sandspiel.club/#7oUTxtqzUoLJTVuapqmc](https://sandspiel.club/#7oUTxtqzUoLJTVuapqmc)

------
choochootrain6
I've never played Powder Toy, but I do remember playing something called
Powder Game. Are they related in some way?

------
the_other_guy
This is the most satisfying thing I've ever seen on HN!

