News for hackers. Stuff that matters.
Re:Improving the foundation of our falling sand simulator by makeworld on Tuesday May 17, 2022 @11:04PM (#31418835)
These days when I want a falling sand game, I go to https://sandspiel.club/
Re:Improving the foundation of our falling sand simulator by Doxin on Thursday May 19, 2022 @04:40AM (#31432173)
Allow me to recommend The Powder Toy[0]. It is to date, as far as I can tell, The most advanced falling sand game available, aside from maybe Noita, though the focus there is quite different from most falling sand games. It has hundreds of different elements to play with. It simulates air pressure and can with the toggle of a button simulate ambient heat, water pressure, and newtonian gravity. People have built everything from bombs to CPUs in it.

Disclaimer: I did some minor development work on TPT and am involved in the community. Still though, great game.

[0] https://powdertoy.co.uk/

Re:Improving the foundation of our falling sand simulator by jasonjmcghee on Tuesday May 17, 2022 @11:43PM (#31419028)
Absolutely! I mentioned it in my first post. Great implementation and a good blog post about how it's made.
Re:Improving the foundation of our falling sand simulator by dang on Monday May 16, 2022 @07:58PM (#31404461)
Recent and related:

Making a falling sand simulator - https://news.ycombinator.com/item?id=31309616 - May 2022 (65 comments)

Re:Improving the foundation of our falling sand simulator by c0nsumer on Tuesday May 17, 2022 @09:08PM (#31418136)
There's something about the feeling of this that reminds me of being much younger, running demos in DOS, and how insanely performant they'd be at running the same sort of thing.

It was like magic at those times.

This is so far abstracted from the magic hyperoptimizations that were used for those demos it's mindblowing, but it's still fun to see and neat to play with.

Re:Improving the foundation of our falling sand simulator by jakear on Tuesday May 17, 2022 @05:20PM (#31416425)
Love the gravity addition, that's a clever trick for dealing with fractional velocity. Pausing rendering when there are no changes is also a nice touch.

I notice on my machine the background is initially white and only acquires the grey background color after a sand has fallen past a given pixel. I encountered the same bug when building my own version off of this from your last post, my fix was to initialize the dirty set to be the full set of indexes for the first frame. Also, some of the buttons are pure white, the text is invisible. (I suspect both of these are light mode only bugs)

Re:Improving the foundation of our falling sand simulator by jasonjmcghee on Tuesday May 17, 2022 @08:56PM (#31418066)
I thought treating fractional velocity as the probability to move was a fun hack. Unlike rounding, it makes it feel a bit more fluid as the batch of particles placed at a time step move two different distances.
Re:Improving the foundation of our falling sand simulator by jasonjmcghee on Tuesday May 17, 2022 @05:49PM (#31416688)
The light mode bugs should now be fixed. Apologies for that.
Re:Improving the foundation of our falling sand simulator by jakear on Tuesday May 17, 2022 @06:22PM (#31416964)
Works great!
Re:Improving the foundation of our falling sand simulator by jasonjmcghee on Tuesday May 17, 2022 @05:37PM (#31416584)
Oh no! I clearly have a bug. I develop in dark mode and apparently broke something during this post and didn't verify light mode. I will look into it now!
Re:Improving the foundation of our falling sand simulator by panzerboiler on Wednesday May 18, 2022 @01:21AM (#31419492)
Very nice job. You did some massive improvements since the previous article. I will try to follow along with a GPGPU implementation. Thank you!
Re:Improving the foundation of our falling sand simulator by jasonjmcghee on Wednesday May 18, 2022 @01:29AM (#31419537)
Thank you! I'd be very interested to see that. I've had a couple of fun Sundays now. I'm looking forward to the next pieces- but moving the logic to the gpu (either by shaders or GPGPU) has not been something I've been planning to do.
Re:Improving the foundation of our falling sand simulator by panzerboiler on Wednesday May 18, 2022 @01:36AM (#31419568)
The simulation being massively parallel, it is a perfect fit for a fragment shader. Since the interactions between the particles are mostly local, taking advantage of the fact that the GPU loads a block of neighbouring fragments in the cache to be able to compute the standard derivatives, it should run very well. I will notify you when I find some time to play with it.
Re:Improving the foundation of our falling sand simulator by Bellend on Tuesday May 17, 2022 @05:42PM (#31416621)
This is really awesome!

Anyone remember Sony-J5 Mobile? I first seen falling sand there. Jason's version is a ultra fast version (and cool!).

https://www.sony.ee/electronics/support/res/manuals/3227/322...

Re:Improving the foundation of our falling sand simulator by d4a on Tuesday May 17, 2022 @04:34PM (#31415951)
The acceleration was my main gripe with the previous iteration. Thanks for adding it!

I want to stay up to date on this blog. Is there an RSS feed anywhere?

Re:Improving the foundation of our falling sand simulator by jasonjmcghee on Tuesday May 17, 2022 @04:55PM (#31416172)
I'm glad you are enjoying the posts!

I'm hosting on Github Pages, which seems to have a feed plugin for RSS, so I'll investigate that! Right now I've just been posting to Twitter (so far it's the only thing I've used it for) and HN.

Re:Improving the foundation of our falling sand simulator by steve_adams_86 on Tuesday May 17, 2022 @11:20PM (#31418903)
Nice, I’m glad to see another post from you!

As someone else mentioned, this has intense nostalgic vibes. Something about the acceleration of the sand maybe?

You really knocked it out of the park in any case, the end result is fantastic. I’m looking forward to digging in deeper.

Re:Improving the foundation of our falling sand simulator by sokoloff on Tuesday May 17, 2022 @06:44PM (#31417143)
Fun!

Small bug: if you two finger touch on iOS (or hit clear all), the screen clears to a different color background, lighter than the new sand dispenser, so now the sky becomes darker as you drag around.

Re:Improving the foundation of our falling sand simulator by jasonjmcghee on Tuesday May 17, 2022 @07:02PM (#31417261)
Should be fixed now! Apologies for that! Clearly needed to test light mode more thoroughly.
Re:Improving the foundation of our falling sand simulator by bowsamic on Wednesday May 18, 2022 @04:46AM (#31420532)
Nothing like some good old elegant untyped JS
Re:Improving the foundation of our falling sand simulator by guerrilla on Tuesday May 17, 2022 @07:13PM (#31417344)
Wow why is this so fun and joyful :) So satisfying...
Re:Improving the foundation of our falling sand simulator by cjg on Wednesday May 18, 2022 @04:55AM (#31420577)
Reminds me of the 1991 Archimedes game Cataclysm.
Re:Improving the foundation of our falling sand simulator by ge96 on Wednesday May 18, 2022 @05:19AM (#31420688)
Can't restart it after it falls?
Re:Improving the foundation of our falling sand simulator by jasonjmcghee on Wednesday May 18, 2022 @10:35PM (#31430045)
You can just click "Clear All". Or right click on Web / tap with two fingers on mobile.
Re:Improving the foundation of our falling sand simulator by Jarmsy on Tuesday May 17, 2022 @07:20PM (#31417384)
Nice! How about a 3d version? :)
Re:Improving the foundation of our falling sand simulator by jasonjmcghee on Tuesday May 17, 2022 @07:29PM (#31417452)
If there's interest, I can definitely take a crack at it!

My current plan was to introduce some new particle types as there is some pretty stimulating emergent behavior that comes out particles with different rules interacting with one another.

I'm also really interested in exploring 2D velocity and acceleration- how we could go about enabling particles to be thrown and bounce off of walls- or each other.

Re:Improving the foundation of our falling sand simulator by DylanSp on Wednesday May 18, 2022 @02:17AM (#31419760)
If you don't mind spoiling your plans, are you thinking of continuing with the subclass-per-particle type approach, or eventually moving to something like a simple ECS architecture?
Re:Improving the foundation of our falling sand simulator by jasonjmcghee on Wednesday May 18, 2022 @10:42PM (#31430069)
A full ECS architecture? I don't plan on it. But using some sort of trait / component structure could be worth if enough particles with a mixture of different and overlapping behaviors were introduced.
Re:Improving the foundation of our falling sand simulator by ajmurmann on Tuesday May 17, 2022 @05:53PM (#31416732)
On Safari and Chrome I get `TypeError: p.before is not a function. (In 'p.before()', 'p.before' is undefined)` from falling-improved:171

Nothing gets rendered.

Re:Improving the foundation of our falling sand simulator by jasonjmcghee on Tuesday May 17, 2022 @06:00PM (#31416806)
This is what happens when you try to fix a bug while your post is on the front page. Yikes. Should be fixed.

You might need to force refresh.

Re:Improving the foundation of our falling sand simulator by serenitylater on Tuesday May 17, 2022 @11:24PM (#31418924)
Have you thought about modeling aeolian transport (wind-blown sand?) the mechanics of it are poorly understood and this could be a decent starting point. I know the other models attempting to capture aeolian transport are extremely lacking.