Evolution Simulator with Neural Networks in Unity!

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

Комментарии • 105

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

    I started a Neural Network Tutorial series to show how I made the neural network in this video! Here is a link to part 1: ruclips.net/video/JXGogdI7RIE/видео.html

    • @dotenvdev
      @dotenvdev Год назад

      Have you considered swapping the ReLU activation function out for GELU? A bit more computationally intensive, but great to avoid vanishing gradients

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

      thx

  • @SBroproductions
    @SBroproductions 3 года назад +46

    2:20 Shoutout to the guy that spawned underneath the map. Dude evolved his way to another plane of existence.

  • @modernmarrow1411
    @modernmarrow1411 3 года назад +147

    I've always loved natural selection simulators, it's too bad there isn't more of them.

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

      Me too

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

      The bibites : digital life, it's by far the most advanced and it's also free. The creator quit his job and is working full time on the project now. You should check it out.

    • @Vav97
      @Vav97 Год назад

      I got you ruclips.net/video/Bfcg4tS8hpw/видео.html

    • @revimfadli4666
      @revimfadli4666 11 месяцев назад

      ​@@lunaticgr2925now we also have Simulife Hub, Biomaker CA, Cell Engine, Neuraquarium, and whatever Dylan Cope calls his simulation. Bit sad that most of their skill cap don't go far above "steer towards food" or "maximise sunlight"

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

      wdym

  • @TheDroidsb
    @TheDroidsb 3 года назад +67

    I did a natural selection program with higher energy costs for faster speed and larger size. They ended up evolving to have negative speed so they only gained energy 😂

    • @nikkiofthevalley
      @nikkiofthevalley 3 года назад +19

      Ahh, the good old "neural network finds a bug in your program for you" (also, what happened when you made it so the speed couldn't go below 0?)

    • @Mr-Raptor
      @Mr-Raptor Год назад +1

      lmao

    • @nikolozgilles
      @nikolozgilles Год назад +6

      I AM (REVERSE) SPEED

  • @kingbling7571
    @kingbling7571 3 года назад +39

    There are different Neural Network Training techniques, Supervised, Unsupervised and Reinforcement type. What you implemented here was reinforced technique which uses Genetic Algorithm to train the NN whereas Backpropogation is the algorithm used in Supervised learning.
    Good stuff btw hopefully this video blows up!

  • @page8472
    @page8472 3 года назад +13

    this is amazing you truly deserve more recognition, keep it up:)

  • @frozenzenberry4101
    @frozenzenberry4101 3 года назад +1

    FINALLY. I’ve watched so many videos about neural networks, seen the dots connecting with lines, but never actually understood how they worked. Someone finally bothered to stop and tell me.

  • @ebrahimmomin7518
    @ebrahimmomin7518 3 года назад +6

    Me: jumps of a cliff
    God: why did u jump off a cliff
    Me: i wanted to learn

  • @julianon161
    @julianon161 3 года назад +6

    What a great video!! I predict your Channel is going to blow up soon.
    I actually coded a genetic algorithm (like you showed) for a biology essay. It was about cars learning to drive a race track and worked pretty similar.
    Keep your work up!

  • @matsukuia7140
    @matsukuia7140 3 года назад

    The quality of this video really caught me by surpise, It deserves more recognition!

  • @shoom7103
    @shoom7103 3 года назад +3

    You are very underrated. That was a very interesting video!

  • @AbstaartKardman
    @AbstaartKardman Год назад

    it cracks me up seeing you having fun during your explanations , its a very interesting project , thanks for sharing man!

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

    I love this!! I love evolution simulations. Ive built a few myself but never to this magnificent extent. You are implementing everything I would like to implement: neural networks and 3D graphics. Hope you can show us some more :)

  • @meryyy0388
    @meryyy0388 3 года назад

    This video was super easy to understand, thanks a lot. I hope you grow a lot on RUclips!

  • @teambellavsteamalice
    @teambellavsteamalice 3 года назад +3

    Awesome!
    I first found some videos from a project called Bitites and then found Primer. I immediately thought, what if you could combine those!

  • @arv_is
    @arv_is 3 года назад +33

    Literally made something almost exactly like this, found this video when trying to solve a problem... it didnt help but was very interesting! Keep up these videos

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

      Haha same here

  • @oatcube3961
    @oatcube3961 Год назад

    Just had to rewatch this video. I first time watched this 1,5 years ago before I started writing my masters thesis on AI. Last week I got it granded and ended up getting grade of 4,5 (max is 5). This was one of the vids that reeled me into working with AI in Unity.

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

    I started playing with this idea last night, its super fun

  • @anomalocaris540
    @anomalocaris540 Год назад

    reminds me of one summer project i tried. the idea was to make a game where creatures evolve like that, I wanted to make it so the player to hunt/play in the game, causing creatures to evolve to the player presence, and also allow player to domesticate and farm them .
    was new at unity/programming and ended up making a snake thing that could crawl a bit. not exciting for a game, but I learned a lot.
    Still think a survival game where creatures evolve and adapt would be a fun game.

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

    Wow, great video! I am looking into such simulations at the moment because I was also fascinated by the same videos by Sebastian Lague and Primer. And you did a really good job of explaining things in this video. Well done!

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

    Great video! Would love to see more!

  • @xendelaar
    @xendelaar 3 года назад +13

    Very interesting video! You've got some magic coding and explaining skills good sir.
    A deadly combination. :)
    Would be interesting to train an Ai like that for a rts game but I guess it would take very long for the ai to mature

    • @revimfadli4666
      @revimfadli4666 11 месяцев назад

      It could mature fast using PPO and invalid action masking, Yannic Kilcher had a video on a paper about it (with microRTS)

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

    i love u for teaching me about AI.

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

    Can we just appreciate he made the oof sound as the death sound in the beginning? R.I.P. OOF SOUND 2006-2022. Also, maybe add a chat system so that they can talk to you and eventually grow up to learn English?

  • @TacticalAnt420
    @TacticalAnt420 3 года назад +3

    That’s really good.

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

    Really great Video man

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

      Thank you! I appreciate it!

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

    Great video man keep it up.

  • @manavgala2361
    @manavgala2361 3 года назад

    Nobody else on RUclips has explained Neural Networks as well as you have for newbies

  • @sirpleasee3472
    @sirpleasee3472 3 года назад

    I freaking love these experiments

  • @CalebHansonlets
    @CalebHansonlets Год назад

    In my early 20s I made all kinds of AI evolution simulations like this in unity. But I always got stuck with back propagation. I never, *NEVER* thought of using death and reproduction as an alternative to backpropation, but once you said it it makes perfect sense. GAH

  • @audditygvhgvhv8778
    @audditygvhgvhv8778 3 года назад +1

    wheres the auto jump cut software?

  • @visheshl
    @visheshl 10 месяцев назад

    Hi i downloaded the project. What most important thing is that you populate the world with the most evolved creatures.
    Creature spawner needs to keep a list of ten most evolved creatures and populate the world with them so as to keep the evolution progressing forward. Please implement this feature and make a part 5 of this tutorial.

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

    2:47 made me laugh so hard that I almost swallowed my pizza.

  • @kiachi470
    @kiachi470 3 года назад +1

    Dude great video and work

    • @JohnnyCodes
      @JohnnyCodes  3 года назад

      Thanks! Glad you enjoyed it!

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

    How does changing the weights and biases change the output... basically, whether or not a node is active or inactive, then it'll choose whether to go forwards or backwards? ?

    • @JohnnyCodes
      @JohnnyCodes  Год назад

      The weights and biases control the "flow" of information through the network. If a weight is large, it means that the input it's connected to is very important and will have a strong influence on the output. If a weight is small or close to zero, then the input has less effect on the output.
      The biases help the network make better decisions by shifting the outputs of the activation function, allowing it to learn even when the input data isn't a perfect match to the expected results.
      Also In our case the output nodes are always technically active because I don't apply the activation function to the output layer. So instead there we have the 2 output nodes and if the first one is negative they will go left and if it is positive they will go right, Then the second output node works the same way but for forward and backwards.

  • @BadChess56
    @BadChess56 Год назад

    I mean, I am a creationist, and anyone with common sense knows that evolution in this sense is impossible, but it is still fun to watch. (mostly because of the neural network)

  • @atcer51
    @atcer51 Год назад

    this finally answered a big AI question I had! thx!

  • @christophermoore7676
    @christophermoore7676 3 года назад +3

    Super interesting, have you chosen to release the source code?

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

      Yeah I was planning on adding a web version of the sim to my non existent website in the next few weeks. I will probably put the code on github at some point too.

    • @christophermoore7676
      @christophermoore7676 3 года назад +1

      @@JohnnyCodes Thanks!

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

    good video, I have a challenge make AI wich its inputs are the pixels of its camera in unity

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

      I've wanted to do that for like 15 years now. But spoiler alert: you can't do in on a home PC, even today. It's so computationally expensive (read: slow), you'd need a cluster computer (small supercomputer).
      (That's if you're evolving a neural net. If you're "cheating" and using statistics or other math, it's less expensive.)

  • @donbeckham
    @donbeckham 3 года назад +1

    7 months later... still waiting on the video about automated jump cuts. :)

  • @visheshl
    @visheshl 10 месяцев назад

    The creature spawner needs to keep track of the ten best creatures and spawn them periodically to keep the simulation going forward.

  • @lucutes2936
    @lucutes2936 3 месяца назад +1

    were you using ML-Agents?

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

      No this was using a neural network I made from scratch. I have a 4 part version of this where I show how to make the code for it

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

      @@JohnnyCodes aren't they both similar?

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

    Interesting, i notice none of them turn into birds. Sure takes a lot of processing power & code to make natural selection work.

    • @JohnnyCodes
      @JohnnyCodes  Год назад

      There is actually a really cool RUclips channel/simulation called The Sapling and his evolution simulator actually has the ability to have creatures start off on land and eventually evolve to fly.
      Also, these networks are actually quite simple so the actual bottleneck of the program is the Unity stuff and not the networks themselves.

  • @pedroheck3667
    @pedroheck3667 3 года назад +1

    Great video, John! If you don't mind, may I ask you a few questions? You used Unity, so was every part of the code made with C#? If so, how did you manage to make neural networks with C#? And, if not, how did you integraded both languages into Unity? I'm asking this because I'm creating my own natural selection simulation, but it is becoming too complex for a browser app, so I'll be migrating it all to Unity (therefore changing all my code from JavaScript to C#). And since I'm changing it all, I feel like adding neural networks is a step I can take now. However, I've just recently started learning Machine Learning, and I only know of Python libraries and techniques to implement it.
    I hope you see this comment! :)

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

      Hi Pedro! I did make the neural networks from scratch for this but the code was a huge mess and it also used an external library called Math.Net. Over the past week I made another neural network simulation to teach cars to drive around a track and I removed the need for that dependency. I have been cleaning up the neural network code as much as possible to make it easier to understand and also easier for other people to reuse this in other projects. I can add the code to git for you in a few days once it is working better. I will be making another video and tutorial about these updates soon too

    • @pedroheck3667
      @pedroheck3667 3 года назад

      @@JohnnyCodes Oh that's great to know! And yeah I would absolutely love that! I'm trying the best I can to gather info about this subject but there's still so much to learn 😅
      I truly appreciate your response, I'll be looking forward these updates! :)

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

    if you like simulations, you should really see the bibites

  • @neilfosteronly
    @neilfosteronly Год назад

    Very cool. I made something similar. But with prey, hunter and plant. Only hunter and prey DNA change. I decided against a size change as thought it would be too powerful. I just used basic states for the AI. Will post it on github soon.

  • @jaydee4397
    @jaydee4397 3 года назад

    There is still an interest in your jump cut code as well as your larger unity project here. Lots from which to learn, kind sir.

  • @neoblackcyptron
    @neoblackcyptron 3 года назад

    You deserve so many more views.
    From you video Atleast I know that Unity and reinforcement learning can be used together.
    Did you have to design each neuron and the interconnection between the nodes. Before natural selection was used to train the weights?
    Or does unity provide a pre-made function to define the neural network structure.

  • @billross9656
    @billross9656 3 года назад

    Forejumpcutting as a new plot device.. what will the jump-cutting video foreshadow??

  • @MatthewKanwisher
    @MatthewKanwisher 3 года назад

    Cool video, make some more

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

    Is your code somewhere available?

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

      I am actually planning on putting the neural network template on github as part of the neural network series I started posting today. I am planning on making the neural network template free on github but I am going to be adding the source code for the rest of my projects as a perk for Patreon members

  • @ITomocska
    @ITomocska 3 года назад +1

    Love the jokes, you got a new subscriber:D

  • @GIRGHGH
    @GIRGHGH 3 года назад +1

    For some reason I expected there to be more after the explanation of how to do movement.

  • @finnwendt9540
    @finnwendt9540 Год назад

    Why does every node need to be connected with every other to the next layer?

    • @JohnnyCodes
      @JohnnyCodes  Год назад

      They don't actually need to be connected to each node but that is one of the most common layers. When they are all connected like that it is called a Dense layer (You will see this term when using python libraries like pytorch or keras). When you string a bunch of these dense layers together like we did it is called a "fully connected feed forward network".
      People experiment with all different kinds of networks, for example the NEAT algorithm tries to figure out what connections each node should have (Using evolution of the actual network shape). There are also recurrent neural networks where previous outputs are looped back into the node as inputs, this gives networks a form of short term memory, also this would be called a recurrent network instead of a feed forward network in this case.
      Hope that helps clear things up a bit! Let me know if you have any other questions!

  • @definitelygamedev5821
    @definitelygamedev5821 3 года назад

    That's a really good video

  • @offroadr
    @offroadr 3 года назад

    @John Sorrentino, I have been looking for a start point for a unity genetic algorithm with a NN built in to the critters. Do you have the source available?

    • @xaviermagnus8310
      @xaviermagnus8310 3 года назад

      You could try Udemy course by Penny something or other.

    • @offroadr
      @offroadr 3 года назад +1

      @@xaviermagnus8310, I am guessing you mean, Dr Penny de Byl. I think I might just do that. Thanks.

    • @xaviermagnus8310
      @xaviermagnus8310 3 года назад

      @@offroadr Get it on sale, but yes. Udemy scheme is to have sales all the time.

  • @AlekMunroe01
    @AlekMunroe01 Год назад

    i wanted to do something like this but a sims like game however i was only able to make really simple "Ball go to cube" game. Then i gave up.

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

    Great stuff, and an even better explainer! Question: Do you only use asexual reproduction? Or can two parents have a child (i.e., with genetic crossover logic)?
    If you're still interested in the topic, the god tier of evolving neural nets is the "NEAT" algorithm -- Neuro-Evolution of Augmenting Topologies. It's been on my coding bucket list for a long, long time now.

  • @darudeSandstorm.
    @darudeSandstorm. 3 года назад

    Isnt backpropagation what we call sleep? I think thats kinda missing in the Simulation :-)

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

      Supervised ML can do a lot, faster. I think it would have been cool to have a day time limit and if they gained 0 food, then they would make some random changes. After 4 days with no food they die out completely. but due to random luck they could reproduce maybe once, which might help some not useful at the start gene's make their way into the future.
      the problem with genetic algorithms seems to be that eventually there is only one or two sets of genes left. Which means they loose their ability to adapt. It might be that way IRL too but

  • @laskey2175
    @laskey2175 3 года назад

    Take the sim that you had them eat the smaller creatures and allow 3 small creatures to teamkill a large creature and drop a bunch of food.

  • @madankd
    @madankd Год назад

    Hey can you share a code

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

      The scripts are on github from part 3 but I am actually planning on posting a quick unity setup tutorial tomorrow and I will also put the whole project on github. The reason I haven't done it yet is because of the Assets I used. But in tomorrows video I am not going to use any assets so I can share it.

  • @Coffeemancer
    @Coffeemancer 3 года назад

    make a sim where the souls of the dead can appear and teach descendencts

  • @eemasd
    @eemasd 3 года назад +1

    Make a count of how many times he said neural network

    • @JohnnyCodes
      @JohnnyCodes  3 года назад

      11 times is that a coincidence? I think not... Remember remember the 5th of November my friend

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

    the jump cuts were perfectly fine until you pointed them out

  • @gamedev_byhobby8872
    @gamedev_byhobby8872 Год назад

    You should make a bunch of neural networks that process different stuff from one another and some feed their outputs to others' inputs so that you'll efectively have a brain

  • @palingram
    @palingram 3 года назад

    1:43 that was a bug bro😂😂😂

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

      Really though is it? I don't think it should be considered that. I mean part of machine learning is that we want to see them find ways to win. If this NN was more complex it would have been totally possible for them to learn to push off the edge intentionally, and to avoid the edge as well. The point of NN's is to have as many variables as possible without destroying your computer.
      Maybe its just the developer in me saying its a feature not a bug. But I think a game that does not have any room for emergent gameplay is unappealing and likely result in stale gameplay.

  • @henrythearcticwolf4709
    @henrythearcticwolf4709 Год назад

    HES A MONSTER HES UNDOING OUR WORK HES MAKING SIZE MATTER! NOOOOOOOOO!!!!

  • @Neuer_Alias_erstellen
    @Neuer_Alias_erstellen 3 года назад

    gg

  • @fkxfkx
    @fkxfkx 3 года назад

    .