Falling Sand

A rather simple cellular automaton simulation. I wanted to figure out something to make for the February TOTM, I was recently making cellular automaton in Unity so I thought maybe I could do something similar for Snap!.

EDIT: I may make it to where you can use the cursor to place sand instead of it slowly filling up... soon.
EDIT 2: Yeah, done, hold left mouse button to place sand!
EDIT 3: Use number row to change type of cell.

Oh, this is beautiful and ... satisfying to play! I love it, thank you for sharing this super nice project with us!

Cool, I love this kind of stuff.

Is there a name for this celluar automaton rule?

Yes, this is very nice. Sort of reminds me of that snake game.

I have one user interface complaint: You hit the green flag and nothing happens. There should be a startup screen saying "Click the mouse and drag it around the screen" or something.

I've fixed this now, thank you for the feedback.

Thank you!

I don't believe so, it's just a simple movement algorithm thingy? I don't believe its any rule.

I like it. Very much.

You may consider some grains as "settled" and stop script to speed up.
untitled script pic - 2022-02-08T174722.678

Thank you for this suggestion, it has been implemented. I think I actually noticed a performance increase as well...

Update! Added stone.

Stone is different from sand in that stone will not form dunes, stacking perfectly.

I've noticed a bug... If you're quick enough you can cause a cell to settle in mid-air, causing it to float, anybody got a suggestion? If there is no idea perhaps I can just make the script not stop...

I think what you need is a sprite-local variable (so each clone will have its own) called GROUNDED? or something that starts out False. Then you can test the variable of the clone you're touching, and stop (and set your variable to True) only if the other clone's variable is True.

Ah, I was working on another solution, but this one is actually pretty smart.

Ok, I implemented it, but the way I'm doing it seems to be causing a huge performance hit... I'm not sure how to fix this, any pointers?

Removing of the clone spawned on top of other clone didn't fix the freeze problem?

Most clones never settle and still performs a loop. Only clones with y<-126 switch costume to "grounded".
So you need a better criterion, e.q. sprite remains at the same y position few times.

See if you can get any inspiration from the bubble popper project, where I was exploring similar (multi-criteria) communication between clones.

On the other hand, a very simple solution for eliminating the "being too quick" problem is to play the project on the mobile (smartphone) only. (One can be 'too quick' on computer, only; I guess).

I find it ideal for playing on phone.