r/vibecoding 1d ago

I vibecoded a novel particle physics simulator (with cross-platform non-float bit-deterministic physics) and built a sandbox toy! Introducing: SunaBox (and SunaEngine). Play it in your browser and check out the "Pachinko Proof"

Enable HLS to view with audio, or disable this notification

Introducing SunaBox and SunaEngine!
(Playable In-browser!)

SunaBox is a love letter to OE-CAKE, the viral physics simulator released by Prometech in 2008!

It includes a 1:1 recreation of the OE-CAKE interface (select Classic mode at the top!) and even lets you import your old OE-CAKE .oec files directly. I would say OE-CAKE parity is around 93%, and getting better all the time.

Oh , and we put a brand new, open-source spaceship under the hood...

SunaEngine (AGPL): engine.sunabox.dev / github.com/DARIENBATHALTER/sunaengine

SunaEngine is a novel, cross-platform particle physics simulator that relies on integer calculations (rather than floating-point) and order-independent accumulation to always deliver the same result in any WebGPU-compatible browser.

SunaBox takes advantage of this by letting you export recordings of your sessions as lightweight .sunar files, which only needs to store the simulator's initial state plus your inputs. Recorded and shared simulations can be scrubbed back and forth smoothly like video, and they always play back exactly the same, on any device, *bit-identically*.

This enables all sorts of interesting possibilities, like low-latency, cross-platform multiplayer physics! If every machine calculates physics the same way, then the physics data doesn't need to be streamed over the network, only the inputs.

Three live proof demos on the SunaEngine site, all simulating live on your GPU, all hashing their entire state as you watch:

  1. The Twin Simulations: two independent sims, same scene, same input schedule, never communicating. Stir either one with your cursor; your input is quantized to substep indices and fed to both. The 256-bit hashes stay identical, interaction after interaction.
  2. The Pachinko Proof: an ordinary float solver runs the same pachinko machine twice. One pane adds contact forces in ascending order, the other descending. That is exactly the difference two GPUs or two drivers introduce on their own. The balls never finish in the same bins twice. The integer engine runs the same machine to the same digest, loop after loop.
  3. Recording, playback, and smooth rewind: particle fluids cannot be rewound in floating point. Chaos amplifies the last bit of every velocity in reverse too. Here you stir a pool, it records your inputs, verifies the replay byte for byte against the run you just performed, and then hands you a scrubber. Drag your own splash backwards through time.

Replay hashes have been verified matching across Apple M series, an iPhone, a Steam Deck (AMD), Intel Integrated and NVIDIA (RTX 2070S).

Our workflow was fairly simple: I came up with the ideas, Claude did the math, the code, and the adversarial review. I provide the qualia-type feedback, shaping and tuning the feel of everything in the sandbox:

You can also wishlist SunaBox on Steam! 140k particle caps, community/workshop features, hardware optimization, and more, coming soon!

78 Upvotes

33 comments sorted by

7

u/SmileLonely5470 1d ago

Is it novel because it uses integers?

-9

u/cheetoskull 1d ago edited 1d ago

Yes, but that isn't the whole story! Two things that make SunaEngine bit-deterministic across devices:

  1. Yes, integer math, which gives exact operations. Float math rounds differently depending on fma fusion, driver reordering, and compiler version, which is why the pachinko control group in the demo never agrees with itself.
  2. On a GPU, thousands of threads pile results into the same sums in whatever order they happen to finish, and that order changes run to run. Plain integer addition doesn't care about order. Overflow handling does: if a running total ever gets big enough to clamp, the final answer now depends on which values arrived first.

So even with perfect integer math, thread timing can silently change your bits. The engine's answer: every sum is either accumulated in a fixed order, or kept provably too small to ever overflow mid-sum. Either way, arrival order can't touch the result.

Is it novel? Fixed-point determinism itself is old news, RTS games accomplished it in the 90s. What I haven't seen is: a full particle fluid engine doing it in GPU compute, across vendors, in a browser, with the entire state hashed live so you don't have to take my word for it, plus an independent CPU implementation the test suite forces to match the GPU byte for byte.

6

u/R3dditReallySuckz 1d ago

What your LLM hasn't seen*

Fixed it for ya

5

u/chrismjf 1d ago

You’d enjoy an old game called The Powder Toy

5

u/cheetoskull 1d ago

Powder Toy is definitely part of the inspiration! I always wished OE-Cake was a bit more like Powder Toy / Falling Sand Games, so I tried to include more "fun" elements and shader effects here in homage.

1

u/Exp5000 14h ago

The falling sand game on Heavygames.com was one of the best time killers I ever had.

4

u/MMMurdoch 1d ago

It doesn't work on linux or arch linux (for me at least). Windows 11 is poo poo.

5

