Yeah, I'm wondering how The Powder Toy does it (especially since it also has electronics/wires and changeable gravity)...
Edit: I found a great intro to the cellular automata approach:
https://blog.macuyiko.com/post/2017/an-exploration-of-cellul...
https://blog.macuyiko.com/post/2017/an-exploration-of-cellul...
https://blog.macuyiko.com/post/2018/an-exploration-of-cellul...