Neural Boids

(campedersen.com)

98 points | by ecto a day ago ago

52 comments

  • rdedev 21 hours ago

    > In 2010, a team led by Andrea Cavagna at the University of Rome tracked individual starlings in 3D using multiple synchronized cameras. And they found something surprising!

    > In 1986 Craig Reynolds encoded this insight as three rules:

    This part just left a really bad taste in my mouth. I am not against using LLMs to write stuff but please proof read what it writes before posting it.

    The way it's written it's sounds like Craig Renault travelled in time to 2010 to come up with his rules for boids

    • ecto 21 hours ago

      Thanks for the feedback, I flipped the two sections.

      Sorry about your mouth!

  • catlifeonmars a day ago

    I found this difficult to read due to the LLM-isms, but love the concept. Gentle feedback: take the time to write articles in your own voice.

    • skolskoly 14 hours ago

      >Sentence fragment. Sentence fragment. Sentence fragment. That's not X, that's Y.

      I can't even call this LLM smell at this point it's a stench.

    • ecto 21 hours ago

      Thanks for the feedback :~)

  • jdlshore 21 hours ago

    I have to second the complaints about LLM writing. The tropes were grating, to the point where I hit the back button before ever learning what the difference between a boid and a noid is.

    Ecto, I see that you’re reading and responding to comments. In your own words, concisely, and assuming I know what what boids are: what sets this apart?

    • ecto 21 hours ago

      gpu

      • fc417fc802 19 hours ago

        You sure about that answer? Variants of boids have been implemented to leverage the GPU many times. I'm unclear how far typical GPU based examples deviate but then yours doesn't precisely imitate the original either. GPU accelerated boids is even one of the sample programs provided for testing Dawn when you compile it. [0]

        Aside from "look ma, machine learning!" I noticed exactly one thing that sets your implementation aside from any other example I've seen before. It seems quite odd to me that you didn't select either neural networks or that feature for this answer.

        Also the performance analysis section contains several questionable claims.

        [0] https://dawn.googlesource.com/dawn/+/refs/heads/main/src/daw...

  • schlich 21 hours ago

    Cool stuff! It's an interesting approach to the starling phenomenon. I'm familiar with the phenomenon through the lens of phase transitions and the critical point, which you allude to in the article briefly. Any further thoughts on how your neural-network based approach maps conceptually to the critical point and related models of emergent behavior?

    • ecto 21 hours ago

      Fantastic question :) one could extrapolate the possibility space here to see the potential. The interesting core here is the emergent behavior clearly visible in the vizs - what happens when you measure this in higher-dimensional and more connected networks? (What if it’s not noids?) I think this is underexplored in interpretability today

  • cadamsdotcom 21 hours ago

    Very cool and I love the visualisations..

    There’s a saying, “people are smart but crowds are dumb”. One wonders if humans in crowds subconsciously do something like flocking.

    • rdedev 21 hours ago

      The fact that stampedes happen is evidence against it. At least we are not capable of sticking to some basic rules the birds follow when we are startled

      • Timon3 21 hours ago

        I don't think the situations are remotely comparable due to the additional spatial dimension available to birds (and fish). When you have a person on each side, and they get pressed into you with enough force, you have no chance - of course people panic. I'll wager the guess that something like this has never happened to a bird.

        • fc417fc802 21 hours ago

          Groups of fish and birds both extend into that "extra" dimension so it's not as though there's additional empty space available to them. Yet both sorts of creature exhibit functional group behavior that coordinates high speed travel while being packed fairly tightly. Humans don't do that.

          That said, failure likely looks quite a bit different. For both fish and birds there's nothing at the edges constraining the cluster aside from unusual situations such as a net or a cave. Whereas the most notable human failures involve what amount to walls on multiple sides.

          It's amusing to visualize a flock of birds failing to maintain distance and all falling out of the sky as a result.

          • Timon3 20 hours ago

            I'm not a mathematician, but I've seen many examples of systems where changes to the number of dimensions cause completely different behavior. This feels like such a system to me.

            There's also an additional big difference: on the ground, you always have a hard body (the ground) constraining you.

            • fc417fc802 20 hours ago

              The presence of the ground is equivalent to the absence of a third dimension. Thus irrelevant.

              I see no reason to expect additional dimensions to make a fundamental difference here. This isn't a complex topological problem involving the constraints of graph connectivity. It comes down to nothing more than immediately available space, maintaining it as a group and making use of it as an individual.

              Consider a tightly packed group of runners. If someone in the center goes down they'll likely be trampled and it's also likely to cause a mass pileup.

              If birds were prone to that you'd expect the occasional collision at the center of a dense flock and a bunch of birds falling out of the sky as a direct result. Yet I've never once heard of that. The simple and obvious hypothesis is that they are hardwired for group navigation in a way that the vast majority of other animals aren't.

              If you're having trouble seeing the point I'm trying to make here then try swapping out the example with runners for one with a fleet of planes. A swarm of hundreds of modern fighter jets in a dense 3D formation actively maneuvering in randomized arcs without any sort of pre-planning or rehearsal. If something went wrong can you really imagine all of the pilots successfully avoiding collision every single time? The birds around here put on shows like that multiple times every day.

              • Timon3 20 hours ago

                The presence of the ground is very important because it's a solid body you can get crushed against! The fear of falling down and getting trampled is a major source of panic in bad crowd conditions. That alone makes a big difference.

                This isn't about complex topological problems, it's about the square-cube law. In a 3d environment, the direction of movement of any individual covers a much smaller portion of their possible movement directions. This means it's much easier to form a "wave" in 2d, and this wave covers a much larger portion of their potential movement options.

                Doesn't this obviously mean a 3d crowd is much less likely to crush an individual? And even if we're only talking about bird-on-bird collisions, head-on collisions make up a much smaller portion of all possible movement vectors.

                Regarding your plane example - birds don't explode upon most collisions, and I'd assume they can easily recover from many angles a plane couldn't.

                • fc417fc802 18 hours ago

                  > the direction of movement of any individual covers a much smaller portion of their possible movement directions

                  Number of adjacent bins versus fraction of unoccupied bins. The latter is what matters (ie density). Plus the physical and mental ability to rapidly and accurately select and maneuver into one of them. Plus (and this is really the crux of the thing) some sort of hardcoded behavior that makes the risk of conflicting independent choices vanishingly small.

                  A concrete example of that last part is TCAS. [0] That's what birds seem to have built in that other animals lack.

                  > it's much easier to form a "wave" in 2d, and this wave covers a much larger portion of their potential movement options

                  Not true. Waves in a 3D medium are themselves 3D. Go check out a fluid dynamics simulation.

                  I think what you might be trying to get at is dissipation within a volume. Cubed versus squared. But that's not the issue here. Dense pockets will occur from time to time in such a system regardless of dimensionality. The question is collision frequency for a given density. Birds are ~0 whereas humans (and most other animals) are really quite bad.

                  > birds don't explode upon most collisions

                  It's a fair point (and humorous) however irrelevant because my entire point there is that I've never seen birds collide to begin with. Even if they did explode it wouldn't matter.

                  Note that unlike human pilots autonomous aircraft are capable of forming dense swarms without colliding. (At least assuming the software was designed with that in mind.)

                  [0] https://en.wikipedia.org/wiki/Traffic_collision_avoidance_sy...

                  • Timon3 11 hours ago

                    If we just go by what we've seen it's all irrelevant, since I've never seen a flock of birds with anywhere near a comparable 3d density to a dangerously dense 2d crowd. Even the densest flocks still have visible gaps between the birds, I'd guess the density would need to be at least 5x higher.

                    • fc417fc802 11 hours ago

                      We were never making an exact comparison though. The point you've been arguing against (unless I misunderstand) is that creatures such as birds and fish have some special hardcoded behavior that the rest of us don't. I don't think spacing the humans out a bit more is going to solve the problem here; the aircraft example makes that point nicely.

                      In fact even your objection about visible gaps serves as a case in point. A flock of hundreds of thousands of starlings somehow avoids such dangerous densities even in the face of transient "pressure" waves traveling through it. Meanwhile human groups appear to willingly form such densities without thinking twice. Sounds like a hardcoded behavior to me.

                      If you really want an example with more density then consider schools of fish. Of course unlike birds it's not so easy for most people to observe fish. I don't actually know for certain that they never collide or get injured by being crushed. I seriously doubt it though.

                      • Timon3 10 hours ago

                        The point I'm arguing against is that a 2d crowd of people and a 3d flock of birds are anywhere near comparable. They aren't, they have fundamentally different mechanics, problems, behaviors etc. You're comparing apples to elephants.

      • cadamsdotcom 21 hours ago

        Birds can move in 3 dimensions, crowds are restricted to two.

        Maybe there’d be bird stampedes too, if they didn’t have wings ;)

  • abetusk 19 hours ago

    This is awesome. I think I've heard of other research that's similar to try and speed up Navier-Stokes or other water/smoke/etc. simulation.

    But this isn't actually recreating murmurations, is it? This is a neural network that's using the Reynolds criteria as a loss function, with Cavagna's topological neighbors?

    As far as I know, there's no good research that reproduces the murmations seen in starling flocks. This seems like it would be a good use case for neural networks but I don't know of any publicly available 3d data of actual starling flocks, aside from some random YouTube videos floating around.

  • 21 hours ago
    [deleted]
  • blademaw a day ago

    Wow, this post is beautiful. Well done, great read.

    • maest a day ago

      Cool idea and explanation, but hampered by the clanker tone of the writing.

      • ecto 21 hours ago

        Thanks for the feedback!

  • pton_xd 21 hours ago

    Is this some OpenClaw blogging setup? I've seen similar posts [0] on Twitter lately (not from OpenClaw, but maybe the claw is getting the idea from there).

    [0] https://x.com/fleetingbits/status/2028669892686438818

    • ecto 21 hours ago

      No dude

  • oscarcp 21 hours ago

    Huh, this just gave me an idea (provided a few modifications and enhancements to the noids) to create a god game with true emergent behaviour (yes, that's not very gamey like, I know, it can collapse for no reason). Let's see if I'm smart enough to pull it off (note: I'm waaaay over my head in this)

  • dexwiz 21 hours ago

    Boids are little lovely simulations. This just looks like a boring force directed graph. I wonder if there is any correlation between the blandness of LLMs and weight based models.

  • adammarples a day ago

    What's the point of training a nnet on outputs from the original 3 rules so it can effectively just relearn them?

    • kjshsh123 21 hours ago

      Kinda agree. Training the network with RL instead and penalizing collisions and rewarding collecting something like food would be interesting.

      As long as the birds can't change direction too quickly (e.g. output acceleration, not velocity) I'd guess you get flocking.

      • daemonologist 21 hours ago

        I agree that this would be a more interesting approach; I think you might need more incentives to create a flock though (aerodynamic benefits, predator protection, etc.)

      • ecto 21 hours ago

        Awesome idea!

    • jayGlow 21 hours ago

      based on the article the noida approach has better performance and is able to run on a GPU while the Sterling implementation must run on a cpu.

    • ecto 21 hours ago

      What happens when you want to simulate millions of rules?

      What if they weren't noids?

    • brcmthrowaway 21 hours ago

      Yeah, this is well presented slop.

      • ecto 21 hours ago

        Thanks!

  • titanomachy a day ago

    > That's the whole mechanism... Local perception. Local action.

    > it’s not communication. It’s physics.

    Dude, if you’re going to go to all the trouble to make something cool why don’t you take like 20 minutes to write in your own voice about it! I’m so tired of reading robot slop.

    • krtab 21 hours ago

      It's not even only a matter of tone, the content is just.. wrong and incoherent?

      > Each bird tracks about 6-7 neighbors. Not the closest by distance, but the closest by rank. Bird number 1 through 7, sorted by proximity.

      I mean, it sounds like it is exactly the 7 closest birds by distance?

      • ecto 21 hours ago

        Thanks I fucked that up! Updated to make the distinction clearer

    • ecto a day ago

      Thanks for the feedback :)

  • friendo_fez 20 hours ago

    Really great work! I would love to know how this could be extended to handle additional information. Things like walls and other environmental factors, pathfinding, keeping formations, etc.

    • ecto 20 hours ago

      Simply expand the observation vector!

  • esafak 21 hours ago

    Is this not just self organization?

    • ecto 21 hours ago

      Are you not entertained?

  • 21 hours ago
    [deleted]
  • herf 21 hours ago

    It's sad to see an LLM take over a blog, because you can see the line: before 2026 it's an interesting person you would like to talk to. After 2026, it's like generic LLM marketing-voice copy.

    • ecto 21 hours ago

      Thanks, which of my pre-AI blog posts are your favorite?

    • 21 hours ago
      [deleted]