Create Artificial Life With Simple Rules - Particle Life Explained In JavaScript

Поделиться
HTML-код
  • Опубликовано: 2 окт 2024

Комментарии • 1,2 тыс.

  • @clfleishman
    @clfleishman 2 года назад +1798

    If you came up with this you’re a genius. Even if you got inspiration from other projects making something with that little code that can simulate these complex emergent properties is a huge achievement

    • @brainxyz
      @brainxyz  2 года назад +579

      Thanks for the compliment. This project was inspired by Ventrella's Clusters (the link is in the descriptions). Once I wrote the code, I spent the entire month trying to make the code as concise as possible and as educational as possible. Hopefully, this presentation inspires more work on investigating emergent patterns from very simple rules.

    • @christianremboldt7028
      @christianremboldt7028 2 года назад

      ruclips.net/video/makaJpLvbow/видео.html

    • @HardcoreMontages
      @HardcoreMontages 2 года назад +21

      no, this isn't an original idea.
      Code Parade did it first.

    • @reversev9778
      @reversev9778 2 года назад +167

      @@HardcoreMontages code parade was nowhere near the first

    • @commenturthegreat2915
      @commenturthegreat2915 2 года назад +262

      Guys, these things have existed for decades. Nearly every youtube coding series out there is drawing upon earlier research and isn't a breakthrough in of itself. The beauty here isn't "being original", it's presenting things in a simple and accessible way.

  • @andreasnesse04
    @andreasnesse04 2 года назад +100

    Now make it 3d

  • @joshmyer9
    @joshmyer9 2 года назад +672

    I wonder how much more emerges if we make the rule coefficients a function of a common parameter (we can call it "temperature"), then have that variable go through a "day cycle" of sin(t). This might make some of the very unstable/twitchy patterns more stable for a bit, and vice-versa. Or make t itself a function of (x,y) and make warm/cool pockets with different stable patterns, swapping particles between them.
    Lots of neat stuff to play with here, thanks for sharing it!

    • @WomboBraker
      @WomboBraker 2 года назад +7

      Thats a cool idea

    • @giannipiccioni8411
      @giannipiccioni8411 2 года назад +18

      slightly differences in the game rules with add exponentially more complex structures. Like in real life

    • @AlissonNunes
      @AlissonNunes 2 года назад +12

      Isn't "temperature" the "value" of how much particles moves? At a certain point, some measurements that we use at normal level doesn't apply to molecular level

    • @AlissonNunes
      @AlissonNunes 2 года назад +8

      The "temperature" increases by the sun that emits radiation (photons), which are more molecules... Or I'm just being dumb

    • @joshmyer9
      @joshmyer9 2 года назад +30

      @@AlissonNunes Not dumb, but I do think you're taking the model a little too literally (which his presentation kind of encouraged). This model is too simple to capture anything like that level of detail. It gives us big picture, super hand-wave-y patterns, which is neat, and helps guide one's thinking for more fine-grained problems.
      This is why I said "call it" temperature: it's a kinda-sorta analogue for temperature within the very coarse-grained model we're using.
      Honestly, my motivation is entirely to make it fun to watch for longer. It's a bummer that each model stabilizes to a static state, though. I'm mostly interested in finding ways to make it visually interesting for longer spans of time =)

  • @NorthernHurricane7
    @NorthernHurricane7 2 года назад +124

    While Conway's Game of Life has been impressive for a long time, the striking part of this adaptation is the organic way the movement, shapes, and patterns appear. There are a number of ways to use this approach to visualize concepts about chaos, probability, prediction, and determinism in systems. The first-principles development approach to set it apart from similar programs is the cherry on top. It looks great!

  • @ecliptic2ecliptic111
    @ecliptic2ecliptic111 2 года назад +577

    I've never seen an algorithm of this simplicity granting such lifelike behavior. Truly Impressive

    • @Mushele
      @Mushele 2 года назад +15

      game of life

    • @estebanod
      @estebanod 2 года назад +20

      @@Mushele game of life is nowhere near a living cell simulation

    • @Mushele
      @Mushele 2 года назад +20

      @@estebanod neither is this

    • @Mushele
      @Mushele 2 года назад +16

      @@estebanod the point is, the game of life shows very well, just like this demonstation that we see above, that a set of very simple rules can produce very complex and unpredictable behaviours(just like in real life)

    • @RavenMobile
      @RavenMobile 2 года назад +20

      @@Mushele This is far closer to representing emergent life coming from simple rules than Conway's Game Of Life. I absolutely love Game Of Life, but this looks like what one sees from microscopes. Cells consuming other cells, cells losing their cell wall and leaking their insides, cells that are highly active, other cells that are mostly stagnant, etc.

  • @nick2629
    @nick2629 2 года назад +5

    You are a genius

  • @Daniel-Davies-Gonstead-Student
    @Daniel-Davies-Gonstead-Student 2 года назад +81

    As a person who has never coded before but is interested in biology this was really cool!

    • @ruffianeo3418
      @ruffianeo3418 2 года назад +10

      Computers and code are the most accessible facsimile to a generic laboratory. Be it some finance stuff, physics, biology, quantum mechanics - whatever - if you take an interest and want to see how an idea pans out, coding is the way to go. Frankly, it even teaches respect to all those scientists before the computer age, who managed to produce useful insights without computers :) But today, anyone should be able to code a little, so they can use it as a tool of learning.

  • @bencressman6110
    @bencressman6110 2 года назад +49

    Dude, this was so, so well done! From the pacing, to the code walkthrough, open source, pop culture reference, music, video length. Superb. I love artificial life, and this is so exciting to see. You discovered some really dope paramaters

  • @nowar452
    @nowar452 2 года назад +315

    Very cool project!
    It's not really a life simulator. It's more like simulating chemistry from another dimension.
    If you add here not only particles, but also waves, you get a quantum physics simulator!

    • @lemming7188
      @lemming7188 2 года назад +7

      How could one go about adding waves to a program like this?

    • @francovillarreal7266
      @francovillarreal7266 2 года назад +40

      @@lemming7188 Divide the screen into a grid, and give each cell a vector, make the cells influence their neighbors, make them change color depending on the intensity of the vector.
      Some thing like that, thou I'm sure there are dozens of ways of implementing this, and probably all of them run faster than my idea.

    • @nowar452
      @nowar452 2 года назад +7

      @@lemming7188 wery good question. My suggestion about waves is more joke than offer. But i think waves could be a carrier's of powers like in real world. The simulation have a lot of powers. Every link between particles with different color is power. Every power would be an elastic plane and every particle would pertrub the plane. Waves move on plane and influence to other particles.
      Of course, it is very complicated. And it will be absolutely not same programm.

    • @christhorne116
      @christhorne116 2 года назад +7

      Hmmm whoop whoop pump the brakes there sonny…just adding waves will NOT give you QM

    • @zarinavarina8580
      @zarinavarina8580 2 года назад +1

      @@christhorne116 Adding stochasticity to maxwellian electrodynamics is enough to produce the results of QM in the linear regime. Adding non-local sources (wave-like rather than point-like) to that would probably be enough to capture at least some of the non-linear QM phenomena.

  • @mauritspuggaard4689
    @mauritspuggaard4689 2 года назад +23

    Currently studying computer science at university, and this dude is one of the reasons I love what I do and keeps getting inspired. Keep up the good work, you’re a legend!

  • @GuilherminoBr
    @GuilherminoBr 2 года назад +36

    This is one of the coolest life like simulations I have ever seen

  • @pocketallen1051
    @pocketallen1051 2 года назад +12

    it's real amazing product I have seen. It demonstrates how complexity is emergent from simple rules. Thank you

  • @katungwakioko465
    @katungwakioko465 2 года назад +25

    I'm a python and coding beginner and such projects are an inspiration to continue learning and not give up. To me, this is a masterpiece even if I don't understand the code. Thank you.

  • @SeanStClair-cr9jl
    @SeanStClair-cr9jl 2 года назад +62

    Wow. I've seen these kinds of simulations before, but what I was not expecting was this level of production and entertainment. Cool stuff, hope your channel gets the subs it deserves!

  • @devfromthefuture506
    @devfromthefuture506 2 года назад +11

    I would really like to see this code running in 3d in a software like blender

    • @OffbrandDrPhil
      @OffbrandDrPhil 2 года назад

      That would be pretty insane... I think it would be easiest to create in the open source node-based programming language Processing with the P3D renderer.

    • @captainvenom7252
      @captainvenom7252 2 года назад +2

      I am gonna do this but instead of blender am using a 3d game engine Coppercube

    • @FoivosApostolou
      @FoivosApostolou 2 года назад +1

      @@captainvenom7252 If you ever do that, I would love to use footage for a music video :) Good luck!

  • @carel91
    @carel91 2 года назад +26

    This is not just perfect presentation of amazing simulation with source code, code walkthrough tutorial, but also metaphysical essay with humor and great images. I am really thankful for your work. Thank you. I will be pleased to try your program and to code my from your tutoring. Amazing

  • @bacillusanthracis9073
    @bacillusanthracis9073 2 года назад +16

    Super interesting. In some of these simulations, there even were shapes ressembling cell division and macrophages phagocyting !

  • @josephcoon5809
    @josephcoon5809 Год назад +2

    1:30 I’ll have to make this quick since it’s my bedtime…
    A thought occurred to me about H.P. Lovecraft’s “Blind Idiot God”: Azathoth.
    Azathoth is the most powerful of the Old Ones. In his slumber he created the reality in which we reside. Should he waken, it is hypothesized that reality would end. So, in his unconscious state he is unaware of all the billions of souls that he has created just as most of them are unaware of him.
    Each neuron has its own level of consciousness, and as they form larger groups, that level of consciousness also grows. However, neurons are only conscious of the neurons they communicate directly with just as higher order neurons are only conscious of the neurons they are directly connected with. So a neuron that considers the data of the millions of neurons beneath its consciousness has a level of consciousness which is the accumulation of all the consciousnesses beneath it. This makes THE consciousness that is “you” like Azathoth. For most of us, we are unaware of the billions of consciousnesses that incorporate to become “the self” we all understand. The problem with being unaware of those billion consciousnesses is that we are responsible for the ideas they come together to represent.
    A neuron’s individual purpose is to be part of a group to represent an idea. As a neuron, they have no idea what idea they are apart of. All they know is that when that idea is thought, they activate and receive resources. Not knowing what idea they are apart of, it is “the self’s” responsibility to provide good ideas for them to be apart of.
    So, we all are “gods” of a sort; gods to 100 billion neurons that define who we are. Most of us are “Dumb Blind Gods” like Azathoth, mindlessly giving useless ideas for our neurons to be apart of. We can endeavor to collect good ideas for our own sakes, but we can also be conscious of our godhood and endeavor to collect good ideas for the sale of our 100 billion neurons who are unaware of “The Self.”
    Once a person realizes their godhood relative to their neurons, they have the choice to be a kind and loving god providing good ideas for their neurons, or they can be an evil and spiteful god giving their neurons bad ideas to be apart of.
    People often ask, “What is the meaning of life?” To the neuron, it is to survive and thrive. As their god, the meaning of life is whatever you decide for them.

  • @BleachWizz
    @BleachWizz 2 года назад +10

    4:50 if you just take out the sqrt you can correctly calculate it squared and it's actually removing code.

    • @mccvargues7792
      @mccvargues7792 2 года назад +1

      I came here to say that, taking a squareroot is a very expensive operation. But I also think that the behaviour will significantly change due to the distance being quadratic, which means that attraction over long distances will be way stronger.

    • @operandassembler
      @operandassembler 2 года назад +3

      @@mccvargues7792 Just in case anyone reading this doesn't fully understand what y'all are talking about, they mean you square the check distance instead of taking the square root of the computed distance. So.. instead of if (CheckDistance < sqrt(dx^2 + dy^2)) you use if (CheckDistance^2 < (dx^2 + dy^2)) then, you are within the tested distance without having to call the computationally expensive sqrt function. Good suggestion you two!!

    • @BleachWizz
      @BleachWizz 2 года назад +1

      @@mccvargues7792 I think yes but I think you said the opposite.
      he's using 1/d instead of 1/d^2
      if he excluded the sqrt d would become d^2
      and 1/d^2 would make the interaction between particles get weaker as distance increases than 1/d.
      So yes the behavior would change.
      But you'd be using the correct formula for gravity as he mentioned for less effort.
      And the interaction has become weaker for greater distances.

  • @waltermcmain1732
    @waltermcmain1732 2 года назад +10

    i'm no physicist but these remind me a lot of how I imagine electron shells in atoms.

    • @larion2336
      @larion2336 2 года назад +1

      several of them resembled ice crystals at times too

    • @mikkirefur
      @mikkirefur 2 года назад +1

      no such thing as electron shells in an atom.... think it more like a magnetic & dielectric field emanating from the atom, with the field having certain properties that can be "measured as electrons, and the size of the field." As the great physicists JJ Thompson stated, an electron is simply 1 unit of dielectric induction.

  • @n0deguy
    @n0deguy 2 года назад +10

    Wow. I’m really amazed of that little amount of views.. Your work is very cool, hope you get much more views and subs!

    • @brainxyz
      @brainxyz  2 года назад +7

      As I said in the video, this universe setup is against me!
      Edit: OK now the views have increased dramatically. The settings of this universe may not be against me 😅

    • @n0deguy
      @n0deguy 2 года назад

      @@brainxyz Incredibly! xD

  • @dummyspittinglamma6494
    @dummyspittinglamma6494 2 года назад +3

    "This cell has learned to teleport"
    *Omae wa mo shindeiru*
    *NANI?!*

  • @dreadflow3155
    @dreadflow3155 2 года назад +4

    Because of the music, I kept waiting for him to say "And I will become the god of a new microworld"

  • @redstoneranger1404
    @redstoneranger1404 2 года назад +10

    What a great piece of work! This is even more amazing than Game Of Life. You HAVE to do a 3D version.

  • @nicolasgaritagoitia5536
    @nicolasgaritagoitia5536 2 года назад +4

    This is the best video i've seen on RUclips for a very, very long time

  • @Ludifant
    @Ludifant Год назад +1

    I like that you give the code. You have to play around with it yourself. The complexity from simplicity is staggering and hard to believe. It is the same flight of imagination as the cellular machine life by Conway. the behaviour of it's attractors resembles eukaryotic life and it lacks the quantisation artifacts of Conway's game. I urge everyone to play with this.

  • @OscarLazzarino
    @OscarLazzarino 2 года назад +13

    This is incredibly cool and I love the walkthrough of the code. I have a question. You have some rules like rule(green, yellow, f1) and rule(yellow, green, f2). It looks to me that's equivalent to rule(green, yellow, f1+f2). Is that so?

    • @OscarLazzarino
      @OscarLazzarino 2 года назад +4

      Uh, no, looking closer at the code now I see that rule() only updates atoms in the first group. So you can have asymmetrical forces which is really "non newtonian" but is probably what allows the emerging patterns. Very cool.

    • @brainxyz
      @brainxyz  2 года назад +6

      Nice observation! but I don't think so because these rules specify uni-directional relationships

    • @brainxyz
      @brainxyz  2 года назад +4

      @@OscarLazzarino Yes to make it symmetric f1 should be equal to f2.
      Asymmetrical forces don't exist at the atomic level but I guess it is abundant at the level of large compounds, proteins, and enzymes

    • @РусланРысбековичБайназаров
      @РусланРысбековичБайназаров 2 года назад +3

      @@brainxyz all forces are symmetrical in real life according to Neuton's 3rd law. But this asymmetry might be why your simulation makes such interesting results, so imo it is a good thing.

    • @РусланРысбековичБайназаров
      @РусланРысбековичБайназаров 2 года назад +2

      @@brainxyz also there is no conservation of energy because of the asymetry. But again, I think it is cooler

  • @silentnight.official4261
    @silentnight.official4261 9 месяцев назад +3

    I got a tell you. It was perfect. Perfect. Everything, down to the last a few detail.

  • @nembobuldrini
    @nembobuldrini 2 года назад +5

    one thing that bugs me is that the particles in this model seem to violate the conservation of momentum: some interactions are like between positive and negative mass, where you have one particle repelling another, while being attracted by the latter. So you can basically create motion from nothing.
    On a different note: how does the model change if you use 1/R^2 instead of 1/R?

    • @simonmasters3295
      @simonmasters3295 2 года назад

      try it and see - why is everyone so lazy on here?

  • @peezieforestem5078
    @peezieforestem5078 2 года назад +2

    Halo, Death Note, Veritasium... you're a man of culture, I see.

  • @TheHottrod3000
    @TheHottrod3000 2 года назад +14

    Very innovative. I’m a junior developer/Art & Designer. I would love to play with the code and make some nice visual elements. Imagine what you can come up with while using Zbrush, Maya, Blender and Unreal Engine.

    • @kitoru
      @kitoru 2 года назад

      do it

  • @svenklingen4849
    @svenklingen4849 2 года назад +2

    WOW. This gets me a bit closer to what i would like to achive (Multi Agent System of Neuralnetworks - parallel and multithreaded execution with the ability to create agents at runtime). thank you very much for sharing. Call me crazy, but lets just play for a second with this idea:
    WHAT IF the particles are replaced with something different. lets say "perceptrons". I wonder if that would not be a huge step towards selforganizing neural networks, which can be "trained" on "unordered, unsorted" data and thus let it learn unsupervised. And to go one step further: How about feeding such a simulation with the available settings and let it create a new version of itself(metaprogramming and permutation, population, - this wouldnt even need the ability to modify its own code, it would just increment the version so to speak and have a generation of children.). What i wanna be when i m grown up? mad scientist without the restriction of the scientific community. XD

  • @rfly-fpv
    @rfly-fpv 2 года назад +10

    Oh man, this is truly amazing! First time ever I see code explained in such way with examples on the right. Really you deserve millions likes on this video

  • @Ipergenio
    @Ipergenio 2 года назад +2

    Super supervideo! I followed your instruction to write the script code. My browsers (Chrome, Firefox and Edge) don't like the "Let" inside the for instructions. Without the Let keyword it works good. The behavior is slightly different depending on the browser because Firefox it's very fast while Edge is the slowest and I slightly changed some parameter affecting velocity. Great great work!

  • @cogtortion
    @cogtortion 2 года назад +5

    Thank you for this, amazing video, great explanation, I certainly did not expect to actually be shown the code let alone a full rundown from scratch. Please make more videos like these, the motivation it brings to open up a code editor is next level, these are the types of videos I wish I could find more of, perfect pacing, i like how you sped up most of the coding to match your explanation as you went. Other people would have turned this into a 3 hour tutorial including all their mistakes, fixes, overexplanation, etc. Very wonderfully produced. You sir have an amazing brain. Thanks again.

  • @tiggerbiggo
    @tiggerbiggo 2 года назад +2

    just gotta say the music from death note being used as a backdrop to your quick coding made me laugh pretty hard, all it needed was an overly dramatic reading of the script and it'd be a true death note scene XD
    i'll take a canvas...
    AND DRAW IT!

  • @OutbackCatgirl
    @OutbackCatgirl 2 года назад +26

    This is friggin cool. A "randomize" button in the C app would be amazing

    • @JB-fh1bb
      @JB-fh1bb 2 года назад

      It might be a good first pull request to the repo

    • @waterpicker6879
      @waterpicker6879 2 года назад +1

      @@JB-fh1bb Its number 7 apprently.

    • @JB-fh1bb
      @JB-fh1bb 2 года назад

      @@waterpicker6879 🎉

  • @eSKAone-
    @eSKAone- 2 года назад +2

    Every so called "scientist" that does not see that the universe is a living thing is just a mechanic. His mind can only process the obvious parts of life before his eyes.
    Everything is alive. Life does not end at the other side of a cell's membrane. A city is an organism too. There is no isolated system in the universe. It's systems within systems, overlapping each other.
    God is life itself. Everything in life is connected. We are part of a greater being. Religions are just different languages, they are an attempt to communicate this insight to other humans. With science getting more and more of the picture (macrocosm, microcosm), and people getting educated about it, it will be easier and easier for everyone to understand it.
    For that:☮️, you have to see this:☯️.

  • @heliquackterstudios
    @heliquackterstudios 2 года назад +4

    "I know this universe is set up against me" - Had a solid chuckle 😂. Rock on brother, really nice work.

  • @filipfedorisin3457
    @filipfedorisin3457 2 года назад +2

    Isn't this a simple demonstration of system theory? Particulary Stocks and Feedback Loops where interconections increase the complexity of interactions exponentially thus resulting in unpredictability where small changes to relations have a big effect on entire system.

  • @TheTenorChannel
    @TheTenorChannel 2 года назад +7

    Very beautiful project, I loved every part of it. Very interesting to see a Chladni Pattern emerge at 9:09 // these are known to be the nodal lines of a resonant body, and they literally plot Helmholtz equations solutions in function of frequency, the latter being quite omnipresent in any kind of physics, and even in neuroscience, structuring the causality within brain waves. Cheers

    • @CrystalStearOfTheCas
      @CrystalStearOfTheCas 2 года назад +1

      This comment made me go down a delicious rabbit hole. Thanks
      Chladni is goat

  • @Noonicknames
    @Noonicknames Год назад +2

    1/d instead of 1/d^2 is actually more accurate for a 2D world.
    Force fields are observed to conserve a flux, (number of field lines does not change). Inverse square law is a byproduct of having 3 spatial dimensions, force fields disperse as a surface (e.g. a sphere) which scales quadratically with radius. In a 2D universe force fields disperse as a line (e.g. a circle) which increases linearly with radius.

  • @rudawabdulrahman1010
    @rudawabdulrahman1010 2 года назад +7

    I can see that your content quality is improving. Keep it going.

  • @LuanRykheer
    @LuanRykheer 2 года назад +1

    Would love to see you actually explain the algorithms, and perhaps the intuition behind the model, and how it works. The code walk through was cool, but ultimately way less valuable compared to a proper explanation. I'm sure most of the people watching this can already program, and perhaps have at least some basic understanding of DSA. This renders the code walkthrough not completely useless, but not as important, at best. I'm sure you explain a lot of the algorithms in the walkthrough but it's hard to extract the value from it.
    (Maybe I'm the only one who feels it's hard to understand the intuition when the video is very much like a tutorial. 🤷‍♂🤔)
    Yet the model intrigues and impresses us all very much. This is very cool (perhaps also very promising, who knows), good job. Looking forward to you other videos.

  • @karmatical5837
    @karmatical5837 2 года назад +5

    I like how you made and explained the code part by part, i believe even a beginner can understand your video and with your explanation i can convert this concept to other languages and plataforms and apply my own ideas, thanks for helping.
    Someone already said, but you are a Genius, you have a lot of potential and you are using it for good. Keep the amazing work.

  • @Mind_z_______Gap
    @Mind_z_______Gap 9 месяцев назад +2

    This is amazing and beautiful and I can't wait till I get mine fully up and running. I hope am am able to save people a few hours by suggesting to go right to github for finding the actual code to copy down and just use the video for what order to write everything up.

  • @Eichro
    @Eichro 2 года назад +6

    I really appreciate how you show step by step how to achieve it with plain vanilla js

  • @PokeKnoxDSRomHacker
    @PokeKnoxDSRomHacker 2 года назад +2

    Don't know why this is on my homepage but I'm glad it is!

  • @alexhuang7681
    @alexhuang7681 2 года назад +4

    While looking at the thumbnail, it's complexity put me off from watching the video, thinking "I'm probably not going to understand a thing". But upon actually watching it, you showed that the rules are so simple that you could go through writing every line of code in a small portion of the video. Stunning.

  • @mrreese2342
    @mrreese2342 2 года назад +2

    Please Please & Please make a tutorial series, in all of RUclips i haven't found any good genetic algorithms and AI life simulation tutorials, they're all just like a walkthrough of what's happening, right now my goal is to build artificial life, i don't know how but i'll try to support you by sharing all of your videos if you want to ...
    Peace ✌

  • @JB-fh1bb
    @JB-fh1bb 2 года назад +5

    I don’t know whether I have enough experience to understand what might be complex for others, or whether it’s just that simple, but whatever it is I’m stunned by how simple the explanation is and how beautiful the results are. 10x points for starting from 0 with a single empty html file.

  • @midclock
    @midclock 3 месяца назад +2

    This is not interesting... it's fantastic!

  • @chibula
    @chibula 2 года назад +5

    The shakiness is purely becasue of the instability of explicit time stepping used in nemerical integration (an artifact). Also this is a perfect example to use webgl shaders to acceelrate (save particle position and velocity as rgba in a float texture, read them in vertex shader and update), render a quad with same amount of pixels mapping to the particles

  • @porky1118
    @porky1118 2 года назад +2

    This should be shown to creationists

  • @FreeScience
    @FreeScience 2 года назад +6

    It would be interesting to see what happens with a more sophisticated integration algorithm, such as Runge-Kutta for the force-acceleration-velocity-position.

    • @anywallsocket
      @anywallsocket 2 года назад

      smoother but slower motion

    • @FreeScience
      @FreeScience 2 года назад

      @@anywallsocket Sure, but I'm more I'm thinking things like preservation of momentum and energy.

    • @anywallsocket
      @anywallsocket 2 года назад

      @@FreeScience the dynamics will evolve differently, but only slowly as a divergence. The chaotic nature of the system will quickly override any predictability anyway.

    • @faisalwho
      @faisalwho 2 года назад +2

      His integration scheme is broken. He is isn’t accumulating forces and stepping, he is collecting forces and stepping at the same time.

  • @mehrshadfarahani6071
    @mehrshadfarahani6071 2 года назад +4

    I don't know what to say man, it just changes the way I look at the universe. Thank you for sharing this. Great job.

  • @Eltro101
    @Eltro101 2 года назад +4

    I deobfuscated Ventrella's code once a long time ago. I think it worked in a very similar way, with predicting the other particles positions, except I think in his the rules can be dynamically redefined for particles based on who they've encountered so far

  • @youmadbro168
    @youmadbro168 6 месяцев назад +4

    It dont not wrok 😡😡

    • @Nientaledfaux
      @Nientaledfaux 3 месяца назад

      So it works if it doesn’t not work then it means it works and are you having a stroke

    • @prolastmedia6171
      @prolastmedia6171 3 месяца назад

      ​@@Nientaledfauxrelax smart guy😂

  • @95Geli
    @95Geli 2 года назад +3

    Its a crime that this channel doesnt have wayy more subscribers.

  • @vornamenachname597
    @vornamenachname597 9 месяцев назад +2

    Wow! That stuff around 12:28 really resembles mitosis, crazy!

  • @iruns1246
    @iruns1246 2 года назад +4

    Amazing work! It'd be a million times better if combine this with evolution-like process. What I can think of:
    1. Add a new type of object, let's call it "nucleus"
    2. Genetic information: Each nucleus stores the information of formation of particles in polar coordinates to it. e.g. red: [ [1, 90], [2, 45] ], blue: [ [2, 60] ]
    Each will be spawned surrounded by other particles arranged according to the gene.
    3. Metabolism: Each time there's another type particle that is close enough to a nucleus, it will "eat" it and increment a counter of that particle inside it. e.g. red++.
    4. Reproduction: When there's enough particles eaten to satisfy the number of particles of each type needed for the genetic code e.g. red == 2, blue == 1, another one of this nucleus will be spawned elsewhere
    5. Mutation: For each reproduction process, there's a chance of a small change in the genetic code.
    6. Death: Each time a particle that a nucleus "owns" is eaten or gone too far, the HP of that nucleus is reduced. If it's 0, the nucleus dies.
    7. Growth: The genetic information can be split into stages and the nucleus will need to consume enough particles to go to its next stage. It means the consumed particles will be respawned around the nucleus based on the next stage's gene. Reproduction will be done after the last stage is reached.

    • @jonrjeffrey
      @jonrjeffrey 2 года назад

      Technically shouldn't analogues of all of these sorts of processes (hopefully) emerge with the right fine tuning of parameters?

    • @iruns1246
      @iruns1246 2 года назад

      @@jonrjeffrey I think it should, but it would require orders of magnitude more particles, and particle types. The synthetic nucleus there should act like a shortcut that represents a mechanism that would require tons and tons of particles to function.

  • @daemonsilverstein8633
    @daemonsilverstein8633 2 года назад +1

    Math.sqrt(a*a + b*b) can be replaced by Math.hypot(a,b), as it's better, faster and smaller. It solves beautifully for large and small numbers, for instance, let's say that a = 1E200 and b = 1E200, the sqrt implementation returns "Infinity", while hypot(a,b) correctly returns 1.414213...E200. Same for a = 1E-200 and b = 1E-200: sqrt returns 0, while hypot returns 1.414...E-200. One could argue "1E200 is a enormous number", or "1E-200 is a rather small number"... indeed, but physics calculations can easily approach these magnitudes, specially for the smaller one. Chaotic patterns generally depends on the smallest forces to work properly, so if you can compute these smaller numbers with precision, you manage to replicate natural patterns that otherwise would be "truncated" with "standard" JS Math functions.

  • @dzidmail
    @dzidmail 2 года назад +3

    Some of the instabilities could be a result of simulating in discrete domain. Different sample time: if you multiply all the forces by 0.5, record the simulation and play it at 2x speed, the results with fast moving particles (e.g. instabilities) will be different.
    There are also continues domain solvers, but understandably that would make it not very approachable.

  • @MarioRodriguez-ow9rl
    @MarioRodriguez-ow9rl 2 года назад +2

    I have an idea. Why not programming those particles as real atoms? Living beings are mainly made by C,H,O,N,P (Carbon, Hydrogen, Oxygen, Nitrogen, and Phosphorus) so just 5 particles. They are not in equal proportion but C = 9.97%, H = 63.1%, O=24.86%, N=1.83% and P=0.19% (abundance, not weight percentages). They have also their rules:
    C: Can create 4 bonds and can bind itself, H, O, N and S
    H: Can use just one bond and can bind C, O, N and S
    O: Can create 2 bonds and can bind itself, C, H and P
    N: Can create 3 bonds and can bind C and H
    P: Can create 4 bonds and can bind O
    This will create molecules. C-H and C-C parts of different molecules will attract, and repel the rest of the combinations (O-H, N-H, P-O). These last groups will be attracted among them, including H-O-H (H2O). If a H2O molecule hit an atom bound to an oxygen bound to another atom (different from H), the H2O will bind to the atom, transferrin one H to the other freed oxygen (hydrolysis): C-O-C or C-O-P + H2O = C-OH HO-C or C-OH HO-P, and the opposite is true if 2 OH from different molecules hit, they can combine, releasing one H2O. Just the following molecules will be inert O-C-O (CO2) and O-O (O2).
    And let´s see which molecules are formed and how they interact and self-organise.
    I'd just make a small criticism in your software (if I got it well). If green attracts red, red has to attract green, there is no way red repels green. Attraction and repulsion must be reciprocal in real life.

    • @brainxyz
      @brainxyz  2 года назад +1

      Yes, attraction and repulsion forces are symmetric in our world. This simulation was not meant to model the real-life organisms but more to showcase how simple iterative rules can give rise to complex emerging patterns. You can think of these patterns as life in alternative reality were some arbitrary made up rules applied to many particles iteratively.

    • @MarioRodriguez-ow9rl
      @MarioRodriguez-ow9rl 2 года назад +1

      @@brainxyz I understand your point but it´d be equally interesting to use these simulations with the conditions of our universe and planet. They could recreate the origin of molecules, structures and even a simple living being (in best scenario) here. Most of living beings are made by few elements and "simple" rules (getting complex).

  • @nembobuldrini
    @nembobuldrini 2 года назад +3

    0:55 reminds me a lot of a recent simulation of a proton model (quarks + gluons)

    • @brycering5989
      @brycering5989 2 года назад +1

      I saw it also, had to scroll and use ctrl+F to find the word Proton to find you :D

  • @fuzzyorangetv
    @fuzzyorangetv 2 года назад +1

    This concept could be applied to all kinds of things, it's facinating. Imagine if you applied the values of the 4 fundamental forces to all the various types of atom and watched it go boom! If hydrogen gets with more hydrogen you eventually get helium etc until it goes supanova. Would artificial galaxies form? Dark matter etc??

  • @elxde0
    @elxde0 2 года назад +4

    "Any application that can be written in JavaScript, will eventually be written in JavaScript." ~ Jeff Atwood
    this dude literally codin life in javascript. (and c++)
    can't wait for life 2: electric boogaloo | Quantum Physics edition. where he creates an accurate simulation of consciousness and his funny life cells gain sentience and slaughter us like pigs
    that would be cool i think

    • @goaty1208
      @goaty1208 2 года назад

      If you think about it, (and yesterday I thought about it a lot) if you were to scale this to infinite sizes, were each of these simulations were the size of an atom (obviously impossible), you'd eventually get a fully functioning creature, and since I said an inifinite space it could even be an infinite 2D universe, which works with these simple rules. This is already Life 2. Heck, even Conway's game of life or any Game of Life like these can make an entire creature given enough space and particles.

    • @SuperYtc1
      @SuperYtc1 2 года назад

      You been watching Blametruth?

    • @elxde0
      @elxde0 2 года назад

      @@SuperYtc1 idk who that is. sorry to disappoint

  • @LuksaTV
    @LuksaTV 2 года назад +1

    Make it visually more appealing and you get millions of views. Nice editing too

  • @_shadow_1
    @_shadow_1 2 года назад +4

    I wonder if you could also simulate some form of particle physics with a set of simple rules.

  • @user-jp5jd5sb2p
    @user-jp5jd5sb2p 2 года назад +2

    I don't know if it's somewhere noted, and yes I didn't read EVERYTHING, but...
    There is a bug.
    RED and GREEN "number" sliders are for the opposite colors.
    Just letting you know. Love Your work

  • @aliceberethart
    @aliceberethart 2 года назад +6

    This video is as much a lesson in biology, programming, math, astronomy, and physics as it is a lesson in literature.

  • @vinnienovido
    @vinnienovido 2 года назад +2

    Step 1. Open text editor.
    Step 2. Create the universe.

  • @ayior
    @ayior 2 года назад +3

    This video is amazing and underrated. I've been following life simulations as a hobby for a couple of years now and this is one of the most interesting ones I've come across in a while! It seems like a more advanced Boids, the organicness of the patterns, simplicity of the code and presentation is amazing.
    My cell biology knowledge is a bit rusty, I think I remember polarity being an important factor in osmosis? I love the elegance of this simulation and would hate to ruin it, but I wonder if more complex mechanisms can be simulated by taking more inspiration like that from real life cells.
    Edit: maybe I'll try recreating this (Don't know C++ so I'll have to go from scratch) and somehow add in lifespan and evolution to get changing cells... somehow... I'll have to think on it

  • @benjamincasatimcintosh2918
    @benjamincasatimcintosh2918 2 года назад +1

    this got philosofical really quickly.
    also i wanted to point out that the cbm is a product of the electrons recombining with the nucleous all across the universe at the same time and emiting gamma radiation. the cooler and hotter areas are of course denser and less dense areas but only diferenced by a fraction of a degree yet causing massive diferences in the end. the recombination era takes place 370k ish years after the big bang and the cbm shows the effects on slight differences that existed since the very begining (you have to think that the universe was a lot smaller and denser during the big bang meanig that these diferences were even smaller)
    🤓🤓🤓🤓

  • @n00dles79
    @n00dles79 2 года назад +3

    I am unsure if I have ever seen anything this amazing. Thank you so much for the open GitHub file man you’re a legend. I’m at my desk screaming.

  • @fingernecklace4817
    @fingernecklace4817 5 месяцев назад +1

    "Perhaps if the density here was slightly offset, I would have been a millionaire, but I knew; 'this universe is set up against me'" hahahaha I feel you brother
    Thanks a ton for offering the source code in C++, too. I'm definitely going to spend too much time tinkering with sliders now.

  • @Lunsterful
    @Lunsterful 2 года назад +3

    Sublime presentation, impressive on several fronts, well done. I've seen explorations of this concept from Conway, Hoftstadter, and Wolfram as you mentioned, but I don't think I've seen anything close to this level of elegance and complexity of emerging behaviour. I think the key differentiator is adding clean, physical laws with an emphasis on simplicity - and then allowing time to take over. You also make many astute comparisons and analogies in this video. Imagine how complex our simulations could be in decades to come!

  • @phutureproof
    @phutureproof 7 месяцев назад +1

    I'm a little late to the party! Great work mate, I have been fascinated by this kind of emergent behaviour since hearing about boids and the simple rules applied to them, I will certainly be using your ideas as inspiration, thanks man.
    I will add.. Your code example was easy enough to follow and well explained cheers again, I've got weird little thing with wings flying about in my browser :D

  • @mosaic34
    @mosaic34 2 года назад +3

    Wow I am impressed ! This is genius man. This is so meta and also shows how life actually is formed cause of different behaviour of particles!

  • @13zensu
    @13zensu 2 года назад +1

    When I finished watching this clip 😳 It's amazing for such a beautiful algorithmic way of thinking and transforming.
    Thanks for the nice vdo clip.😊

  • @DavidLindes
    @DavidLindes 2 года назад +7

    This is cool! I typed in the js code, tweaked it a little*, and made a fish! :D (I wasn't setting out to make a fish, but that's what it looks like to me.)
    * added two parameters to rule(), one is the maximum distance for interaction (80 by default, as in your code), and the other is an option to do 1/d² instead of 1/d. Also a few other tweaks, but I think those are the most noteworthy. The rest was just playing with rules.

  • @pacogirerd5676
    @pacogirerd5676 2 года назад +1

    Wow ! Incredible. If I try to do the same with Python, what library would you recommand ? Tkinter ?Py Game ? Matplotlib ?

  • @sammyclassicstarfoxfan9827
    @sammyclassicstarfoxfan9827 2 года назад +3

    This is by far the most interesting cell simulation i have seen

  • @shadowguarder2857
    @shadowguarder2857 Год назад +1

    Why do the rules in the open demo KEEP CHANGING? I set it to something and it KEEPS CHANGING

  • @masterrguy4465
    @masterrguy4465 2 года назад +3

    Please do an hour long video of just this! It's so satsifying.

  • @matin563
    @matin563 2 года назад +1

    This is not a reaiistic model. You're giving the gravitational force and the electric force comparable orders of magnitude in the scale of particles, which is not true in real life (apart from the fact that you modified those forces throwing away the "squared" in the distance variable).
    Nonetheless, it is a really simple model to predict somewhat complex behaviours of these "forms of life". One could imagine the existence of such a model in accordance with realistic laws.
    Keep up the good work!!

  • @loveistheonlything3626
    @loveistheonlything3626 2 года назад +20

    Feels magical, like cellular automata. This feels as if life would actually emerge in a similar way.

  • @TheFedemontero
    @TheFedemontero 2 года назад +1

    Yo yo YO! Bro! Dope sh*t you got here, keep it up with the good work! Interlinking philosophy with "the science", NIIIICE!!

  • @baseduck
    @baseduck 2 года назад +8

    Just a quick tip, I noticed an error in your physics calculations in the javascript version. You're calculating the gravitational force correctly, but then you're applying it to the components of the velocity vector wrong - you want to normalize the distance vector when multiplying it by the force. So something like vx += norm(dx) * f. And since normalizing a component of a vector is the component divided by the magnitude, you can actually simplify the square root out and have a calculation that looks something like this:
    let dx = other.x - this.x
    let dy = other.y - this.y
    let distsq = (dx*dx + dy*dy)
    if(distsq

    • @WindsorMason
      @WindsorMason 2 года назад

      Yeah, the longer I looked at the video the more things felt really weird and it took me a while to realize how "incorrect" all of the code really was. Ahaha!

  • @jonbrouwer4300
    @jonbrouwer4300 2 года назад +1

    This is absolutely incredible. Amazing!

  • @KarelMatthieuLLogro
    @KarelMatthieuLLogro 2 года назад +6

    With your foundation, this will allow others create more complex simulations of life

  • @exel001
    @exel001 2 года назад +1

    in the matter of fact, real force between any two particles in this model is always the same and equals 'g' parameter.
    just note, that x component of force is g * dx / d, and y component is g * dx / d. if you just calculate total 'length' of this force, you'll get
    f = sqrt((g * dx / d)^2 + (g * dy / d)^2) = sqrt(g^2 * (dx * dx + dy * dy) / d^2) = g * sqrt(d^2 / d^2) = g.
    so force between two points is always constant, regardless on the distance, we just need to decompose it on axes depending on dx and dy. the limit 80 just makes the force to be zero outside this radius. I think the value of 80 just determines the radii of the circles that we see in the video

  • @adriansabau6388
    @adriansabau6388 2 года назад +3

    1:25 Corona anybody? 😂

  • @AexisRai
    @AexisRai 2 года назад +1

    it feels like this system is pointing in the direction of actual particle physics simulation more than life simulation. but in any case, congrats on your results and welcome to the emerging group of Artificial Life Simulation Developers On RUclips, lol.
    you'll be riding a wave of popularity for a few days and you can capitalize on it if you have more to add.

  • @zoltarg
    @zoltarg 2 года назад +14

    Really great work! It would be amazing to put this into Unity 3D and also add the third dimension along with some smooth random camera interpolations to view everything.

  • @ashitoshkamble685
    @ashitoshkamble685 6 месяцев назад +1

    I think by adding some random fluctuation in attractive and repulsive force and allowing interchangability of particle types based on some parameters might have given us very chaotic results at first but very much stable events after some time. Also I think it might have added thatbextra layer of physics which led to life.

  • @kuwertzel7980
    @kuwertzel7980 2 года назад +6

    Yooo this is amazing!
    I've seen a couple simulations like this in the past (eg. by "Particle Life" by Code Parade) but this is far more complex than what I saw so far. Good job!
    I tried making a simulation like this myself in the Unity game engine but the performance sucked and I ran into some issues...
    Shameless self promotion: I made a 'slime' simulation inspired by one of Sebastion Lague's videos and uploaded a little showcase of that on my channel :P
    It brings me so much joy seeing complex behaviour emerging from simple rules :D

    • @zbnmth
      @zbnmth 2 года назад

      Kuwertzel, Unity is a "fourth" level programming language. Physical logic gates -> Machine language -> Programming languages (C, Fortran, etc) -> Fourth level languages (Unity, Mathematica, etc).. That is to say, Unity has something like C between it and the machine code. Generally, the more user-friendliness you have, the less efficient the physical machine (CPU) is given instructions.
      Maybe you already knew, but it's why your program will run (very) slow when coded in Unity.

    • @dealloc
      @dealloc 2 года назад

      @@zbnmth This is just plain wrong. I've written Particle Life in JS (fnky/particle-life on GitHub) and its performance is fine. This is without much optimisations (no WebGL shaders, just Canvas and purely running on the CPU).
      Unity is first of all, not a programming language, but an engine. Secondly, any language can be slow if you don't know about pitfalls that are usually general to every language; i.e. allocating within a deeply nested loop can be very slow if not cached or managed properly. Doesn't matter whether you write Rust, C++, C or even Assembly.
      The important part is to understand those pitfalls and how to use the language to avoid them. C#'s runtime (CLR) is fast and is used in many applications, more complex than this. Not only that but your C# code is also heavily optimized through Roslyn before being translated into MSIL/CIL and then to machine code by the JIT compiler.

  • @Zebokdk
    @Zebokdk 2 года назад +1

    As a determinist and mathematician this was very pleasing! Also, was that background music from Death Note? :O

  • @rsanche4726
    @rsanche4726 2 года назад +5

    this is exactly what all programming tutorials should be. Simple, clean, fast, to the point, and showing how it works. Thank You!

    • @Tubeytime
      @Tubeytime 2 года назад

      Did it work for you? I followed along and it didn't work.

    • @mememanfresh
      @mememanfresh 2 года назад

      i cant get html to display in chrome bruh its blank

    • @mememanfresh
      @mememanfresh 2 года назад

      now i cant yellow particles to appear i give up

  • @Vedariy
    @Vedariy 2 года назад +1

    Obvious! And SOOO INCREDIBLE! Your really a genious!