Remix.run Logo
▲ Show HN: Impossible Machines: declaratively program the physical world(impossiblemachines.xyz)
49 points by bhaprayan a day ago | 16 comments

Hey all —

Sharing a thought experiment I put together. The premise: what might declarative programming feel like for the physical world?

We’re already familiar with this paradigm in software land (eg SQL etc where we declare what we want and the execution engine figures out how).

I didn’t have access to an actuator so I mocked up the concept in software. The way it works is you demonstrate the effect and the system figures out how to achieve it. So say you want to ring a bell and you have a crank. The system will find a way to connect the two. If you add obstacles it figures out how to work around them (runs a constraint solver runs behind the scenes).

I think what’s interesting about this is being able to think about the problem at a higher level of abstraction, with the system figuring out a way to achieve the intended effect.

Anyways, curious to read reactions, feedback, and interesting ideas on how to extend this!

▲insiderprint 17 minutes ago | parent | next [-]

This is fancinating!

▲bhaprayan 11 minutes ago | parent [-]

Thanks, happy to hear you liked it!

▲donalddominko 3 hours ago | parent | prev | next [-]

This is actually very interesting idea you had. I watched the demo and played with it and I am looking for a link to repo - I would like to know how did you implement the system achieving the outcome.

▲bhaprayan 2 hours ago | parent [-]

Happy to open source, the code is a little messy right now, so I’ll clean it up and post a link in a few days!

High level:

I’m using ThreeJS for the rendering and Rapier (https://rapier.rs/) for simulating bodies, joints, collisions, forces, etc. The mechanism is solved for using a simple heuristic search (eg constraints, etc that you introduce in the scene) and then run through Rapier to find a configuration that works, though there are definitely more sophisticated ways to do this. The audio is based off a sound pack which I tried to make physically realistic so impacts are panned relative to the camera, with compression and a small generated reverb.

▲pshc 4 hours ago | parent | prev | next [-]

The Incredible Machine vibes.

▲bhaprayan 3 hours ago | parent [-]

Embarrassed I'm just finding out about this, very cool! Neat that they simulated air pressure too. I should try that, would be fun to influence the texture of the sound.

▲SeanAnderson 2 hours ago | parent [-]

woah lol. I 100% assumed you used it as inspiration for your software.

▲bhaprayan 2 hours ago | parent [-]

Haha it sort of came out before I was born, otherwise I definitely would have! I think I'll take a leaf out of their book and expose a mode to make the simulation deterministic. I'm using a PRNG right now to make the mechanism selection more "creative", but I could see determinism being an interesting experience.

▲skinfaxi 4 hours ago | parent | prev | next [-]

This is cool! I think it would be interesting to expand the language of the world. Right now the interaction with the bell or door is limited (basically binary). Even with binary it would be cool to say ring the bell three times or play shave and a haircut and then a mechanical device that could generate that frequency would be created (for ex a simplistic one would be to skip every other ring for ringing the bell). I guess that would require the world/the objects to account for interactions over some recording period.

▲bhaprayan 4 hours ago | parent [-]

Thanks! Great idea, I hadn’t realized the interaction is binary. It would be cool to allow for "continuous" inputs too. The world would have to account for interactions over a recording period right.

Behind the scenes, I’ve tried to make the audio production realistic, so there’s some acoustic modeling going on (eg echoes, attenuation of sound, etc). But yes you could imagine having the input forces be continuous and having the mechanism trying to figure out how to reproduce the sound exactly.

▲mcphage 3 hours ago | parent | prev | next [-]

Disney's research lab did something along these lines some years ago for making a point follow a path. You draw a path, and it generates the linkages required to match that path as closely as possible. They've had a lot of follow-up work since, but I remember this video for it: https://youtu.be/DfznnKUwywQ?si=F-5NZxKu4hP_mand

▲bhaprayan 2 hours ago | parent [-]

Really neat demo! I skimmed through the paper and it looks like they’re using a precomputed database to find an assembly that matches the motion (presumably as a seed to instantiate the solver). That’s definitely more efficient than what I have right now (though perhaps less versatile). I like that they manufactured a few of the characters using 3D printing! That was definitely on my mind, really happy to see they did it.

Some of the mechanisms (belt drives etc) might be a little tricky with 3D printers, but would be very cool to see the mechanism tangibly realized.

▲jdw64 4 hours ago | parent | prev [-]

It seems people think alike. Something that inspired me in the past also had a similar implementation.

[1]https://www.microsoft.com/en-us/research/publication/motion-...

▲bhaprayan 4 hours ago | parent [-]

That was cool! Watched the demo video, didn't go through the paper yet. I'm running a simple heuristic to test for candidate solutions and running them through Rapier (https://rapier.rs), but simulated annealing to efficiently search the configuration space would be a nice extension.

▲jdw64 4 hours ago | parent [-]

Your work is wonderful, too.

▲bhaprayan 3 hours ago | parent [-]

Thanks, appreciate it!