Coding Adventure: Boids

แชร์
ฝัง
  • เผยแพร่เมื่อ 31 พ.ค. 2024
  • Trying to create some flocking behaviour, and getting a little distracted by spirals along the way...
    Links and Resources:
    Project source: github.com/SebLague/Boids/tre...
    Boids paper: www.cs.toronto.edu/~dt/siggrap...
    Points on a sphere: stackoverflow.com/a/44164075
    Fish shader: github.com/albertomelladoc/Fi... and www.bitshiftprogrammer.com/20...
    If you'd like to support the creation of more programming videos, I'd greatly appreciate your support on patreon:
    / sebastianlague
    Chapters:
    0:00 Intro
    0:26 The three rules of being a boid
    1:44 Obstacle avoidance
    3:03 Getting sidetracked by spirals
    6:12 Back to obstacle avoidance
    6:55 Obstacle course and optimization
    7:47 Swimming with the fishies
    Music:
    "Beauty Flow" Kevin MacLeod (incompetech.com)
    Licensed under Creative Commons: By Attribution 4.0 License
    creativecommons.org/licenses/b...

ความคิดเห็น • 1.8K

  • @jamesmnguyen
    @jamesmnguyen 4 ปีที่แล้ว +4737

    When you combined the boids and underwater marching cube projects. My mind got blown.

    • @Sparrow420
      @Sparrow420 4 ปีที่แล้ว +153

      all that's left now is to put this water/fish system into the eco system he did.

    • @SplashProductions556
      @SplashProductions556 4 ปีที่แล้ว +73

      I said out loud "Thats so fucking cool!"

    • @bsicyaroix
      @bsicyaroix 4 ปีที่แล้ว +19

      Then you definitely will like ABZU game.

    • @ap1evideogame44
      @ap1evideogame44 4 ปีที่แล้ว +34

      @@Sparrow420 I think he could make CoD Ghosts now, he has fish ai!

    • @ohboy1113
      @ohboy1113 4 ปีที่แล้ว +8

      I would buy that no cap.

  • @artem_hilia
    @artem_hilia 4 ปีที่แล้ว +3159

    Ok, now this series is really turning into Subnautica development

    • @KjipGamer
      @KjipGamer 4 ปีที่แล้ว +103

      This goes faster though

    • @WildAnimalChannel
      @WildAnimalChannel 4 ปีที่แล้ว +94

      Making the game is the easy part. The hard part is the other 99%.

    • @tomohawk5411
      @tomohawk5411 4 ปีที่แล้ว +18

      I really really like this comment

    • @andimakes
      @andimakes 4 ปีที่แล้ว +8

      @@tomohawk5411 i like it too

    • @bobobenniify
      @bobobenniify 4 ปีที่แล้ว +10

      I truly apreciate this picture (your profile image) very, very, very much.

  • @brandongreenland9632
    @brandongreenland9632 3 ปีที่แล้ว +1248

    "Me and the Boids at 2AM" was literally the first thing that popped into my head.
    Jokes aside, it looks fantastic!

    • @pikachu-jf2oh
      @pikachu-jf2oh 3 ปีที่แล้ว +1

      Or maybe you copied

    • @grownman9984
      @grownman9984 2 ปีที่แล้ว +10

      @@pikachu-jf2oh or maybe this is the original

    • @devesh7582
      @devesh7582 2 ปีที่แล้ว +11

      @@grownman9984 or maybe this is the simulation

    • @RASD87
      @RASD87 2 ปีที่แล้ว +6

      Actually watching this at 2am

    • @felipegutierrez3477
      @felipegutierrez3477 ปีที่แล้ว

      @@RASD87 2,05

  • @haph2087
    @haph2087 4 ปีที่แล้ว +2469

    Would that be called "Obstacle Aboidance"?
    I'll let myself out.

    • @benardnguyo6817
      @benardnguyo6817 4 ปีที่แล้ว +131

      @Haph try and aboid making such dad jokes in the future.

    • @arnav9009
      @arnav9009 4 ปีที่แล้ว +56

      @@benardnguyo6817 Ha, his jokes are so bad, his mind must be a boid.

    • @Squishy_yhsiuqS
      @Squishy_yhsiuqS 4 ปีที่แล้ว +82

      boids will be boids...

    • @azaroma
      @azaroma 3 ปีที่แล้ว +10

      Don't let the door hit you on the way out.

    • @NStripleseven
      @NStripleseven 3 ปีที่แล้ว +1

      H

  • @Rafale25
    @Rafale25 4 ปีที่แล้ว +3436

    Me and the Boids, watching a new great Coding Adventure

    • @SkylerMaki
      @SkylerMaki 4 ปีที่แล้ว +13

      lmao

    • @EctoMorpheus
      @EctoMorpheus 4 ปีที่แล้ว +72

      Cracking open a cold one with the boids

    • @Elliot.2591
      @Elliot.2591 4 ปีที่แล้ว +19

      You watch that new amazon prime series, “The Boids”?

    • @Rafale25
      @Rafale25 4 ปีที่แล้ว +4

      UGE Those Twitch ads are so annoying

    • @Elliot.2591
      @Elliot.2591 4 ปีที่แล้ว +2

      Rafale25 I binged it all it’s a good show. Flixtor.to is a website like Netflix but has EVERYTHING YOU COULD EVER WANT. I bought vip for rlly cheap.

  • @daniausimon8674
    @daniausimon8674 4 ปีที่แล้ว +2129

    This sphere raycast system using fibonacci sequence blew my mind, this is really awesome and very well explained ! Great series, please continue like this !

    • @SebastianLague
      @SebastianLague  4 ปีที่แล้ว +76

      Happy you enjoyed it :D

    • @DrOptix
      @DrOptix 4 ปีที่แล้ว +23

      @@SebastianLague Chapeau for your great explanations. I don't know why I feel that those coding explorations are actually really great dev logs and we may get a kick ass game after a while! Keep up the excellent work. I'm learning a ton from you and you inspire me to learn even more on my own.

    • @wupsje1
      @wupsje1 4 ปีที่แล้ว

      Yeah i’d love a more elaborate video on that!

    • @zedfalcon6972
      @zedfalcon6972 4 ปีที่แล้ว

      @@SebastianLague I saw something similar a while back, th-cam.com/video/rwV_dAlWWnw/w-d-xo.html video titled "N Equidistant Points on a Sphere"

    • @parasiticangel8330
      @parasiticangel8330 4 ปีที่แล้ว +1

      Should have just used spherical coords-choose angle1, angle2

  • @bleepboop
    @bleepboop 4 ปีที่แล้ว +2317

    "I don't need math, i want to make games" :D

    • @TheAero1221
      @TheAero1221 4 ปีที่แล้ว +233

      \*creates entire physics model\*

    • @TheAero1221
      @TheAero1221 4 ปีที่แล้ว +17

      @Holy Spiritual Practices Good to know. Imma keep it the way it is though, so people understand your comment.

    • @Selestrielle
      @Selestrielle 4 ปีที่แล้ว +32

      Tbf I make games and I'm completely lost with the above.

    • @Yamyatos
      @Yamyatos 4 ปีที่แล้ว +15

      @Holy Spiritual Practices It's not commented out tho. It's two nested opened multi-line comments... so this is not even the comments' final form!

    • @blasttrash
      @blasttrash 4 ปีที่แล้ว +6

      @@TheAero1221 backslashes? guess you are a diehard windows fan lmao. :P

  • @6Twisted
    @6Twisted 3 ปีที่แล้ว +464

    I love how you can put a few simple instructions into a computer and get something complex in return.

    • @DBR9009
      @DBR9009 3 ปีที่แล้ว +57

      "simple instructions"

    • @Jack-cw8bw
      @Jack-cw8bw 3 ปีที่แล้ว +21

      That's emergence for ya

    • @N3onDr1v3
      @N3onDr1v3 3 ปีที่แล้ว +16

      Emergent behaviour is almost always amazing

    • @basicallybrand
      @basicallybrand 2 ปีที่แล้ว +12

      Try doing it yourself. IT'S NOT SIMPLE.

    • @marcospatricio8283
      @marcospatricio8283 2 ปีที่แล้ว +4

      @@basicallybrand Specially if you remove some degrees of abstraction. The generation of points (the first part of the video) is rather simple in C. Try making that in assembly. Or take a look at how the video card interprets them. Making something complex from the most simplified instructions is the bloody purpose of computers.

  • @Danidev
    @Danidev 4 ปีที่แล้ว +3204

    That's so cool! Math and nature is crazy man, damn

    • @SebastianLague
      @SebastianLague  4 ปีที่แล้ว +339

      Thanks Dani! :) Yeah that stuff boggles the mind

    • @ullwy9269
      @ullwy9269 3 ปีที่แล้ว +26

      Dani?

    • @ullwy9269
      @ullwy9269 3 ปีที่แล้ว +3

      Martino Ericsson ik

    • @Adamimoka
      @Adamimoka 3 ปีที่แล้ว +16

      Hi Dani you got me into coding and I’ve watched nothing but coding for days. :)

    • @xcxp3226
      @xcxp3226 3 ปีที่แล้ว +6

      WOAH IT'S THE REAL DANIIIIIIIIIIIIIIIIIIIIIIIIIIII

  • @TheBrotherhoodofCadendale
    @TheBrotherhoodofCadendale 4 ปีที่แล้ว +786

    When you realize "boid" is just "bird" being spoken in a new jersey accent

    • @TonyWhitley
      @TonyWhitley 4 ปีที่แล้ว +73

      Spring is sprung, the grass is ris.
      I wonder where the boidies is?
      The boids are on the wing.
      Now isn’t that absoid?
      I always tort the wing was on the boid!

    • @notsure1969
      @notsure1969 4 ปีที่แล้ว +8

      Jersey birds are just pidgeons with bad attitudes.

    • @kinker31
      @kinker31 4 ปีที่แล้ว +2

      You catch on quick.
      Eggs?
      What about the eggs?
      Plastic!
      Yes, plastic, in whatever color you can think it!

    • @chessboy00
      @chessboy00 4 ปีที่แล้ว +1

      Craig Reynolds said the term is a contraction of birdoid... boid!

    • @easydarkunity9781
      @easydarkunity9781 3 ปีที่แล้ว +2

      Let the boidies hit the floor!

  • @OutlawJackC
    @OutlawJackC 4 ปีที่แล้ว +1146

    i could do this in my sleep
    i learned ' print("Hello world") ' yesterday so im pretty much a expert

    • @jasondeng7677
      @jasondeng7677 4 ปีที่แล้ว +106

      stop flexing on everyone 😭

    • @BeardedButter
      @BeardedButter 4 ปีที่แล้ว +41

      Ikr made a calculator... pretty much a god now

    • @nathann1445
      @nathann1445 4 ปีที่แล้ว +92

      @@BeardedButter I made a calculator in python that makes sence at the time.
      I remade it after I mastered python and it wont work

    • @TheAtlasRises
      @TheAtlasRises 4 ปีที่แล้ว +10

      @@nathann1445 lol

    • @RegahP
      @RegahP 4 ปีที่แล้ว +2

      bro how

  • @xianchen1935
    @xianchen1935 3 ปีที่แล้ว +77

    3:25 I can't get over how you drew this phi so beautifully

  • @mystisification
    @mystisification 4 ปีที่แล้ว +433

    This is so cool, do you have plan on brining the boids, worlds and ecosystem together to create a little planet ? Thanks for your work

    • @gustavowadaslopes2479
      @gustavowadaslopes2479 4 ปีที่แล้ว +18

      Maybe add even "land boids)

    • @FlyingDominion
      @FlyingDominion 4 ปีที่แล้ว +2

      @@gustavowadaslopes2479 Or rabbits and foxes.

    • @gustavowadaslopes2479
      @gustavowadaslopes2479 4 ปีที่แล้ว +12

      @@FlyingDominion They felt kinda stiffy compared to the boids.
      I guess if they get slightly deeper behaviors (camouflage, hiding and maybe tracking/smelling.

    • @memeymeemerson5426
      @memeymeemerson5426 4 ปีที่แล้ว +4

      @@gustavowadaslopes2479 I would love to see the ecosystem expanded on with more realistic behaviors.

    • @gustavowadaslopes2479
      @gustavowadaslopes2479 4 ปีที่แล้ว +4

      @@memeymeemerson5426 Yeah.
      I think seeing some sort of "ecosystem" for a game or simulation game being done animal by animal followed not only by evolution but also by new behaviors implemented and new environments.
      It would be like seeing a documentary about evolution on earth, but being able to use completely new environments and systems, while keeping everything considerably simple and engaging.

  • @Craig_Anderson
    @Craig_Anderson 4 ปีที่แล้ว +220

    The auto-generated subtitles at 0:05: "I'd like to play around with some boys"
    Well ok then

    • @kontoname
      @kontoname 4 ปีที่แล้ว +3

      Just saw this - legend :D

    • @ambrosxa
      @ambrosxa 3 ปีที่แล้ว +3

      Those are girls

    • @kakyoindonut3213
      @kakyoindonut3213 3 ปีที่แล้ว +1

      oh shit

  • @lewisnorth1188
    @lewisnorth1188 ปีที่แล้ว +23

    I love that the fish move out of the way when you get close to them

  • @altaudio555
    @altaudio555 4 ปีที่แล้ว +523

    You should add an enemy (e.g. shark?) like the rabbits and the foxes

    • @altaudio555
      @altaudio555 4 ปีที่แล้ว +5

      Xaracen for sure but if that would it would be mad

    • @Yamyatos
      @Yamyatos 4 ปีที่แล้ว +23

      @@xaracen7207 Not so sure about that. While it would eat quite a bit of performance, it should be doable on a decent computer if optimized accordingly. He does most things on the GPU since he learned about compute shaders, however there are also ways to utilize the CPU efficiently. The rather newly introduced Burst Jobs in Unity for example. Not only are they a comparably easy (and completely safe) approach at multithreading, the speedups are also pretty ridiculous. We are talking in the regions of factor 10-50x speedup. Properly utilizing the CPU with burst jobs, plus the GPU with compute shaders, would definitely allow for a pretty darn complex simulation to run smoothly. How complex or how smooth exactly will depend on the hardware, as always.

    • @DouglasEKnappMSAOM
      @DouglasEKnappMSAOM 4 ปีที่แล้ว +2

      @@Yamyatos Really it would not be that intensive. The eroded terrain would be baked. The bot code could be done with collision spheres triggering the code.

    • @ethanolcarbonyl4025
      @ethanolcarbonyl4025 3 ปีที่แล้ว +3

      Im not an expert in programming but i think that that would be easy... you just need to program the sharks to avoid obstacles and catch the nearest boid (group of things) and program it to do at random time

    • @official-obama
      @official-obama 2 ปีที่แล้ว

      Add shark hunger systems

  • @cartelrusso5992
    @cartelrusso5992 4 ปีที่แล้ว +123

    I like how you explain the algorithm in every video so enyone can implement it in any language (dx, opengl, vulkan ...) or engine.

  • @qm3ster
    @qm3ster 4 ปีที่แล้ว +80

    5:32 - God DAMN
    When that distribution got corrected, I FELT that!

  • @SkyTheLeafeon
    @SkyTheLeafeon 4 ปีที่แล้ว +117

    You're like the 3blue1brown of coding.
    You explain everything in a manner that can be understood very easily, and I like that.
    3blue1brown does math, while you do code.

    • @LabGecko
      @LabGecko 2 ปีที่แล้ว +3

      Bob Ross + 3B1B + Code
      Edit: Although 3B1B is kind of Bob Ross + Math, and (good) code includes math anyway, so I guess we can remove that overlap.

    • @writethatdown100
      @writethatdown100 ปีที่แล้ว

      @@LabGecko I feel like coding train is more like Bob Ross

  • @SaadTheGlad
    @SaadTheGlad ปีที่แล้ว +50

    I just noticed that your editing is absolutely masterclass. The effort put in to have what you say sink in to what we see is commendable. You're the best Sebastian Lague.

  • @krisztiannagy4953
    @krisztiannagy4953 4 ปีที่แล้ว +66

    Fun fact: the original Half-Life game includes a boids implementation. It can be seen in a scripted sequence as flying critters in Xen.
    If you search TH-cam for "half-life boids" the first video shows this.

    • @carlosmspk
      @carlosmspk 3 ปีที่แล้ว +4

      Yeah but they went with the "leader" approach, which is not as realistic. Still, great stuff to watch

  • @scattershotshow
    @scattershotshow 4 ปีที่แล้ว +64

    This is one of your best videos! The step-by-step visualizations as you implement each part of the code is seriously next level, and makes these really complex ideas far more palatable.
    Can't give enough praise for your work on this format. It's seriously fantastic. Keep up the awesome work!
    Also didn't realize you had a Patreon. Please give it a shout out in your next video so people know they can support you. Im signing up right now.

  • @Breadzticks
    @Breadzticks 2 ปีที่แล้ว +25

    When you make cool lookin stuff like this, make the showcase at the end longer please. The serene visuals and music were kickin, wish i could have watched that for a minute or 3.

    • @ThePond2023
      @ThePond2023 ปีที่แล้ว

      I wanted more of that end also, the stuff he makes is amazing.

  • @breezingwing7513
    @breezingwing7513 4 ปีที่แล้ว +65

    COD: *Revolutionary Fish AI!*
    ...
    Sebastian Lague: *Three lines of code*

    • @jabruli
      @jabruli 3 ปีที่แล้ว +1

      Came to the comments looking for this... To make it look even more real just add a huge repulsive force whenever something big happens in the game like shooting or so...

  • @JohnMcChungus
    @JohnMcChungus 4 ปีที่แล้ว +52

    I love these videos, I learn so much neat stuff from them! This is my favourite coding series, I can't wait to see what's next.

  • @grandmajojo5211
    @grandmajojo5211 3 ปีที่แล้ว +4

    Is nobody gonna talk about how mesmerizing it is. It looks like a school of fish.

  • @flaagan
    @flaagan 2 ปีที่แล้ว +16

    It would be interesting to see how the behavior changed if you added a predator with its own set of instructions and had the boids add in some sort of "avoid getting eaten" rule to their existing rules.

  • @cakeboy6422
    @cakeboy6422 ปีที่แล้ว +4

    I may be a 7th grader but that won't stop me from trying to understand These equasions.

  • @bensmith9253
    @bensmith9253 4 ปีที่แล้ว +30

    This video is FANTASTIC .
    Thank you so much for what you do!
    LOVE your work.

  • @ebreiny
    @ebreiny 4 ปีที่แล้ว +3

    I love watching these videos as it greatly inspires me to continue working on my projects and to get coding and learning more. Keep up the incredible work!

  • @stomachcontentz
    @stomachcontentz 3 ปีที่แล้ว

    Outstanding work. Your humility makes trying this myself infinitely less intimidating. Thanks for taking the time to make these videos Sebastian.

  • @marklondon9004
    @marklondon9004 2 ปีที่แล้ว +9

    I read somewhere that each bird only needs to be aware of 7 nearest neighbours. They probably estimate to remove the blind spot, too.

  • @exenerate6407
    @exenerate6407 4 ปีที่แล้ว +285

    How do you even come up with these things? Like, you start with a known example of individuals moving together in groups(boids), and end up with something that can be used as a 3D pathfinding solution.

    • @programereniscool
      @programereniscool 4 ปีที่แล้ว +71

      I did a Game Development study in Amsterdam and we covered most of these things (apart from the ecosystem). Next thing would be a particle-based fluid simulation. If you have an interest in this kind of topic you quickly find these fun challenges. He does go really in-depth into the topic which makes it really cool!

    • @tushargupta764
      @tushargupta764 4 ปีที่แล้ว +4

      @@programereniscoolwhere to find these fun challenges

    • @programereniscool
      @programereniscool 4 ปีที่แล้ว +16

      ​@@tushargupta764 Unfortunately, school is a big factor. Teachers really think their courses through. You can look for it yourself. If you see something interesting try to make it yourself. I personally really like optimizing, rendering and voxels. So now I am building my own game framework in C using Vulkan and Octrees. If I learn something new I apply it to this playground. Now you got to decide for yourself and create time to do some fun things that keep you motivated. Why did you get into programming in the first place? What inspired you?

    • @kaksspl
      @kaksspl 4 ปีที่แล้ว +2

      @@programereniscool What if someone wants to learn it all but can't go to programming school?

    • @programereniscool
      @programereniscool 4 ปีที่แล้ว +22

      @@kaksspl You can always learn by just doing. The hard part is figuring out what to learn next and to stay updated. Personally, if you are really serious about it you can check out the Open Source Computer Science Degree (github.com/ForrestKnight/open-source-cs ). This page has a lot of different courses that you can follow or you can use it to find out what courses you should know more about. Hope this helps a little!

  • @cinnamon9390
    @cinnamon9390 4 ปีที่แล้ว +6

    None of the senior thesis presentations I saw (before lockdown) were as interesting or as well done as this... and it looks like you make these videos super regularly. Subbed!

  • @Visigoth_
    @Visigoth_ 4 ปีที่แล้ว +9

    I really *REALLY* like the way you present what's going on in these videos (I'm not a programmer, and my math skills absolutely suck - but even I'm able to follow along with your logic progression).
    This is awesome!

    • @whoisj
      @whoisj 4 ปีที่แล้ว

      As a person who makes their living writing software professionally, I feel the need to tell you that programming is more about solving logic puzzles than about having solid math skills.

  • @thellamacorn8902
    @thellamacorn8902 4 ปีที่แล้ว +1

    The underwater scene you made at the end was so amazing! Even though it was just a simple and not very detailed map and some simple fish it really did feel like you were underwater! Amazing!

  • @Adrian_Fleck
    @Adrian_Fleck 4 ปีที่แล้ว +215

    best, do you want to make an erosion video in voxel space ?? would be super cool

    • @micaiahstevens8840
      @micaiahstevens8840 4 ปีที่แล้ว

      I may be off, but that is what his underwater scene was all about. Maybe your asking for a different technique.

    • @PKMartin
      @PKMartin 4 ปีที่แล้ว +17

      @@micaiahstevens8840 As I recall the terrain in the underwater scene just comes from using marching cubes to render a surface on some 3d perlin noise. Erosion is a technique for modifying terrain using simulated weathering processes to generate features that you don't see in pure noise-derived terrain (like sharp mountain ridges and valleys)

    • @micaiahstevens8840
      @micaiahstevens8840 4 ปีที่แล้ว +1

      Awesome thanks PKMartin. He did make an erosion video, but with meshes not voxels as well. NOT say I don't want more videos from Lague hehe!

    • @peterroe2993
      @peterroe2993 4 ปีที่แล้ว

      And the natural selection simulation built into the fish boids.

  • @Aoredon
    @Aoredon 4 ปีที่แล้ว +16

    I'm really happy that you're back, can't wait to watch this :)

  • @geraldlouis5099
    @geraldlouis5099 4 ปีที่แล้ว

    Wow, you have no idea how seeing these two projects together felt great. I dont know if you had that in mind from the beggining of this project, but it really adds up to the channel. Please continue building things that go along with those two.

  • @adammontgomery7980
    @adammontgomery7980 2 ปีที่แล้ว

    This is definitely the coolest mix of art and technology around. I don't think I would have thought to put those two projects together. It's obvious once you've done it, though I think you deserve credit for that apart from the whole.

  • @tfrascaroli
    @tfrascaroli 4 ปีที่แล้ว +173

    aaaaand 3 lines of code later it looks like magic, again. Why can't I code like that?!?!!?

    • @individuotipo
      @individuotipo 4 ปีที่แล้ว +30

      I think it is not about the code itself, but what he was coding. His starting point was a paper. His coding is beautiful, but the idea of coding a studied behavior is even better.

    • @bobshoaunng2038
      @bobshoaunng2038 4 ปีที่แล้ว +6

      Because if your code is well written in the first place, adding new features can be just as simple as adding couple of lines

    • @micaiahstevens8840
      @micaiahstevens8840 4 ปีที่แล้ว +12

      NOT to discredit Sebastian amazing work, but some of this is well documented code, he is adding his own flare for SURE. That's why its simple yet elegant its like taking 10 sebastians and making amazing code. He listed out some of their names. Including the original author of the Boids code. Almost like the author of Cellular life. IE the Game of Life, by Conway I think.

    • @pearz420
      @pearz420 4 ปีที่แล้ว +5

      probably too much grovelling and not enough study

    • @tfrascaroli
      @tfrascaroli 4 ปีที่แล้ว +5

      Sure, I get all of your comments. I'm a programmer myself, and we regularly code from papers (specially geometry stuff). But still, the fact that you can put < 50 LOC and get schools of fish freaking floating around your marching cubes terrain and avoiding your submarine... well, that's something else.

  • @GiannyDev
    @GiannyDev 4 ปีที่แล้ว +16

    Amazing video Sebastian. Flocking behavior is really an interesting subject. This leads to an Emergent behavior... How an object can react exclusively to its neighbor behavior. Awesome as always!

  • @timecubed
    @timecubed ปีที่แล้ว +3

    It's so fascinating to see little tiny cones swimming in air.

  • @sergeboisse
    @sergeboisse 3 ปีที่แล้ว +4

    Creating and evenly distributed set of points inside a disk is called phyllotaxis. Here is a javascript function that returns a function that gives the coordinates of the ith point in a phyllotaxis, ensuring that each point is separated from its neighbors by a distance d:
    function phyllotaxis(d) {
    var theta = Math.PI * (3 - Math.sqrt(5));
    return function(i) {
    var r = d * Math.sqrt(i), a = theta * i;
    return [
    r * Math.cos(a),
    r * Math.sin(a)
    ];
    };
    }
    // enjoy !

  • @trjrMedia
    @trjrMedia 4 ปีที่แล้ว +31

    the underwater exploration at the end looked super relaxing, i'd probably buy it if you added a few more features and sold it for like $10

    • @JNCressey
      @JNCressey 4 ปีที่แล้ว +8

      Looks like a good candidate for VR.

    • @geoffcunningham6823
      @geoffcunningham6823 4 ปีที่แล้ว +8

      Get Subnautica - it's awesome.

    • @noamweiss2244
      @noamweiss2244 4 ปีที่แล้ว +2

      Something like this? media.giphy.com/media/2xEAuD1mqqjk7ul1Pp/giphy.gif
      Beyond Blue is an underwater exploration game releasing this year on PC, Xbox1, PS4, and on Apple Arcade, if all goes well :)
      Come follow us on twitter.com/BeyondBlueGame
      (I can't speak to the actual price, probably a bit more than $10 but less than full priced)

    • @jamesmnguyen
      @jamesmnguyen 4 ปีที่แล้ว

      @@geoffcunningham6823 Yeah, but the simple graphics are really refreshing.

  • @aikatheshibainu3994
    @aikatheshibainu3994 4 ปีที่แล้ว +4

    Damm your coding skills are amazing! My favorite unity related channel on TH-cam 👏

  • @zaraf
    @zaraf 3 ปีที่แล้ว +2

    This is one my favorite coding adventure episode! It is just so satisfying to watch a computer simulate real life to such precision.

  • @Nkrasart
    @Nkrasart 3 หลายเดือนก่อน

    Man, I really enjoy your content. Pure professional and pleasant.

  • @EnraEnerato
    @EnraEnerato 4 ปีที่แล้ว +3

    Those fishes behavoir patterns look suprisingly real, this is rather fascinating!

  • @AceTheBlue
    @AceTheBlue 4 ปีที่แล้ว +67

    I must confess that thanks to you I have a newfound love and passion for using Unity and Compute Shaders for my simulation projects.
    If I may make a suggestion, would it be possible for you to go back to your planet generation code but maybe add a tectonic plates simulation to see how the planet would change its shape with time?

    • @leecaste
      @leecaste 4 ปีที่แล้ว +2

      WTF?! yesterday I was thinking exactly the same after watching those same videos. This would add another layer of realism to procedural planet generation. 🤤

    • @AceTheBlue
      @AceTheBlue 4 ปีที่แล้ว +2

      @@leecaste I wholeheartedly agree! Though from the few papers I've read regarding that, it seems quite convoluted.

  • @KingOmarcO
    @KingOmarcO 4 ปีที่แล้ว

    I’m learning to code on my own, and seeing what you can do with it I really motivating and enjoyable ! Thanks a lot , please continue !

  • @Kioselis
    @Kioselis 4 ปีที่แล้ว

    You're really inspiring, love these challenging little adventures, opens up your eyes.

  • @Music7Ada
    @Music7Ada 4 ปีที่แล้ว +5

    I just watched a man man virtual fish and honestly, amazing doesn’t begin to describe this.

  • @OrangeC7
    @OrangeC7 4 ปีที่แล้ว +6

    This is remarkably good for simulating fish! How interesting!

  • @florianestour3233
    @florianestour3233 4 ปีที่แล้ว

    I don't know what is better : Your animations and teaching, or your ideas and skills. Anyway, you are really smart and entertaining ! I really enjoy your genius videos !

  • @tnkspecjvive
    @tnkspecjvive 4 ปีที่แล้ว

    Man maaaann... Your teaching ability is insane. My respect, stunning job!

  • @Arnatious
    @Arnatious 4 ปีที่แล้ว +3

    Definitely try using a discretized vector field for performance gains - divide the space into voxels/pixels and assign a vector to each voxel. Each entity goes to neighboring voxels and adds a vector from the center of that voxel to itself, with magnitude falling off with distance. When a boid tries to find its neighbors, it subtracts its own field from the global field and averages the vectors of its neighbors. This gives a nice "pheromone" style approach like in ant colony simulations.

  • @dan0_0nad76
    @dan0_0nad76 3 ปีที่แล้ว +8

    I think I've just watched the coolest thing of my life.

  • @YasnaKo
    @YasnaKo 3 ปีที่แล้ว

    I`m absolutely in love with this channel, it`s very inspiring and my big thanks to Sebastian!

  • @Kanfutizer
    @Kanfutizer 2 ปีที่แล้ว

    I'm blown away by how you even find a point to start and then come up with the maths to do it

  • @rutgertenbrinke7827
    @rutgertenbrinke7827 4 ปีที่แล้ว +7

    I got distracted at 3:30 by the mesmerizing way the vortex moved

  • @rubenleejohnsen2037
    @rubenleejohnsen2037 4 ปีที่แล้ว +9

    I love your visual studio colour theme! Which one is it?

  • @techgamer1597
    @techgamer1597 3 ปีที่แล้ว +1

    Sebastian really makes some interesting and cool videos and makes them look easy using Unity which everyone can get for free. Much respect for this guy.

  • @michaeldougherty6036
    @michaeldougherty6036 3 ปีที่แล้ว

    Simple concept, elegant execution, insightful explanation. Brilliant! Subbed.

  • @akenny4308
    @akenny4308 4 ปีที่แล้ว +4

    8:10 if I could bottle up the feeling of excitement, pleasure, and satisfaction I got when this part came on, I’d be a millionaire. Seriously, well done

  • @weckar
    @weckar 3 ปีที่แล้ว +6

    I come back here every few months just to hear Seb say 'boiiids'.

  • @Cauks1
    @Cauks1 4 ปีที่แล้ว

    Gosh this is so beautiful. I've never seen something like it. Not just a coder, an artist.

  • @mehdimo6306
    @mehdimo6306 4 ปีที่แล้ว

    maaaan you are the boss !!! Haven't seen anything rapped up that clean before !! thanks for being there !!! 🙌🏽🙌🏽🙌🏽🙌🏽

  • @matthewspencer6669
    @matthewspencer6669 4 ปีที่แล้ว +14

    Whenever I watch Sebastian I realize I am a trash programmer.
    But what I have to remember is that Sebastian is world-class. It's like comparing yourself against Usain Bolt in running. Strive to be the best you can be and learn from giants, but don't compare yourself.

    • @GezGean
      @GezGean 4 ปีที่แล้ว +5

      What I exactly feel :(

    • @simonisenberg4516
      @simonisenberg4516 2 ปีที่แล้ว +2

      There is no linear scale of how "good" a programmer is. We're all made up of different strengths and weaknesses and tendencies. Sebastian has a very inquisitive and creative mind that drives him to dive deeper into lots of little aspects as many would and finding fun new experiments on the side. And he has(or rather takes) the luxury of having time and allowing himself to go off on tangents which often are rewarded with deeper understanding or snippets that can be used later or for something different or inspire a whole new project.
      I don't know what his job is or how much "professional" development he does but in some regards he might be considered a "bad" programmer. When he doesn't stick to a deadline, the scope get's bloated, maybe he has a difficult time concentrating on the task at hand, his code, while creative and doing what it should, may not fit well with others from a team or cohere to certain standards, might lack motivation when the project isn't challenging or interesting. There's just so many aspects and different coders are better suited for different tasks. Find your niche and strengths and decide if you really want to earn money with it or rather try to keep the passion alive as a hobby. Not that it's impossible to work on a passion project and make money with that but that's the holy grail of most professions or activities. Like right as I bought my first DJ equipment, I decided I never wanted to do that for money despite investing money into it. (actually DJed two weddings of family/friends, swearing never to do so again after both :D )

    • @hejsandu1215
      @hejsandu1215 2 ปีที่แล้ว

      @@simonisenberg4516 I'm honestly saving this for when I need it, nicely explained!

  • @thegreatwarrior1239
    @thegreatwarrior1239 4 ปีที่แล้ว +9

    Hey its Cod Ghost and we want our fish AI back.

  • @octosaurinvasion
    @octosaurinvasion 2 ปีที่แล้ว

    Every minute of the video, you're going the extra mile. Wonderful!

  • @lickow3820
    @lickow3820 ปีที่แล้ว

    Bro i just love this channel, for just few days i have learned some goegraphy,coud placement and fluid movment, how birds tend to form shapes, how was terrain formed, how does many cool ways of solving some programing problems work, lots of simulations on some math problems, and sooo on in just few days and it was all while showing us how to program all that and implement into a game, and all this was soooo iterestingly expalied that even i with adhd was soo drawn to his channel more that i would have been to some series, and i nearly forgot electronics how gates work how pc works how graphics card work and not just that but showed you how he learnd it so you can too and show you how to do it your self step by step, i mean im just blown out how usefuul would it be for children to learn from you cuz this whould be perfect knowlage for futre kids.

  • @jay-tbl
    @jay-tbl 4 ปีที่แล้ว +10

    Coding Adventure Guy: I want to program many individual objects to move around the field as if they were alive.
    Coding Adventure Guy, 2 minutes later: haha spirals

  • @Blaxpoon
    @Blaxpoon 4 ปีที่แล้ว +9

    5 episodes later: recreating the entire Earth

    • @shifanahmed3990
      @shifanahmed3990 3 ปีที่แล้ว +1

      this comment aged well

    • @l0k048
      @l0k048 3 ปีที่แล้ว

      @@shifanahmed3990 indeed xD

  • @irregular1430
    @irregular1430 3 ปีที่แล้ว

    I remember that when this video came out it was what introduced me and finally helped me understand rays in coding and stuff. This is still so cool to watch!

  • @lantinghsueh5537
    @lantinghsueh5537 3 ปีที่แล้ว

    I'm really enjoying your videos! I'm not a coder, but it's beautiful to see how you play around with the code.

  • @KsizaBoid
    @KsizaBoid 3 ปีที่แล้ว +8

    Damn. It took me 12 years to find out.
    But now I finally know the meaning of half of my nickname.

  • @123eee555
    @123eee555 4 ปีที่แล้ว +9

    That raycasting object avoidance solution seems really performance intensive
    I wonder if there is a better way

    • @ThePC007
      @ThePC007 4 ปีที่แล้ว +3

      Maybe you could loop through all nearby objects (using the spacial partitioning scheme shown in the video) and just calculate the distance and angle towards their center?

    • @bigboobmasterbaiter69
      @bigboobmasterbaiter69 4 ปีที่แล้ว

      more intense than twice your existence

    • @bearwynn
      @bearwynn 4 ปีที่แล้ว +3

      @@ThePC007 looping is pretty intensive, the less you can do the better.
      The best solution for performance is to calculate the raycast vectors at the start, so that you only ever have to calculate the directions once.
      Then, whenever a boid checks for a direction it's not doing all the turn fraction stuff and instead is just looping through an array of vectors.
      You can also adjust how many directions would be generated at the start if you wanted a less detailed obstacle avoidance, decreasing the amount each one would loop.
      The most performance intensive part other than calculating neighbours is actually iterating through each boid and applying their new movement vector.

    • @ThePC007
      @ThePC007 4 ปีที่แล้ว +2

      @@bearwynn If you use the partitioning scheme the looping shouldn't be _that_ intensive and depending on how you store the coordinates of the boids (preferably in an array consisting of only the coordinates themselves (and not a pointer to their object or anything)), then you could loop through them with very few cache misses, which would make it pretty fast. Calculating their distance and angle should be fast as well, since (I believe) you could even drop the square root part of the distance formula entirely.

    • @hi_im_a_kookie
      @hi_im_a_kookie 4 ปีที่แล้ว +1

      There aren't many optimizations if we want to keep using rays in a classic "does the ray hit the triangle" way.
      But in this case we don't really care about precise surface collisions, just a rough idea of whether or not e.g a random background fish is about to swim through a wall or something. So we can optimize this significantly by by precomputing a 3D grid or octree and simply marking a given cell as solid or empty. Now we only need see if a vector passes through any solid cells, which is much easier than looking for ray-triangle intersections.
      Of course, once we have a simple integer-aligned grid like this, we can make a bunch of additional assumptions and optimizations. But I'll leave this as an exercise for the reader.

  • @michaelbeeler7461
    @michaelbeeler7461 4 ปีที่แล้ว

    I have always been fascinated by boids and recently became enamored with spatial partitioning techniques. Great video

  • @maify13
    @maify13 2 ปีที่แล้ว +1

    Very nice. I find very amazing that you can combine Math and nature. It seems so fun and interesting to watch you.

  • @mikaxms
    @mikaxms 4 ปีที่แล้ว +3

    [Dunkey Voice] Procedural Subnautica baby!

  • @bartekm3878
    @bartekm3878 4 ปีที่แล้ว +3

    Wow! Amazing video. I love those coding adventures. I've got 3 questions:
    1. Wouldn't it be easier if you used the Job System instead of compute shaders?
    2. Where do you get the ideas and inspiration for coding adventures?
    3. When is the next episode of the neural network series coming?

    • @AramilAnakir
      @AramilAnakir 4 ปีที่แล้ว +1

      It definitely wouldn't be faster using JobSystem. It spreads things on CPU Threads. There are far more on GPU.
      The rest of questions... I don't know :D

    • @bartekm3878
      @bartekm3878 4 ปีที่แล้ว

      @@AramilAnakir Thanks for the answer.

    • @noamweiss2244
      @noamweiss2244 4 ปีที่แล้ว +1

      The Job System is definitely easier than compute shaders. It's also extremely fast when using the Burst Compiler. Compute shaders still have the potential for much more performance, if done right. We're using the Jobs+Burst for the same thing (but not entities), and using compute shaders for occlusion and indirect instanced rendering. I've been wanting to move the Boid code as well but haven't had the time. Right now I can get 50k+ fish reliably, I'm temporarily blocked by some data copying (yeah, take time!) and a bug with the GPU sorting that limits me to 65k instances for now.
      Here's an example of how our game looks: media.giphy.com/media/2xEAuD1mqqjk7ul1Pp/giphy.gif
      Beyond Blue is an underwater exploration game releasing this year on PC, Xbox1, PS4, and on Apple Arcade, if all goes well :)
      Come follow us on twitter.com/BeyondBlueGame
      :)

    • @bartekm3878
      @bartekm3878 4 ปีที่แล้ว +1

      @@noamweiss2244 Woah! Such a smooth transition between answering a question in comment to promoting your game. You clever.

  • @minorseven8134
    @minorseven8134 ปีที่แล้ว

    Very inspiring to watch + cool result + cute dog profile picture = perfection.
    Thanks for creating this

  • @pale_whitey
    @pale_whitey 4 ปีที่แล้ว

    The coolest coding video I've seen thus far. Great work!

  • @levifzephyr
    @levifzephyr 3 ปีที่แล้ว +8

    Hi @Sebastian, don't know I you ll read this, but I just loved the ending, going from completely off track abstract Fibonacci sphere to... Actual usage for fish behavior! Just drop my jaw! I loved both the idea and the result.
    Enjoy your deep sea journey :)
    🕊️ => 🐟 🐠 !? 🤯 ... 😍

  • @ruinsage2677
    @ruinsage2677 4 ปีที่แล้ว +11

    I'm gonna stea- COUGH COUGH I mean cop- COUGH COUGH I mean look into this on my own and make my personal* implementation.......

    • @genericytprofile852
      @genericytprofile852 4 ปีที่แล้ว +6

      Well I mean most coders aren't afraid to say they borrowed a few ideas from here and there. Especially if it's free to use. Why build say an entire system from scratch when someone has already done the feature you want?

    • @ruinsage2677
      @ruinsage2677 4 ปีที่แล้ว +2

      @@genericytprofile852 true, but it's also bad practice to copy entire sections without understanding them ;)

  • @rudolfsykora3505
    @rudolfsykora3505 4 ปีที่แล้ว

    This is very sophisticated explanation. Its pleasure to listen your voice

  • @jasonguest6516
    @jasonguest6516 3 ปีที่แล้ว

    That's gotta be one of the coolest programming projects I've seen, gonna try this now thanks

  • @slyguy8808
    @slyguy8808 4 ปีที่แล้ว +3

    Usually when watching these videos, I do not understand half of what he says. Does it get better over time?
    Still, they are very interesting to watch.

  • @boredman4687
    @boredman4687 4 ปีที่แล้ว +3

    I swear Sebastian. You could recreate the universe if you tried.
    Make a randomly generated spherical planent (which you've done), add an also randomly generated ocean (also done) apply Darwinism to the fish you've made. Calculate your rain water erosion with real time clouds and plop a third person character on said planet.
    Combine all the things you've already done and you've got a game far better than all those AAA games. Make it an Rpg simulation game charge $20 and you'd make millions.
    You've been my coding hero since High school. Keep at it, your videos always make my day :)

  • @bitgalaxis1147
    @bitgalaxis1147 4 ปีที่แล้ว

    From start to finish, every bit of this video was impressive.

  • @ricardsvilipsons2988
    @ricardsvilipsons2988 4 ปีที่แล้ว

    These things are so fascinating, i love these series

  • @calvin311222913
    @calvin311222913 4 ปีที่แล้ว +5

    0:13
    No one:
    Touhou players: put their cursor on the screen and start dodging

  • @landru27
    @landru27 4 ปีที่แล้ว +5

    As soon as you said "a nice irrational number" at 3:01, I thought instantly of this Numberphile video : th-cam.com/video/sj8Sg8qnjOg/w-d-xo.html
    There is an immense overlap between this aspect of your direction-picking function and that video. And, the Golden Ratio is in fact *the most* irrational number, and that Numberphile video explains exactly why (watch all the way to the end). I'm mentioning it because of your clearly evident joy becoming sidetracked by the beauty of the underlying math. (100% with you on that, by the way!) Cheers!

    • @karolakkolo123
      @karolakkolo123 3 ปีที่แล้ว

      That's exactly the video I thought about lol that was one of the best Numberphile videos imo

  • @AissurDrol
    @AissurDrol 4 ปีที่แล้ว

    Not sure why this popped up in my recommendations, but it's actually very useful to me. I haven't looked up coding or math videos in a very long time, but today I'm doing some programming on a project involving lighting and the point distribution stuff will be very helpful to me. Thanks for uploading!

  • @guylianwashier4583
    @guylianwashier4583 4 ปีที่แล้ว +1

    I don't know why, but when you said you were going to swim with the fishes, and the video cut to you actually swimming with them I felt an immense sense of hapiness. This is a very nice video, keep it up!

  • @maugre316
    @maugre316 3 ปีที่แล้ว +3

    5:44 looks like the start of some pretty cool spiral galaxy rendering. Maybe a future part of your solar system series?

  • @mreverything7056
    @mreverything7056 3 ปีที่แล้ว +8

    People who watch JoJo already knowing about the golden ratio: The kool kidz

    • @kyle_mk17
      @kyle_mk17 3 ปีที่แล้ว

      th-cam.com/video/tLyRpGKWXRs/w-d-xo.html

    • @seniorvenusdigital3904
      @seniorvenusdigital3904 3 ปีที่แล้ว +1

      normal people who already know about the golden ratio because its the most common ratio in nature and commonly taught: shut up you are special for watching a shitty anime

    • @user-db2dx8pf9y
      @user-db2dx8pf9y 2 ปีที่แล้ว

      @@seniorvenusdigital3904 tell us why jojo is shitty

  • @maugb17
    @maugb17 4 ปีที่แล้ว

    Godamn, this is so cool. Lovin’ this coding adventures man, awesome work👌👌

  • @rohingosling
    @rohingosling 3 ปีที่แล้ว

    I love your work. So clean and elegant.