r/programming • • Jun 25 '20

A bug with a surprisingly cool side effect

https://youtu.be/us1IqknNYmw
5.0k Upvotes

249 comments sorted by

581

u/viscence Jun 25 '20

The bug made the orbital periods for all objects the same, independent of mass, orbital distance etc. It also looks like the objects are only attracted to the system's centre of mass, not each other. The collision system effectively re-randomised all the objects on collision courses. As soon as all the objects miss each other for one orbit, the system can no longer change.

205

u/PezzzasWork Jun 25 '20

In this case they are not attracted to each other, it is a really simple simulation with Euler integration

83

u/viscence Jun 25 '20

The result is really neat!

49

u/PezzzasWork Jun 25 '20

Thanks :D

44

u/ConcernedInScythe Jun 25 '20

Did you make the force towards the centre of the system directly proportional to the distance from the centre? In that case your system is an example of a radial harmonic oscillator, which has this property of all orbits having the same period.

20

u/PezzzasWork Jun 25 '20

Yes it is the case, it's not gravity.

2

u/Dr_Legacy Jun 26 '20

Now I am wondering if there are solutions where the force is gravity-like (inverse square of distance), assuming masses proportional to the cube of the radius.

3

u/PezzzasWork Jun 26 '20

I did try with gravity like force (inverse proportional to the distance times the mass) and it seems to converge to parallel orbits, it is quite cool. I will link a video to this once I ll be home.

→ More replies (1)
→ More replies (1)
→ More replies (1)

66

u/howmodareyou Jun 25 '20

Probably the best interpretation of what is happening!
An interesting conclusion from this seems to be that you can find a collision free configuration for every input. It would be interesting to find out wether this is really true and stable for every kind of initial configuration.

8

u/ultrasu Jun 25 '20 edited Jun 25 '20

I don't see that happening when you've only got 2 objects. They'll always be moving right at each other, collide, separate, and repeat, kinda like Newton's cradle, and like Newton's cradle, I think this would extrapolate to any number of (round) objects if they're all placed on a single straight line.

Edit: another counterexample would be placing round objects of the same size & mass on the vertices of any regular polygon, they'll just end up contracting & expanding ad infinitum, so I assume some degree of asymmetry is required to have them end up in a collisionless course.

12

u/zuma93 Jun 25 '20

Well, in this case, since the particles are orbiting some central point and are not attracting each other, you could definitely come up with a solution. Two concentric circles, for example, or overlapping ellipses which share a focus. And for N > 2, you have solutions like the video. If the only requirements for a solution in this system are 1) no collisions and 2) equal periods, then there should be a solution for any N. If we instead look at a more realistic case in which all particles attract each other, the N = 2 case is both particles orbiting their barycenter. For N > 2, solutions are hard to find, but they do exist. For example, one solution to the three-body problem is to have the three particles traveling along a figure-8 path.

→ More replies (2)

4

u/[deleted] Jun 25 '20

They'll always be moving right at each other

They're not attracted to each other, only to the center.

→ More replies (1)

0

u/[deleted] Jun 25 '20

[deleted]

5

u/Axoren Jun 25 '20

There isn't a possibility of an A->B->A sequence?

→ More replies (3)

15

u/vektordev Jun 25 '20

The bug made the orbital periods for all objects the same, independent of mass, orbital distance etc.

As long as the orbits intersect, that's necessary to reach a stable state. But it doesn't explain the inordinate amount of close misses. I don't think it's random at all.

Instead, what I think the bug here is is that instead of balls bouncing off each other, they absorb all of that energy into nothing without any friction. So on a collision, we lose all of the energy in direction of impact, which sets us up for a "touching" pass the next orbit.

What it doesn't explain immediately is the effect of synchronization. What I think is at work there is: The faster body will run away from the slower body. So it's never possible for the slower body to get a bump from behind. We assume they're not synchronized. So the faster body will get further ahead[1], until he's actually coming up from behind again. Then he gives the slower body a bump from behind. The bodies exchange energy and the slower body goes onto a faster orbit with a higher period. Eventually, all orbits reach the same energy through this.

