How To Code a Falling Sand Simulation (like Noita) with Cellular Automata
Video Statistics and Information
Channel: SCREAMINGSNAKE
Views: 8,395
Rating: undefined out of 5
Keywords:
Id: 5Ka3tbbT-9E
Channel Id: undefined
Length: 21min 18sec (1278 seconds)
Published: Sun May 23 2021
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.
[removed]
Awesome!
Few questions
1) It seems (from the bit on multithreading) like the cellular automation checks and modifies cells in the same pass. If there was a separate logic pass (check what change will happen to the cell depending on its neighbours) and once this is done for every cell a separate state mutation (apply the changes to each cell) or double-buffering (read from one buffer, but write to the other, then swap the two), does the simulation behave in visually the same way? This could mean multithreading can avoid the second odd/even column step and avoid the random offsets used to hide artifacts.
2) Are you drawing every pixel anew on a clear canvas each frame? Could you avoid starting from scratch each frame and simply update the cells that have changed (e.g. if a sand falls, restore the background colour at the previous position, and draw the sand at a position below, but don't need to redraw stone that hasn't moved).
So cool! Hopefully some day Iโll be able to understand more than 10% it lol
Great summary! I can easily tell how to port this logic to my favorite languages based on the great explanations. Thanks for sharing
These pixel simulation / falling sand simulation / sand game systems are so fascinating.
I just started a sand game of my own. Last night I got sand and water behaving decently alone and with each other, and it's amazing how few simple rules end up in a decently realistic behaviour. And often even in surprisingly realistic behaviour, showing effects you didn't specifically intend but it still happens.
One of the pulls for me is that is it's not especially taxing to code these things (lines of code wise) and after you have a good system, adding a new "species" can be really simple. You can create a decently complex world from scratch and with relatively little code.