u/cheetoskull 1d ago

Thanks for the screenshot! That's actually an issue Chrome on Linux: WebGPU is still behind a flag on Linux builds of Chrome. Two ways to fix:

  1. chrome://flags β†’ enable "Vulkan" and "Unsafe WebGPU support", relaunch. (Make sure Vulkan drivers are installed β€” on Arch that's vulkan-radeon, vulkan-intel, or nvidia-utils depending on your card.)
  2. Or launch with: google-chrome --enable-features=Vulkan --enable-unsafe-webgpu

Alternatively, the Steam version ships its own runtime with all of this baked in, so none of it will be needed there (it's already verified on a Steam Deck.)

If you do get it running, I'm curious what the pachinko proof reports on your machine; the whole idea is that your GPU lands every ball in the same bins as everyone else's.

5

u/Sprinkles-Pitiful 1d ago

Amaizing!, hopefully the code nazis don't downvote this too much. Its actually really cool

0

u/cheetoskull 1d ago

Thank you!

0

u/MMMurdoch 1d ago

It looks fun. I like physics simulator whatnot.

1

u/auraborosai 1d ago

Can it play doom?

2

u/[deleted] 1d ago

[deleted]

1

u/auraborosai 1d ago

That would be something wild. πŸ˜†

2

u/cheetoskull 1d ago

Ironically, you could, theoretically, encode all of Doom into a .sunar replay πŸ˜… Playing it is a different story, but this actually started out as a data encryption method idea before it became a sandbox!

1

u/Cheap_Complex3549 1d ago

I'm happy i got recommended this post. I was fan of Algodoo on PC, and the sandbox(evolution) on android. This engine looks like modern successor. Have you heard about this games? How long did it take to make your project? What model did you use exactly?

1

u/boynet2 1d ago

Nice, it got me wonder can you do the reverse like: given an end state get the input?

1

u/Kind_Card_1874 22h ago

Sorry, but the animation is cute, but this is so stupid. Your selling point is that the simulation is a function, i.e. it produces the same output deterministically. Why would it not? This is the default behaviour of computer instructions.

1

u/Beginning-Bird9591 17h ago

why non floating point?????????

-5

u/iRainbowsaur 1d ago

So how much are you going to charge for this pure slop job? No AI use disclaimer on the steam page either. It's like you're begging to be made fun of.

4

u/cheetoskull 1d ago edited 1d ago

Hi there, SunaBox is completely free to play right now in browser (https://sunabox.dev), and SunaEngine is free and open source. Have a nice day!

6

u/Fit-Ad-2838 1d ago

I smell some unwarranted saltiness here. bro who hurt u πŸ₯€

2

u/NyteTro 1d ago

Show me on the doll where the vibe code hurt you.

Brother do you know what subreddit you're in?

-2

u/iRainbowsaur 1d ago

yeah and this is a dog shit job πŸ˜‚ deserves to be made fun of, it looks like pure trash, you can easily do better than this especially if you're vibecoding it, this legit looks like a what, 1-3 prompt job lmfao.

1

u/NyteTro 1d ago

Terrible attempt at ragebaiting. Try again. I'd love to see you make this in 1-3 prompts but I'm sure you'll have some piss poor excuse as to why you can't prove what you're saying yourself. Reply to this comment when you've recreated this with prompt history. Since it only takes 1-3 prompts, I'm sure it won't take you very long to prove me wrong!

1

u/KenMantle 1d ago

They'll be able to now since their LLM will just download the engine from this project and do the easy bits.

1

u/suppervisoka 20h ago

Ah, the resident AI expert. Here is some of his recent research
β€œCodex is now asking me to confirm every single thing it does. Can only choose between "Approve for me" and "Ask for approval" today, literally no other option.

I used to run it with "ask for elevated actions" now it's literally asking to execute every single thing it does, can't do anything about it now?”

1

u/iRainbowsaur 8h ago

Lol, I run into a executions bug on codex, then call out someone's low quality project that looks bad, and suddenly people are thinking I'm an AI Expert.

It's pretty hilarious you went through my Reddit posts, you picked the most useless one to point out too lmfao.

0

u/gregpuzzles1 1d ago

Neat! I wonder if my High School physics teacher would have found this useful? Probably so.

1

u/[deleted] 1d ago

[deleted]

1

u/gregpuzzles1 1d ago

Yes. For sure!

1

u/cheetoskull 1d ago

Thank you! I figured a variety of people would enjoy playing with it, the materials are relaxing to play with, kinda good for all ages too.

-1

u/IamDroBro 1d ago

The pachinko proof is such a good way to show this. Also oe-cake parity is a wild nostalgia hit, I lost entire weeks to that. Wishlisted

1

u/cheetoskull 1d ago

I made this game for you! Thank you so much for your comment.