Of course, none of this would prevent a stable state where one of the balls is on a completely independent or a harmonic (twice as fast, e.g.) orbit, but that's not the kind of conditions the initialization and emergent mechanisms encourage.

[1]: I'm not sure a slower velocity will lead to a faster or slower orbit. Gravity is funny like that. In 3d gravity (1/r2 scaling), the faster body actually has a longer period, but I'm not sure that holds here, as we have 2d (1/r) gravity. We can tell because the center of the ellipses are at the (invisible) "sun". In 3d, the focal point is at the sun. Regardless, the bodies exchange energy always in such a way as to assume similar energies.

→ More replies (3)

8

u/[deleted] Jun 25 '20

Cool screensaver

11

u/JSeling Jun 25 '20

We may call this a kind of natural synchronization convergence or a emergent behavior?

2

u/lookmeat Jun 25 '20

In the collision update only positions are changed but not the velocity (this is the error) thus trajectories stay globally the same but positions are adjusted to avoid collisions. What is impressive is that is converges quite quickly.

→ More replies (1)

463

u/KillTrot Jun 25 '20

I couldn't even program this on purpose

Edit: He says the same thing in the end of the vid^^

170

u/PezzzasWork Jun 25 '20

Me neither :D

16

u/TerrorBite Jun 26 '20

I agree with one of the YouTube commenters: you accidentally made a form of machine learning, it's essentially a physical problem solving algorithm. With no change in velocity possible, each collision adjusts the position of a ball away from the one it collided with, and the entire system naturally seeks out a solution where no collisions occur.

→ More replies (13)

42

u/anyonethinkingabout Jun 25 '20

