Evolution Simulator with Neural Networks in Unity!

แชร์
ฝัง
  • เผยแพร่เมื่อ 28 ก.ย. 2024

ความคิดเห็น • 105

  • @JohnnyCodes
    @JohnnyCodes  ปีที่แล้ว +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: th-cam.com/video/JXGogdI7RIE/w-d-xo.html

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

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

    • @lucutes2936
      @lucutes2936 12 วันที่ผ่านมา

      thx

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

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

    • @lucutes2936
      @lucutes2936 12 วันที่ผ่านมา

      big brain

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

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

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

      Me too

    • @lunaticgr2925
      @lunaticgr2925 ปีที่แล้ว +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 th-cam.com/video/Bfcg4tS8hpw/w-d-xo.html

    • @revimfadli4666
      @revimfadli4666 8 หลายเดือนก่อน

      ​@@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 12 วันที่ผ่านมา

      wdym

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

    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 2 ปีที่แล้ว +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!

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

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

  • @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 8 หลายเดือนก่อน

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

  • @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.

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

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

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

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

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

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

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

    That’s really good.

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

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

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

    Great video! Would love to see more!

  • @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

  • @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.)

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

    Nobody else on TH-cam has explained Neural Networks as well as you have for newbies

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

    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.

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

    I freaking love these experiments

  • @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! :)

  • @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.

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

    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.

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

    wheres the auto jump cut software?

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

    Really great Video man

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

      Thank you! I appreciate it!

  • @atcer51
    @atcer51 11 หลายเดือนก่อน

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

  • @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 TH-cam 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.

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

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

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

    Is your code somewhere available?

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

      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

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

    Dude great video and work

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

      Thanks! Glad you enjoyed it!

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

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

  • @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.

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

    Love the jokes, you got a new subscriber:D

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

    @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 2 ปีที่แล้ว

      You could try Udemy course by Penny something or other.

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

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

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

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

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

    Cool video, make some more

  • @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 2 ปีที่แล้ว

    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.

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

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

  • @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.

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

    the jump cuts were perfectly fine until you pointed them out

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

    Make a count of how many times he said neural network

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

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

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

    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 2 ปีที่แล้ว

    gg

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

    How to learn math and biology at the same time

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

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

  • @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

  • @juliusanon
    @juliusanon 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!

  • @teambellavsteamalice
    @teambellavsteamalice 2 ปีที่แล้ว +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!

  • @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.

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

    if you like simulations, you should really see the bibites

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

    i love u for teaching me about AI.

  • @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 :)

  • @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!

  • @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?

  • @frozenzenberry4101
    @frozenzenberry4101 2 ปีที่แล้ว +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.

  • @lucutes2936
    @lucutes2936 12 วันที่ผ่านมา +1

    were you using ML-Agents?

    • @JohnnyCodes
      @JohnnyCodes  12 วันที่ผ่านมา

      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 12 วันที่ผ่านมา

      @@JohnnyCodes aren't they both similar?

  • @visheshl
    @visheshl 7 หลายเดือนก่อน

    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.

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

    Great video man keep it up.

  • @visheshl
    @visheshl 7 หลายเดือนก่อน

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

  • @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)

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

    .

  • @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!

  • @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!

  • @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.

  • @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.

  • @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

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

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

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

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

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

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

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

    That's a really good video