The code behind Particle Life

Sdílet
Vložit
  • čas přidán 14. 04. 2023
  • Download (Windows 64-bit): particle-life.com
    Source Code: github.com/tom-mohr/particle-...
    Discord Server: / discord
    Particle Life is a very simple particle system. This video explains the code behind this simulation, that shows the emergence of incredibly beautiful life-like structures from rudimentary rules.
  • Věda a technologie

Komentáře • 62

  • @tom-mohr
    @tom-mohr  Před rokem +8

    For more in-depth discussions about Particle Life, join our discord server :) discord.gg/Fd64AhKzMD

  • @MrHichammohsen1
    @MrHichammohsen1 Před rokem +28

    The mind blowing thing is that for someone whom have never coded in their life, been able to copy the code and create life like movement! This is mind-blowing thank you!

  • @Zicrus
    @Zicrus Před rokem +22

    9:42 Unless if that fast programming language runs on the GPU ;) I made my 6 year old laptop run 15k particles without space partitioning with over 60 fps. And on top of the simulation itself, it also runs a 1600x1600 wave simulation on the RGB color channels to create cool rainbow waves behind each particle when they move. And on top of all that it also calculates stereo sound for every particle. GPU's are so fun :)

    • @000pava
      @000pava Před 8 měsíci +1

      Wow! Do you have a video of that?

  • @victormultanen1981
    @victormultanen1981 Před rokem +7

    Thank you for the explanation of behind the scene of particles life software. I appressiate it.

  • @prietjepruck
    @prietjepruck Před rokem +4

    I did write my own code and it is very interesting to see how you wrote yours. Thanks for sharing it.

  • @pa0lo016
    @pa0lo016 Před rokem +3

    YES !! I've been waiting for something like this, thank you.

  • @jaredf6205
    @jaredf6205 Před 2 měsíci +1

    I put the transcript of this video into ChatGPT and it was able to make this in html for me.

  • @CallmeSam00
    @CallmeSam00 Před 4 měsíci

    I love simulations like this! You rock

  • @creative_cooper
    @creative_cooper Před 5 měsíci +2

    Brilliant. I personally believe models like these are a stepping stone to fully understanding the protein folding problem. I particularly like the concept of the attraction vector, just need to figure out the attraction vector for all amino acids and water.

    • @jumpstar9000
      @jumpstar9000 Před 5 měsíci

      protein folding was pretty much solved a few years ago by alphafold

    • @creative_cooper
      @creative_cooper Před 5 měsíci +1

      @@jumpstar9000 not true, alpha fold only got a 90% success rate, which allows room for improvement. Besides, Alphafold is a black box model, unlike this one which is derived from first principles, which makes it more interpretable.

  • @PooperScooperTrooper
    @PooperScooperTrooper Před rokem +2

    This is really cool. I've been playing with my own hack of something similar so this will get me back into a reckon! Thank you!

  • @js267
    @js267 Před rokem

    Thanks for sharing!

  • @jaisonveigas4998
    @jaisonveigas4998 Před rokem +8

    One request for next video.
    Can you relate the third dimension of the particles to its size. So that when the particles move around they appear large as if it's closer and smaller as if it's far. I really want to see how this would turn out.
    Thanks in advance
    Awesome content. Please keep doing such videos

    • @darrennew8211
      @darrennew8211 Před 5 měsíci

      Alternately, draw it twice in perspective from two different angles and use cross-view to view the depth. :)

  • @digit5911
    @digit5911 Před 7 měsíci

    Can you please tell me how you made it so the particles wrapped around easily

  • @theHiddenStone
    @theHiddenStone Před 2 měsíci

    Have you tried giving each particle type different friction properties? Would be interesting to see how things interact.

  • @megauti
    @megauti Před 5 měsíci

    Thank you very much.

  • @spinthesphere2746
    @spinthesphere2746 Před rokem

    I really like the world view‼

  • @korigamik
    @korigamik Před 5 měsíci +2

    Broo could you share the source code for your animations? If love to learn from them

  • @danielcezario2419
    @danielcezario2419 Před 6 měsíci

    Amazing!!!

  • @soketsu
    @soketsu Před 5 měsíci

    These are good times.
    I can find a study that I know nothing about, and I am free to research it further.

  • @domahidipeter6092
    @domahidipeter6092 Před 5 měsíci

    There are collision detection?

  • @AS-ws9pp
    @AS-ws9pp Před 5 měsíci

    Can this be done on CUDA or Vulcan?

  • @k4rli_475
    @k4rli_475 Před 29 dny +1

    is there any way to make it in 3 dimensions or 4?❤

  • @dkm4470
    @dkm4470 Před 4 měsíci +1

    Have been programming similar ideas myself but now I adopted some important insights from your take. Amazing man!
    Thing is I can only render 800 particles fluently at max. Could you please elaborate or give me some hints on the space partioning thing?

    • @dkm4470
      @dkm4470 Před 3 měsíci

      ​@@Romenamath I'm currently using tensor operations, thinking that would be the fastest way to do it. This might need a workaround then but I'll try. Thanks!!
      Also I feel like replotting the frame each iteration is what takes the most energy here since it needs to go through all particles in the storage vector anyway. While we're at it, any suggestions on the plotting part?

  • @josesantos2603
    @josesantos2603 Před 8 měsíci +1

    What if particle life be applied to search algorithms?🤔 Considering that ideas may be like theses particles, they can either be attracted to each other or not...

  • @RoySchl
    @RoySchl Před rokem +6

    I already made my own just from seeing your tweets and videos that described whats happening, but damn mine is so so much slower when driving up the particle count.
    I tried an octree as optimization, that did not help.
    I made it into a compute shader to run it on the gpu, which helped a bunch, but it's still way slower than yours.
    I think your math is simpler because you use a 1 to 1 attraction matrix and I use a list of attraction pairs.
    The one advantage of that approach is that I can have 2 types of particles be attracted at one range and repulsed at another range and everything in between, which produces different results that are impossible to reproduce with your method.
    But damn, that speed would be really nice to have :D

    • @tom-mohr
      @tom-mohr  Před rokem +3

      Cool! :) You could still pick the maximum possible distance of interaction from all your ranges and then do a space partitioning based on this. Don't use a quadtree, just use a grid with boxes of size r_max. That's way easier to implement (still might take some hours to debug until it's working) and actually better at improving speed than a quadtree.

    • @RoySchl
      @RoySchl Před rokem +1

      @@tom-mohr yeah the quad tree might have been over kill and takes more time to recalculate than it would to not use it at all :D

    • @Zicrus
      @Zicrus Před rokem

      @@RoySchl How fast was your compute shader? I was able to get it to run over 15k particles at 60 fps on a 1050 ti laptop. And I still have yet to try space partitioning, but I do have a plan for that.

    • @RoySchl
      @RoySchl Před rokem +1

      @@Zicrus depending on how many rules I use, but with 10 rules I get maybe 4k particles at 60fps on a 3060Ti...
      Guess my code is either terrible or the slight increase in complexity with my multi rule approach is enough to slow it all down.
      I also used unity, so who knows
      Still a fun project

  • @dreamtutorials1015
    @dreamtutorials1015 Před 5 měsíci

    What about 3D?

  • @M1KEMEX
    @M1KEMEX Před měsícem

    I don't understand what you changed in the code to make it render in 3D. Long time ago, when GPUs were not common, I tried to write a 3D engine and I remember that you had to make trigonometric stuff to make projections. But I don't see any of that in your code...

  • @seanalexandertricks
    @seanalexandertricks Před 10 měsíci +1

    Can you do particle life with gravity?

    • @seanalexandertricks
      @seanalexandertricks Před 10 měsíci

      I mean a gravity environment, like making them all fall to the bottom with a floor and seeing if they can form organisms on the ground.

  • @TheCaphits
    @TheCaphits Před 4 měsíci

    Please for the love of god make a 3d version of this. Holy smokes.

  • @Dunch0717
    @Dunch0717 Před 11 měsíci

    Watching this at 3 am and acting like I know the first thing about coding in python

  • @matthewe3813
    @matthewe3813 Před rokem +2

    Well if 3D is so easy, maybe its time for 4D particle life

    • @homelikebrick42
      @homelikebrick42 Před rokem +6

      upgrading to 4d would be just as trivial as doing 3d, you just add another component
      the slightly hard part would be rendering it

  • @SolathPrime
    @SolathPrime Před rokem

    Actually JavaScript is brilliant cause of it's ability
    To be embedded directly from you web browser
    Meaning theoretically speaking someone can code
    It on mobile I don't say it's efficient but it's possible

  • @RabarberBarbar70
    @RabarberBarbar70 Před 9 měsíci +2

    It would be great if you can share this code as a download. Copy the code from the video takes a lot of time and is buggy. I'm currently working on a p5.js version of a particle life script and looking for different methods of calculating the forces.

  • @unveil7762
    @unveil7762 Před rokem

  • @alexandrubusuioc6800
    @alexandrubusuioc6800 Před rokem

    8:20 I'm trying to implement the "force" function in python WHERE CAN I FIND DOCUMENTATION

    • @tom-mohr
      @tom-mohr  Před rokem +1

      I might be able to help you if you pose a more precise question

    • @alexandrubusuioc6800
      @alexandrubusuioc6800 Před rokem

      you used a function called force when calculating the change in velocities at 8:20 and i cant find documentation

    • @alexandrubusuioc6800
      @alexandrubusuioc6800 Před rokem

      @@tom-mohr that is all i know

    • @tom-mohr
      @tom-mohr  Před rokem +2

      It's literally 20s after this in the video, and also a few minutes before that

    • @alexandrubusuioc6800
      @alexandrubusuioc6800 Před rokem

      @@tom-mohr sorry, i was really angry and i didnt think to check...

  • @ratuadilFF
    @ratuadilFF Před rokem

    Gak Mbah, aku gak bakal kasih kucingku macam2 dia hanya bantu disini ngamanin dari tukis

  • @PlayOfLifeOfficial
    @PlayOfLifeOfficial Před 6 měsíci

    Make more videos +1.

  • @ratuadilFF
    @ratuadilFF Před rokem

    Aku ngabisin uang ? Kerjaannya hanya ngabisin uang ga ngasilin uang?
    OOO gitu, mereka bingung?
    Kan aku kerja Mbah,

  • @FlooferLand
    @FlooferLand Před 7 měsíci

    this is how you know Rust is good. you can even make life and living organisms in it lmao

  • @ratuadilFF
    @ratuadilFF Před rokem +1

    Kucingku ? Jangan kasih pil KB?
    Aku ga pernah beli pil KB, buat apa ? Supaya kucingku ga bunting?
    Aku sudah ngomong sama kucingku, ngewe aja sesuka kau! Asal jangan bunting dulu, kalo mau bunting taruh anaknya di rumah Bu Joko, kalo makan boleh disini

  • @k4rli_475
    @k4rli_475 Před 29 dny +1

    i don’t understand coding but i try to learn it with chat-gpt rn (i don’t need any teachers in my comments but u can write some tips)❤