I guess if you would want to program this, you would first create N random paths, and then increase the sizes of the bubbles iteratively (you can increase a bubble's size to the maximum size it could be by checking it's minimal distance to every other bubble, and then subtract the other bubble's size)

7

u/lazyl Jun 25 '20 edited Jun 25 '20

No, I think the best way would be to do exactly this, only intentionally. Just start with random paths and sizes and then simulate the collisions until reaching a steady state.

10

u/KillTrot Jun 25 '20

Did the bubble size change in the video? I thought it was only the paths which changed

28

u/anyonethinkingabout Jun 25 '20

no, you calculate the bubble sizes beforehand, before rendering

→ More replies (9)

3

u/Kzrysiu Jun 25 '20

I had exactly the same thought while watching the video.

→ More replies (2)

198

u/amaurea Jun 25 '20

The source code is here.

I agree that this is a cool bug, and if someone asked me to make an algorithm that achieves this, I'm not sure I could have done it. N-body systems like this tend to be very unstable, so I would have thought that fine-tuned orbits like these would be both hard to find and short-lived.

88

u/PezzzasWork Jun 25 '20 edited Jun 25 '20

The orbits are indeed surprisingly stable. However a slight change can lead to cascading degeneration very quickly as they are all very close to each other.

33

u/justausedtowel Jun 25 '20

Check out Veritasium's video on Butterfly Effect and Chaos Theory. The patterns of motion he talks about is surprisingly similar to the ones your software produces.

11

u/PezzzasWork Jun 25 '20

I will check this!

14

u/SayWoot Jun 25 '20

Destin from SmarterEveryDay also made a video about bird, that uses a similar Pattern motion when they fly in groups https://www.youtube.com/watch?v=4LWmRuB-uNU

6

u/PezzzasWork Jun 25 '20

That's so amazing

48

u/loup-vaillant Jun 25 '20

This is not an N-body system.

  • All bodies have the same orbital period, regardless of their orbit's size.

  • The ellipses don't have any eccentricity. The centre of the system match the centre of the ellipses, not their foci.

  • The different objects quite clearly don't influence the trajectory of the others. Each object just turns around the centre.

Still pretty and impressive, but not physical at all.

10

u/PezzzasWork Jun 25 '20

Yes true, the initial aim of the code was just to create some animations for a data visualization project with no care about accuracy or physics. Just have a visually cool thing for a school project.

5

u/vektordev Jun 25 '20 edited Jun 25 '20

You're right in conclusion, but only the last reason is relevant. It's not a N-body-system because the objects don't interact gravitationally. There's an invisible "sun" that does all the graviticking, so all the chaos of n-body systems disappears... well, most of it anyway. That's what you meant with your last point, I think.

The fact that the gravity scaling is appropriate for 2d physics (scaling 1/r instead of 1/r2) doesn't really matter. I'm reasonably certain n-body systems with that kind of gravity aren't any less chaotic. (Gravity scales in 3d according to how hypothetical "graviton density" would scale. That is to say, according to the square of the radius, because the surface of a ball with the given radius is the area they would be spread over. Gravity that scales according to how physics would work in a 2d universe would scale with 1/r because the surface of the ball is now the circumference of a sphere. The resulting behavior is that of centered ellipses.) This is actual gravity at work here, just weird gravity.

The orbital periods are an interesting emergent behavior here. I'm not sure what's going on there, whether that's a natural consequence of "weird gravity", that suddenly now orbital periods are so different that we can have way different orbits result in the same period.

PS: Apparently, we've got a special case of weird gravity here: scaling with r, not with 1/r or 1/r2. Yeah, that'll do. At that point, equations for a generic pendulum will apply, and everything always has the same orbital period. https://github.com/johnBuffer/NoCol/blob/master/src/main.cpp - Line 98. Adjust my 2nd paragraph accordingly. Funny how they can appear so similar.

→ More replies (1)

46

u/eras Jun 25 '20

I guess it's also self-correcting, so if a planet does collide another one a bit (in the video they are barely but still touching when going by), it would be automatically corrected to a better trajectory with a very small change.

31

u/PezzzasWork Jun 25 '20

Yes it will, sometimes going through a chaotic phase

0

u/[deleted] Jun 25 '20

[deleted]

9

u/[deleted] Jun 25 '20

Yeah, it's just a case of having that transient phase at the beginning which corrects the orbits until we end up in the steady-state. Very cool. I imagine that programming something which never collides at all would be an interesting challenge.

→ More replies (3)
→ More replies (1)

115

u/DuffMaaaann Jun 25 '20

Typically, n-body systems involve some attraction between individual particles. This attraction is chaotic for 3 or more bodies.

In the video it looks like bodies are only attracted to the center, not each other.

56

u/Miyelsh Jun 25 '20

That makes perfect sense! Then the elastic collisions of the particles keep happening until they all have independent orbits. Kind of like an orbital natural selection.

11

u/TemporaryTieEight Jun 25 '20

Natural selection is a great way to put it

→ More replies (1)

6

u/EuroPolice Jun 25 '20

This is one of those repositories that I save for no reason

13

u/[deleted] Jun 25 '20

This isn't an N-body system.

14

u/Perkelton Jun 25 '20

Does the system start off in a stable state or does it converge after a few iterations?

The latter is at least something I can see happening (the objects nudging each other into a stable path).

43

u/PezzzasWork Jun 25 '20

It stabilizes after some iterations, at the beginning everything is colliding

11

u/[deleted] Jun 25 '20

So... it looks like the bug is "forgot to sap vel on collide" - so the objects are shifted away, but they keep moving? That's a relatively easy switch to pull if you want to use something like this as a neat particle effect. I wonder if the same omission would work in 3d.

3

u/PezzzasWork Jun 25 '20

Yes that's a good summary of the situation

9

u/Ramipro Jun 25 '20

It seems this is a result of all particles attracting each other linearly. That's why they all seem to be orbiting in ellipses around the CoM, because all their interactions are linear and equivalent to a single attractive force from the center.

I'm also hypothesizing that all the spheres have the same mass, that's why they seem to orbit with the same period.

7

u/PezzzasWork Jun 25 '20

They indeed have the same mass and they are actually just attracted to the center of the screen. It is a really basic simulation. It should be quite easy to tune it to include mass or attraction interactions though.

6

u/infk3y Jun 25 '20

Mate, that awesome music in the video! What is it?

10

u/PezzzasWork Jun 25 '20

It's from https://freepd.com/ (in this case it is https://freepd.com/music/Screen%20Saver.mp3) very nice site!

2

u/infk3y Jun 25 '20

Thank you very much good sir

6

u/sephirothbahamut Jun 25 '20

Maybe you only coded the change in direction upon collision, but without any decrease in speed/momentum? In that case they'd keep colliding and changing directions until the system ends up in a situation of equilibrium.

5

u/PezzzasWork Jun 25 '20

Yes that's exactly that!

5

u/svs___ Jun 25 '20

Haven't you shown this at the JSUnconf last year in Hamburg?

6

u/PezzzasWork Jun 25 '20

I didn't! But maybe someone made something similar :)

3

u/mjk1432 Jun 25 '20

You should make a screensaver!

3

u/PezzzasWork Jun 25 '20

I will check how to do that

3

u/mobydikc Jun 25 '20

This is all in 2D right? I think that's easily lost in this amazingness.

There may be something mathematically significant about that. Nice work.

4

u/PezzzasWork Jun 25 '20

Yes it is in 2d, It can be extended to 3d trivially though

5

u/mobydikc Jun 25 '20

Yeah, but it in 3d it also seems like it be more mundane.

To see your 2d simulation move and seemingly dodge and weave it makes my mind think I'm watching something that is moving in 3 dimensions. And then realizing its just 2d is like "whooah"

Watching it makes me think of this:

https://en.wikipedia.org/wiki/Evolutionarily_stable_strategy

5

u/dscottboggs Jun 25 '20

Seriously this is genuinely amazing. Thanks for sharing.

1

u/PezzzasWork Jun 25 '20

Thank you!

2

u/Miyelsh Jun 25 '20

Is the potential in this system the inverse of distance from the center? Like someone else said, the potential doesn't seem to scale with radius of the balls, so is it something like V(r) = k/r ?

2

u/PezzzasWork Jun 25 '20

The force is indeed proportional to the distance and all the masses are the same but it can be tweaked quite easily

2

u/[deleted] Jun 25 '20

Nice feature. Also CERN wants your resume.

1

u/PezzzasWork Jun 25 '20

Ha ha I don't think they want me to work on any simulation things after seeing this xD

2

u/alisey Jun 26 '20

I made a crude port to TypeScript if anyone wants to play in browser. Orbits stabilize in a couple of minutes.

https://stackblitz.com/edit/typescript-xhugnh?file=index.ts

1

u/PezzzasWork Jun 26 '20

Wow that's a super nice port! Runs very well

100

u/kimcawin Jun 25 '20

a nice loading indicator

41

u/ShinyHappyREM Jun 25 '20

40

u/DrDuPont Jun 25 '20

That is an oddly suggestive name

7

u/sysop073 Jun 25 '20

Especially since they were definitely called spinners, and somebody felt the need to rename them

→ More replies (1)

71

u/Godof Jun 25 '20

8

u/bagtowneast Jun 25 '20

This is exactly what I was thinking. With, basically, no background in this sort of problem solving, I wonder if there's an reasonable collision avoidance algorithm lurking in here.

5

u/SirClueless Jun 25 '20

Yeah, probably. Take a reversible or periodic simulation. If anything collides, move it slightly (in either 3d space or in time) til it's not colliding. Get back to a new initial state either by reversing time or continuing for one period. Do this until nothing collides.

This probably doesn't work very well at all (would take a long time to converge if it ever does) for any chaotic simulation. But this simulation is extremely well-behaved in that every object is a perfect oscillator.

→ More replies (3)

3

u/andrei9669 Jun 25 '20

palms are sweaty

150

u/YeeetThisYeast Jun 25 '20

A bug with cool side effects = feature

56

u/dr1fter Jun 25 '20

Right, now you just have to slap some minimal game design on top and you're done.

29

u/wpzzz Jun 25 '20

I would love this in wallpaper engine or as my phone background!

0

u/[deleted] Jun 25 '20

[deleted]

3

u/_crackling Jun 25 '20

or some sort of variation on https://agar.io/#ffa

3

u/vaporeng Jun 25 '20

a bug with cool side effects = evolution

→ More replies (1)

65

u/defietser Jun 25 '20

You should crosspost this to /r/oddlysatisfying. Because it is.

3

u/HighGaiN Jun 25 '20

It might be more interesting to /r/physics or /r/maths. I know it's not exactly science but the way the system becomes stable could be something interesting to astronomy? :P

→ More replies (1)

86

u/[deleted] Jun 25 '20

that was way more interesting than expected

→ More replies (1)

35

u/Johnothy_Cumquat Jun 25 '20

It's like you learned to fly by falling and missing the ground

6

u/qazwer_plmoiu Jun 25 '20

I'm surprised more people didn't pick up on this reference

8

u/tradotto Jun 25 '20

They forgot their towel

13

u/crazymonmon Jun 25 '20

Reminded me of the video about flocking birds from smarter every day channel.

7

u/[deleted] Jun 25 '20

this person just solved self driving cars what the

2

u/rtriggs Jun 25 '20

This was my first thought too

→ More replies (1)

6

u/idkabn Jun 25 '20

Those slow-motion clips are storming majestic.

5

u/zhujik Jun 25 '20

Huh, this is really interesting. Is there some field in mathematics or physics that are studying specifically things like that (orbiting objects not colliding)?

4

u/jtinz Jun 25 '20

Orbital mechanics?

5

u/[deleted] Jun 25 '20

Coolest thing on reddit in the last decade or so. I could just run this code to watch it for hours and hours.

4

u/lolhehehe Jun 25 '20

That would make an awesome screensaver!

→ More replies (1)

4

u/shakelfordbase Jun 25 '20

This is what I picture computer-controlled intersections of the future look like.

1

u/AbrocomaTop5436 Jun 26 '20

How many objects can you simulate?

1

u/PezzzasWork Jun 26 '20

A lot, complexity is O(n2) but since the computations are very light it can handle more than 100 or 200 easily (in C++ at least)

2

u/AbrocomaTop5436 Jun 26 '20

Wouldn't that make a cool video? ;)

1

u/PezzzasWork Jun 26 '20

That's true, stabilization will just be a lot longer.

3

u/FederalRegion Jun 25 '20

I need this as wallpaper.

3

u/MultipleAnimals Jun 25 '20

i want this as my sceensaver

3

u/postblitz Jun 25 '20

Now increase the size to several million light years and increase the amount of particles to several trillion and boof: you've created the (metastable) universe.

2

u/RoguePlanet1 Jun 25 '20

Put a negative sign in front of those same numbers, and boom: particle physics.

2

u/[deleted] Jun 25 '20

Wow, it looks really insane to code something like that, BUT THERE ARE NO ACCIDENTS.

2

u/[deleted] Jun 25 '20

Would make a nice screensaver.

2

u/kolumreto Jun 25 '20

Definition of dumb luck

5

u/Gumichi Jun 25 '20

I don't see luck being involved at all. Given that orbital parameters only ever change when there's a collision, a steady state of no collisions is a very likely outcome of a system like this. I see 2nd law of thermal dynamics at work.

3

u/kolumreto Jun 25 '20

It is dumb luck, because unwanted bug became something more complicated.

2

u/[deleted] Jun 25 '20

This is incredibly interesting. Thank you for sharing.

2

u/KernowRoger Jun 25 '20

So I'm assuming once they bump each other into the correct orbit it's stable as they don't attract each other. There's something very satisfying about watching a chaotic system find balance like this. Great job!

2

u/[deleted] Jun 25 '20

Oh wow, this is interesting. Thanks for providing the source, can’t wait to take a peak at this.

2

u/TuViejaEnTanga_ Jun 25 '20

It looks like hindu traffic

2

u/TigoBad Jun 25 '20

It's not a bug, it's a feature!

2

u/Necrophillip Jun 25 '20

The future of autopilots

Until some jackass gets an unnecessary bodykit going passt the mirrors

2

u/[deleted] Jun 25 '20

This would be a sweet wallpaper for Wallpaper Engine!

2

u/[deleted] Jun 25 '20

He made a system to make them collide and got the opposite.

That seems a lot like my work outcome.

2

u/[deleted] Jun 25 '20

Most beautiful bug I have ever seen

2

u/[deleted] Jun 25 '20

Did you just accidentally stumble upon the algorithm for self driving cars

2

u/AvailableCobbler3 Jun 25 '20

happened something similar with me when I was coding a solar system physics simulation.

that day I learned about n-body problem

2

u/GTX_Incendium Jun 26 '20

Who else thinks this is super un satisfying

2

u/hoppi_ Jun 26 '20

The slow-mo shit with the near misses is AWESOME! :D

2

u/Wheekie Jun 25 '20

Self-driving cars be like :

1

u/IorPerry Jun 25 '20

Octuple Star System from star trek picard is nothing

1

u/stijefan Jun 25 '20

It's beautiful

1

u/[deleted] Jun 25 '20

Seems like they are slowing down when they go near eachother, as in a reverse gravity which ensures they don't collide and speed up when the path opens again.

1

u/-Pruthvi Jun 25 '20

We can handle it without handling it.

1

u/crackanape Jun 25 '20

He's stumbled across the algorithm for Amsterdam bicycle traffic.

1

u/NotARealDeveloper Jun 25 '20

I had the same thing happen to me when I wanted to make a simple RTS "go-to position X" command. At the end it was the same result you had: They would move towards the point, but then go further and at some point rotate in an arch going back to the point.

I made it the main feature of my game. It was in space with ships that would basically guard an area / bombard a point.

1

u/[deleted] Jun 25 '20

Imagine this in 3D. A sphere of objects all in different orbital directions, not colliding. I guess this is because they don't have gravity on each other.

1

u/rebelsofliberty Jun 25 '20

If you can generalize the problem you might be able to enhance this into an iterative collision avoidance algorithm. This might need some research first, though.

1

u/PVNIC Jun 25 '20

Of course it takes a program designed to do collisions to make a program that has zero collisions. Maybe I should try writing a program that crashes?

1

u/Lt_486 Jun 25 '20

It has to become screen saver. Sell it to MS.

1

u/the_notorious_beast Jun 25 '20

Dude did you just create a simulation of a solar system?! Friggin' nuts mate! I'd definitely call this a feature

1

u/jdmarino Jun 25 '20

Now do it in 3D and have the camera mounted on one of the spheres, GoPro style. ;D

1

u/M123Miller Jun 25 '20

The ball the camera follows at the end = me trying to avoid people at the supermarket when I venture out for groceries.

1

u/Drahnesor Jun 25 '20

It's not a bug, it's a feature

1

u/frogking Jun 25 '20

And that’s how orbital mechanics work..

1

u/dnew Jun 25 '20

So what was the bug?

1

u/BarkeeperBoi Jun 25 '20

that would be an amazing desktop backround

1

u/didzisk Jun 25 '20

One of 2019 Advent of Code days was about orbiting objects, that was my first thought when I saw this.

1

u/Perkovic15 Jun 25 '20

Pretty sure we are in recursive simulation... Random guys randomly inventing atoms. Whats next? Molecules, lets go

1

u/cw8smith Jun 25 '20

If I remember my physics correctly, an attractive force that varies linearly with distance will result in a single constant orbital period for all orbiting bodies. And if I'm reading the source correctly, it looks like that's how your attractive force works. Since the particles start with no velocity, i.e., at the top of their orbits, and they all have the same orbital period, the particles end up with synchronized orbits.

1

u/imagebiot Jun 25 '20

Looked very cool

1

u/gregontrack Jun 25 '20

Why do I get the feeling this is going to be the next intro?

1

u/sintos-compa Jun 25 '20

I was 100% sure the bug was the infinite redirect loop I got on mobile clicking the video.

1

u/[deleted] Jun 25 '20

1

u/w124gb Jun 25 '20

Warning this video might give you a seizure.

1

u/TheSaltyReddittor Jun 25 '20

that would make a really good home screen/ screensaver.

1

u/ldsdmtgod Jun 25 '20

Imagine this on lsd

1

u/PizzaBoyztv Jun 25 '20

If Corona was bugged like this

1

u/OldLadyUnderTheBed Jun 25 '20

Now we just need to upload this to a hundred self-driving cars and watch them go

1

u/ThePotatoLorde Jun 25 '20

Knowing the three body problem, this is kinda insane to look at, the simple explanation of what happened is that when they collide the velocity doesn't change when normally they slow down and stop, so after they hit eachother at the begining, they keep going and then never hit again, yet the objects don't have any mass so they aren't attracted to each other which is what causes the three body problem to be a problem.

1

u/e_mendz Jun 25 '20

This looks like a "bug" that can inspire a solution to collision free autonomous driving... or perhaps automated air traffic control, or satellite orbit management (if there's such a thing).

1

u/louknew17 Jun 25 '20

This is like how dark matter behaves, interacts only gravitationaly with itself and ordinary matter!

1

u/dumdedums Jun 25 '20

It's pretty cool. I think the bug is that what was supposed to happen was a completely inelastic collision and the bug was that all the objects had completely elastic collisions. The 'gravity' kept bumping the balls together until they oriented themselves where they wouldn't hit and since all kinetic energy was maintained, they never slowed down which ensured they would never stop.

1

u/project89 Jun 25 '20

Now make it in 3D!

1

u/rob10501 Jun 25 '20

That is so cool... I mean could be all tom fuckery, but looks good!

1

u/bradrlaw Jun 25 '20 edited Jun 25 '20

Would be an interesting (and scary) algorithm to apply to a drone swarm. Could make them follow a path while moving about seemingly at random without colliding into each other.

Each drone would be the same size, but you would have a virtual diameter around each drone to simulate the mass. Then over time you have the "mass" randomly change over time at a rate fast enough to not cause collisions, but fast enough for a viewer to have a really hard time predicting where a drone is going to be making for a seemingly "random" swarm of drones moving on a path.

Edit: I see now its not really simulating gravity / attraction, but could still alter it to do the above.

1

u/BenCelotil Jun 25 '20

Who here ever played with CHAOS years ago?

1

u/yacantfixstupid Jun 26 '20

R/supercoolscreensaver

1

u/Majik_Sheff Jun 26 '20

I would love to have this as an Xscreensaver.

1

u/[deleted] Jun 26 '20

I think xlock has it.

1

u/DawsonFind Jun 26 '20

I will never not be dizzy again

1

u/zaemis Jun 26 '20

well, that's 3 minutes I'll never get back

1

u/Red5point1 Jun 26 '20

Would be neat to apply the logic to a swarm of drones and watch them fly around at high speeds criss-crossing each other without colliding.
I think you have inadvertently come up with a safety chaos navigation solution.

1

u/lesroco Jun 26 '20

mindblower!!!

1

u/Dobias Jun 26 '20

Thanks for the nice post and the inspiration. I re-created your effect in three dimensions, and it works fine. :)

https://www.reddit.com/r/programming/comments/hgaz9e/the_bug_with_a_surprisingly_cool_side_effect_in_3/

1

u/MrHappyJohn Jun 28 '20

It's really near how none of them collide!

1

u/Gabgodd Jul 06 '20

Me dodging skills in league be like

1

u/Bored_comedy Jul 10 '20

Aw I'm so confused someone please explain how this went from collisions to no collisions?

1

u/[deleted] Jul 23 '20

So neat!

1

u/Fancy_Mammoth Jun 25 '20 edited Jun 25 '20

So, you basically created a simulation of electrons flying around the proton neutron core of an atom. That's pretty freaking cool.

Edit: Can somebody explain to me why I'm being downvoted for making a observation about what this looks like?

2

u/notyourmother Jun 25 '20

That was my first thought as well. The second was that all of existence might be a bug instead of a feature as well somewhere haha

1

u/NotAnADC Jun 25 '20

obviously im not the only one thinking about planets

→ More replies (1)

0

u/[deleted] Jun 27 '20

[deleted]

1

u/PezzzasWork Jun 27 '20

Thank you!

0

u/[deleted] Jun 25 '20

[deleted]

7

u/revnhoj Jun 25 '20

Needs more honking

2

u/AdvicePerson Jun 25 '20

HORN OK PLEASE

→ More replies (1)

0

u/[deleted] Jun 25 '20

[deleted]

3

u/PezzzasWork Jun 25 '20

There are no energy bleed since velocities are not updated after a collision. The only way for an object to lose speed is to be pushed toward the center because this will make it to have a lower attraction force (since it is proportional to the distance)

0

u/[deleted] Jun 25 '20

[deleted]

3

u/PezzzasWork Jun 25 '20

Hmm you're right. The whole energy of the system is conserved in this case.