Unity Setup Tutorial! Evolution Simulator with Neural Networks (Part 4)

  Рет қаралды 4,732

John Sorrentino

John Sorrentino

Күн бұрын

Пікірлер: 45
@IlseMulAuthor
@IlseMulAuthor Жыл бұрын
Thanks for this tutorial series. I'm certainly going to try it out. I would keep the videos separate, but make a playlist of them. An extra video with the addition of enemies would certainly be good!
@ProperSnake
@ProperSnake Жыл бұрын
yesssss an all together one would be amazing
@cleberfeitosa7954
@cleberfeitosa7954 Жыл бұрын
This is a fantastic series! Ty so much! And please do the full version! It would certainly amazing to watch!!!
@Q_Bits
@Q_Bits Жыл бұрын
Thank you! Been waiting for this! This series has been fantastic!
@may-the-ma-be-with-u
@may-the-ma-be-with-u Жыл бұрын
this is maybe the best nn basic explanation i seen
@natebrett9782
@natebrett9782 Жыл бұрын
Hi, I have followed the past 3 videos and this one. I would defiantly love it if you re-did the series as a whole video, taking us step by step though everything. I have not quite been able to work out how the inputs and outputs link to the network. I'm also unclear how the first creatures generate there original network weights and biases. I'm going to download the files now and see if I can work it out from there, but would love a new fresh video built out of these 4.
@JohnnyCodes
@JohnnyCodes Жыл бұрын
Yeah I rewatched the series after the 4th video and I was kindof dissapointed at how disconnected everything felt. I thought it would be helpful taking screenshots of the code and talking about it but I actually liked the version where I was just screen recording and going through the steps of actually making it. So I would like to do a full version like that soon
@kpr2
@kpr2 10 ай бұрын
Hi, John! I enjoyed this series & just stopped by to poke at you & see if you were indeed intending to revisit it? I think it would be great to have a more cohesive view of everything & am also curious if you'd mind explaining how one would go about saving the NN training data so that it's not starting from scratch every go. Thanks much for all the information! I now have a herd of deer that... well, mostly run in circles and die, but some manage it in the end hahaha.
@JohnnyCodes
@JohnnyCodes 10 ай бұрын
Hi! I am glad you enjoyed it. Thanks for the poke I probably need it lol. I actually wrote myself a schedule for the beginning of next year and right now I actually have working on the NN tutorial from 1/7 - 1/28. I am not normally a schedule person but I have been pulling myself in a lot of different directions lately but if I manage to stick to the schedule then I should be able to post a better version with even more information by the end of January! For saving the networks I think I ended up using a free asset called quick save on the unity asset store. I think it basically turns any object into a json file and then can also read it back out of the file and turn it into a object again. So I would just pass in the entire network or sometimes the entire creature object if you have other parameters you need to save besides the network and it should be able to load it back in. I will hopefully either add this to the updated video or make a separate video about it too
@kpr2
@kpr2 10 ай бұрын
Thanks for the info @@JohnnyCodes! I'll give the quick save a shot as it sounds like a super simple solution. I completely understand how it is to be pulled in a million directions at once (spinning in crazed circles myself here of late trying to do three dozen different things, haha). If and when you can get back to this, I'll certainly be looking forward to it, but don't pressure yourself overly. Thanks again & rock on!
@cmatrix6720
@cmatrix6720 Жыл бұрын
This is an amazing series!!! 🤩
@vilmerlundin4775
@vilmerlundin4775 Жыл бұрын
recently created a similar simulator in javaFx, nice work
@hitlab
@hitlab Жыл бұрын
Can you tell me where you cover back propagation?
@visheshl
@visheshl 8 ай бұрын
Can you make a fifth video with a fitness function where the longest living creature is the most fit. And the spawner selects ten best fit creatures and spawns them?
@samuelgilr
@samuelgilr Жыл бұрын
thank you so much for this!
@JohnnyCodes
@JohnnyCodes Жыл бұрын
No problem! I am glad you enjoyed it. I was actually just thinking that I should make that combined version that I mentioned where instead of it being 4 parts it would just be one well structured video. Was there anything missing in these videos that you think would be a good addition to the full one?
@samuelgilr
@samuelgilr Жыл бұрын
I think that adding a predator would make the simulation more interesting, another agent that has the same necessities as the original creature but eats its prey instead of the regular food you already have, idk if that's something you could add to the NN but I think it would be pretty cool @@JohnnyCodes
@HeerderRatten
@HeerderRatten Жыл бұрын
Could you please make a video in which you explain how I can copy the NN and load it again for the next generation? I am despairing. Writing NN to a Json file works, but loading it back as NN doesn't work for me. Thank you for your videos, you do a damn good job!
@JohnnyCodes
@JohnnyCodes Жыл бұрын
Sure I can do that, are you using unity and C# for it like I did?
@JohnnyCodes
@JohnnyCodes Жыл бұрын
I made this reply to someone else a few weeks ago about it, but if you already saw that and it doesn't help I will probably make a video for it either way: kzbin.info/www/bejne/n6TEn6WcpcqVitU&lc=UgzGRxHHgdLfA7NLg2d4AaABAg.9r2bcOCUsTB9r3DXMHDuZy
@HeerderRatten
@HeerderRatten Жыл бұрын
@@JohnnyCodes It's amazing how fast you answer ^^ Yes, I saw @wShorts43's question and read your answer. However, I haven't tried it yet. I tried it without plugin. Simply save the data in a Json file. I think the mistake I made is to write the objects (Layer-values) one after the other into a JSON file instead of storing them in a list. If I have an object in the json it works as soon as I have 2 or more there is an error. I need to implement saving the Layer-values as a list. I'll do that tomorrow, I'll reply as soon as I've done it. A video of you would be very nice. Especially one like Part 4 (this video) for the Car AI. I thank you for your efforts you make a grate job! And yes I use Unity and C#
@grimmethymcbones8336
@grimmethymcbones8336 11 ай бұрын
Do you have anything on saving and loading specific models so I can use them again later?
@JohnnyCodes
@JohnnyCodes 10 ай бұрын
I remember using a asset on the unity asset store called quick save that can write classes/objects to file and then load them back in. I remember I could pass in the network class or I could just pass in the entire creature class to save a creature to file.
@grimmethymcbones8336
@grimmethymcbones8336 10 ай бұрын
Makes sense, I've seen the asset before in my browsing. @@JohnnyCodes
@akk2766
@akk2766 7 ай бұрын
Yes - I'm all for the suggestion (7:53) to create a consolidated video! And since you've asked, I'm really not a fan of stitching video up so that you don't have any umm's and ahh's - but this then makes it seem so robotic in nature. To me, it's actually very distracting to watch when there's so many obvious visual jumps in the video. A few hmm's and ahh's is not bad - it just shows you are human. Removing those and you are removing the human essence - IMHO.
@Unity_Tutorial_Games
@Unity_Tutorial_Games Жыл бұрын
good.. cool... all the best
@HeerderRatten
@HeerderRatten Жыл бұрын
Thanks!
@halloen1
@halloen1 Жыл бұрын
Can you maybe make a tutorial about learning an ai to walk in 2d step by step please? Or can you make a video about enemies (ai) that can fight each other? with guns or something so they have to learn how to dodge the bullets and aim correctly to get better? It would be really fun. Code Bullet have alot of really fun ai stuff, it would be really good if you made a tutorial of any of that stuff too.
@philly2548
@philly2548 10 ай бұрын
I'm stumped. I tried this and I ran into the same issue as he did initially with them not reproducing...i checked the "is trigger on 3D 'Food' Sphere. But it will not eat and reproduce
@akk2766
@akk2766 7 ай бұрын
It took a long while (~2-3 minutes) before my creature started to reproduce and for the children to survive long enough for them to reproduce. It might depend on PC performance - but I could be wrong...
@navidyaghmaei
@navidyaghmaei 8 ай бұрын
Hi, your videos were awesome 😎 and helped me a lot🙏. Have you ever seen "the bibits channel", he is doing also a neural evolution simulation and was using the neat algorithm(still a neural network). It was especially created for natural selection(this type of simulation). Would you be interested in doing a tutorial for that, it would be very interesting and work very good with the simulation?
@akotoy
@akotoy Жыл бұрын
Hey man can you explain how i would save the brain of the players for like a racing game?
@JohnnyCodes
@JohnnyCodes Жыл бұрын
Sure! I actually just got asked the same question at around the same time you asked it (Should probably add this to a video at some point) but basically I added a plugin and two functions to the neural network script. The plugin is free on the unity asset store and is called quick save (assetstore.unity.com/packages/tools/integration/quick-save-107676) At the top of the script you need to add this: using CI.QuickSave; Then I made these 2 functions: public void Save() { QuickSaveWriter.Create("jumping-v1-Round-" + roundNum) .Write("Car-"+ carId, layers) .Commit(); } public void LoadRound(int roundToLoad) { QuickSaveReader.Create("jumping-v1-Round-" + roundToLoad ) .Read("Car-"+ carId, (r) => { layers = r; }); } Then you can call the save function whenever you want and it will save it to a file, since the evolution sim isn't round based maybe you can call them days instead of rounds. Just make sure to make the string the exact same when you want to save and load a specific session. You call the LoadRound on the creature instances neural network script and as you can see it is currently set up to save and load all the networks layers onto the instance of the script it gets called on. I believe you can save and load any object using quick save so if you also wanted to save the entire creature I think you could do that too with some modifications, but I haven't tried that yet. Hope this helps! Let me know if you have any other questions!
@akotoy
@akotoy Жыл бұрын
is it possible for you to explain how to get the ai cars to learn well, i have fully completed everything but after turn one or two none learn to do anything else. any suggestions?
@JohnnyCodes
@JohnnyCodes Жыл бұрын
Yeah, I was actually thinking of doing a code breakdown and unity setup for the cars next like I just did for the Evolution simulator. But until I get that recorded, there are 2 possible things that come to mind. First is to make sure you are copying the brains of some of the best cars to the rest of the cars and then mutating the other cars. The second is to look out for if you are already doing that, is to make sure you don't mutate your best cars (The ones you copy the network from). Only mutate the ones that get copied too. Otherwise, it will be hard for them to learn since their progress gets overwritten by randomness. I usually save the top 10-20% of the best cars and copy from those to get more variation in the copies (You can only save 1 best car and they will still learn but then the rest are going to be very similar to that one and it will be harder for different strategies to emerge). Will try to clean up the code for the self driving cars today and hopefully record the video for it soon
@akotoy
@akotoy Жыл бұрын
@@JohnnyCodes I was trying to wrap my head around what you said on the second one but im kinda confused, Sorry😅 But, I was saving the only one best car and see how that could limit strategies. a lot of the time they will just slam into the wall first generation and never learn from that. So i think i see what you mean a little but for how to fix it im confused. Thanks so much for all your support! Your the most I have ever talked to a KZbinr and it helps a lot, thanks!
@argmentum22
@argmentum22 7 ай бұрын
remake in parts please with maybe a mix of all together, I would prefer to see the whole process though - making basic creatures and then adding the AI on top - im not a big fan of downloading and gluing things together as I feel I dont really learn anything.
@argmentum22
@argmentum22 6 ай бұрын
yep , after a week of trying to debug code botched together from parts 1.2 and 3 and from copying {not copy pasting}chunks from the git hub I still have problems.. my jagged array deosn't seem to work properly so I used the pre-streamlined version which doesnt crash but doesnt generate outputs - so I treied hard coding movement to at least make sure the controller was working , forwards command works but teh rotate jitters back to the original point and i really am not sure why.. .... so to answer yes please from scratch - #basic environment , #spawners and movement controllers, #basic AI including 1st run scrambled neurons, #mutation and breeding. at each point having something we can press play on so that we know it works up to that point.
@argmentum22
@argmentum22 6 ай бұрын
all that was missing was the if from the else if in the forward loop - missed it for so long..
@visheshl
@visheshl 8 ай бұрын
The creature spawner should copy the brain of the ten best creatures and then spawn the ten best creatures, otherwise the game doesn't progress further. Can you please implement saving and spawning creatures? I'm having a hard time doing it. Please implement save brain to text file and load brain from text file to spawn
@Daedron
@Daedron Жыл бұрын
I tried to follow along with this tutorial series, and in part 3 everything fell apart. By the time I got to the 5 minute mark I was beyond frustrated and I gave up on trying to follow along. I decided to just download the source code instead to see where my confusion spawned from. Looking at the source code, there is a VAST amount of information there that you never even touched on. I would recommend you follow your own tutorial to see if it produces the results you would want without having any other information.
@JohnnyCodes
@JohnnyCodes Жыл бұрын
Thank you for this feedback, I went through the tutorial as you suggested and reviewed all the code that was explained and all the code that wasn't. I found that the main parts of the code that I didn't include were the variables at the top of the Creature.cs function and the variables at the top of the Movement.cs function. I also didn't show the components being initialized in the Creature and Movement script as well. Here is the document that I highlighted while going through the tutorial: docs.google.com/document/d/e/2PACX-1vRANyyasVzZRI757mCZmPSV1kEBpR5xL4YieONzt-rQZDjS0dETtWg4689XS7cZ0pusvTYez5TRem5w/pub The Green sections are parts of the code that were covered in the tutorial, the yellow parts weren't covered but not needed and the code will still work well without them, and the red parts weren't mentioned but probably should have been. So I believe that most of the important parts of the code were shown but I do think that in part 3 it was very confusing because I switched between the creature script and the NN script while barely mentioning the switching happened. I think if I do combine this into one tutorial I will make sure to do the following: - Mention the variables at the top of the files and what I have them defaulting too - Showing me initializing the components in the awake functions - Show which file each function belongs to at the top of the screen and also show more context for where it should go in each file. Thanks again for the feedback, do you think that doing these things would help you and other people follow along with the videos better or is there something else you think I can do as well?
@Daedron
@Daedron Жыл бұрын
​@@JohnnyCodes Thank you for looking into it! I think these suggestions you made should be perfect. The only thing I could suggest that might be useful is a saving/loading system since you mentioned that capability in the first episode? Thank you for making this series, and I look forward to any more cool tutorials from you in the future.
@TheOldArthemys
@TheOldArthemys 24 күн бұрын
Hello John, I would like to contact you via discord to get some help from you, I wan't to make some test with neural network but just having the code won't help me, I would like it if you could help me a bit to have a better understanding of it, I know you just started but, any help would help me right now :)
@JohnnyCodes
@JohnnyCodes 21 күн бұрын
Hello, I am currently traveling for work so it is a little difficult for me to join a call at the moment but if you want to share your questions on here I can try my best to answer them when I have time and other people might have the same questions as well!
AI Cars Learn To Drive!
6:56
John Sorrentino
Рет қаралды 14 М.
Когда отец одевает ребёнка @JaySharon
00:16
История одного вокалиста
Рет қаралды 16 МЛН
НИКИТА ПОДСТАВИЛ ДЖОНИ 😡
01:00
HOOOTDOGS
Рет қаралды 3 МЛН
2 MAGIC SECRETS @denismagicshow @roman_magic
00:32
MasomkaMagic
Рет қаралды 18 МЛН
Human vs Jet Engine
00:19
MrBeast
Рет қаралды 164 МЛН
How I created an evolving neural network ecosystem
10:09
The Bibites: Digital Life
Рет қаралды 335 М.
Creating An Ecosystem Simulation Game In 6 Months
16:28
Fun Master Ed
Рет қаралды 509 М.
Делаю эволюцию ИИ в Unity
17:05
Onigiri
Рет қаралды 487 М.
Dear Game Developers, Stop Messing This Up!
22:19
Jonas Tyroller
Рет қаралды 723 М.
Simulating an Evolving Microcosmos | The Path to Multicellularity
19:04
5 Years of Making Games in Unity!
13:27
xzippyzachx
Рет қаралды 2,3 МЛН
Snake learns with NEUROEVOLUTION (implementing NEAT from scratch in C++)
28:08
A.I. Learns to play Flappy Bird
7:46
Code Bullet
Рет қаралды 14 МЛН
How to Create a Neural Network (and Train it to Identify Doodles)
54:51
Sebastian Lague
Рет қаралды 1,9 МЛН
Artificial Life. The battle of clans
19:34
Simulife Hub
Рет қаралды 489 М.
Когда отец одевает ребёнка @JaySharon
00:16
История одного вокалиста
Рет қаралды 16 МЛН