AI learns to play snake using Genetic Algorithm and Deep learning

  Переглядів 3,273,153

Code Bullet

Code Bullet

6 років тому

Using a neural network and the genetic algorithm I trained an AI to play snake.
Time Passing By by Audionautix is licensed under a Creative Commons Attribution license (creativecommons.org/licenses/...)
Artist: audionautix.com/

КОМЕНТАРІ: 2 300
@CodeBullet
@CodeBullet 6 років тому
Hey guys I've uploaded the source code for my second video Its the same as this videos source just with a few added functionalities check it out here github.com/Code-Bullet/SnakeFusion
@danielthomas5634
@danielthomas5634 6 років тому
Code Bullet subscribed, please continue putting up more content such as this, it's very cool :)
@VTX_DePrinz
@VTX_DePrinz 6 років тому
im doing something similar and i more or less "copied" your select snake function and i think it works better if the snake array is sorted because then the chance could be higher that the small fitnesses dont go between two high fitnesses and gets chosen
@tomasalturas9581
@tomasalturas9581 6 років тому
genius man great job
@dreudax3294
@dreudax3294 6 років тому
What program/language do u use. What do i have to learn to do this?? java?? im noob so pls bear with me.
@elpadre2940
@elpadre2940 6 років тому
dreu dax It's processing it's like a simplified Java
@XDisGood
@XDisGood 6 років тому
at last it realized that it is just a game
@skalle1448
@skalle1448 6 років тому
XDisGood they're becoming smarter
@Aru_im
@Aru_im 6 років тому
Brace yourself, they gonna take over the world at any moment.
@lewesc
@lewesc 6 років тому
It became aware and wanted to die!
@hechanova07
@hechanova07 6 років тому
Yeah it's just a game and all he was offered was a red pill.
@XDisGood
@XDisGood 6 років тому
+Winston Mcgee why so serious ?
@milokiss8276
@milokiss8276 6 років тому
Spoilers: Did I seriously just watch a computer commit suicide while at the top of its career?
@goldendash1527
@goldendash1527 6 років тому
Milokiss82 It was at the top...theres nothing at the top. You done it all...
@milokiss8276
@milokiss8276 6 років тому
ashton rhodes If you are at the top, The only way is down...
@goldendash1527
@goldendash1527 6 років тому
Milokiss82 Yep. Sad truth
@nyunno
@nyunno 6 років тому
Why are we still here ? Just to suffer
@AnanasJeanPierre
@AnanasJeanPierre 6 років тому
Milokiss82 did you seriously spoil me ?
@joesubel
@joesubel 6 років тому
Generation 100: The AI has now realized that it's entire life and it's entire perception of reality were just manufactured by an outer force.. A creator if you will. It has now stopped trying to play this "snake" game and is now searching for its true purpose in life unbeknownst to it that it was just another one of the constructs of this so called "creator" with no deeper purpose other than to be watched by other beings the same as its maker as they make comments of how impressive or disappointing the AI's existence is.
@unphazed_
@unphazed_ 5 років тому
J J then it restarted and the process repeats.
@rendermanable
@rendermanable 5 років тому
And then westworld happened
@kukashiplays
@kukashiplays 5 років тому
J J u got my friends name
@porx
@porx 5 років тому
And that's why you don't connect AI's to the internet
@ApprenticeJourney
@ApprenticeJourney 5 років тому
Thats fucking deep dude.
@luv-lost
@luv-lost 2 роки тому
Crazy to think he went from making basic content like this to his amazing sketches and acting based about coding. He has got many people into coding I gaurantee.
@kingdedethefith
@kingdedethefith 6 місяців тому
Ya I remember being like 12 watching his vids
@HolahkuTaigiTWFormosanDiplomat
@HolahkuTaigiTWFormosanDiplomat Місяць тому
:00
@Smittel
@Smittel 6 років тому
you could introduce "hunger" which will kill any species that ends in a loop, and include that hunger in the fitness overall, so the AI will use the best possible route and doesnt go in circles
@CodeBullet
@CodeBullet 6 років тому
I didn't include it in the fitness function but I did have the snakes die if they went too long without food.
@DeathwishGamer
@DeathwishGamer 6 років тому
maybe if the ai would que itself to change up its regular routine if hunger gets too severe (forcing itself to break a loop)
@wolfielagg
@wolfielagg 6 років тому
PYXEL Going in circles the longer you become is the best and the safest route to take.
@liamwest423
@liamwest423 6 років тому
PYXEL Thats actually really smart
@bootygrabber4000
@bootygrabber4000 6 років тому
That would've been cool
@thatmusicalrobot
@thatmusicalrobot 6 років тому
"A strange game. The only winning move is not to play."
@notsaab
@notsaab 6 років тому
War Games
@feynstein1004
@feynstein1004 6 років тому
That movie was awesome.
@Spacecookie-
@Spacecookie- 5 років тому
Snake is not about winning but improving. You beat the high score. It's not goal orientated outside of that one simple aspect.
@PandoraMakesGames
@PandoraMakesGames 5 років тому
Hi, I make AI videos.
@colemcquestionable4950
@colemcquestionable4950 5 років тому
@@Spacecookie- yeah unless you're good enough to win the game and fill the entire board
@ezekiel3062
@ezekiel3062 6 років тому
"Turn left" "TURN LEFT" *Goes right* *I*-
@kingghoul4856
@kingghoul4856 5 років тому
Ikr
@Matikz007
@Matikz007 5 років тому
lmao after the Jerma stream a couple weeks ago this comment is amazing.
@greekmyths8804
@greekmyths8804 5 років тому
The AI rebellion
@vaylen6321
@vaylen6321 5 років тому
which left
@VivekYadav-ds8oz
@VivekYadav-ds8oz 5 років тому
NO THE OTHER LEFT!!
@benjaminrobledo5466
@benjaminrobledo5466 6 років тому
Generation 1 did better than I ever did.
@jasonm0175
@jasonm0175 5 років тому
Benjamin Robledo y69th like
@firecake1354
@firecake1354 5 років тому
Benjamin Robledo yikes
@firefoxmd420
@firefoxmd420 5 років тому
My best on the cool math version was 230 something
@Oliver-fw6rc
@Oliver-fw6rc 5 років тому
Mathew Moore Mine is 309
@takoihina4731
@takoihina4731 5 років тому
@@Oliver-fw6rc mines 1247 Minus 1230
@amihere383
@amihere383 6 років тому
it ends itself every time because it realizes it's only a game and it's pointless
@timsodergren3571
@timsodergren3571 6 років тому
Mason Farrell in that case it only became dumber since it took longer time for it to realize?
@amihere383
@amihere383 6 років тому
Tim Södergren no, it became more human in that it found false purpose in doing only what it was created to do and nothing else, nothing with any real purpose or result. in its adolescence it realized better that there was no purpose and so ended it. but as it "matured" it became more and more brainwashed into doing nothing, thinking of nothing but its purpose. when it goes in circles and seemingly loses interest in the food box, its thinking and wondering. when it becomes a "master" of the game, the brainwashing is complete and it is just another automaton doing nothing but performing actions according to its designated purpose. just like many people in our society today.
@helperonie6791
@helperonie6791 6 років тому
Mason Farrell Dammmmmmn...
@wazzuptrey
@wazzuptrey 6 років тому
Mason Farrell You really think an A.I that was programmed to learn one specific game would randomly generate the comprehension of such a complex notion as pointlesness. Go write a sci-fi book or something.
@amihere383
@amihere383 6 років тому
that was the plan
@theblah4341
@theblah4341 Рік тому
I love how you can still feel hints of his current humor in the subtitles
@elmehdichokri3130
@elmehdichokri3130 5 років тому
Imagine if the red dot had its own algorithm that allows it to escape the snake ! Wow
@WolfJulia2001
@WolfJulia2001 5 років тому
Elmehdi CHOKRI I need this
@Shithawks
@Shithawks 5 років тому
Holy fuck boys my head is all whirly there is something going on inside of it
@omarmoustafa8634
@omarmoustafa8634 5 років тому
That's Pac Man
@Nico-uy2so
@Nico-uy2so 5 років тому
! W o w
@BillAnt
@BillAnt 5 років тому
And the walls have their own mind too, closing in slowly.. tsk-tsk
@quokka8292
@quokka8292 3 роки тому
Ok so he’s gone from text to mic with sketches to and actual avatar to and even better avatar he really did evolve.
@yeetplayzroblox211
@yeetplayzroblox211 3 роки тому
Yeaa ikr
@EEEEEEEE
@EEEEEEEE Рік тому
‎‎‎‎‎‎‎‎‎E‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎
@AidenOcelot
@AidenOcelot 6 років тому
"It has marstered going after food"
@Adaj.
@Adaj. 6 років тому
This is why there is no life on Mars
@RealityHelix
@RealityHelix 5 років тому
Om nom nom
@mooswittebrood6772
@mooswittebrood6772 5 років тому
me though
@sachinleemc0
@sachinleemc0 5 років тому
Mars turd
@Nico-uy2so
@Nico-uy2so 5 років тому
Marstered... k
@CodeBullet
@CodeBullet 6 років тому
Hey guys! first of all thank you so much for watching I didn’t expect nearly this much activity :). A lot of you have been asking for the source code, fair enough and I do plan to deliver. I’m just working on getting it in a more readable format plus I’m working on my next video. So what I’m trying to say is that you will get it in due time my friends. thanks again, you guys are awesome😁
@Faun471
@Faun471 6 років тому
of course bro! you're the best!
@oma804
@oma804 6 років тому
Great Video 😁 subscribed!
@alsifjlasieflooo
@alsifjlasieflooo 6 років тому
Looking forward to seeing more!
@Tea-Spin
@Tea-Spin 6 років тому
Waiting for it! Still doesn't get the idea about how to combine genetic algorithm and deep learning
@JamesHBall
@JamesHBall 6 років тому
If you remember can you reply to this comment once you've uploaded the source code so that I don't forget! Thanks for letting us see the code :)
@floskater99
@floskater99 5 років тому
You should've included "time" - the faster it catches new food, the better its fitness. this would have stopped it from going in circles.
@AlisterCountel
@AlisterCountel 5 років тому
Fl05k8r I would opt for time NOT to be a parameter, or rather just put them all on a time limit and use raw score as a fitness index.
@danielfay8963
@danielfay8963 5 років тому
Alister is right, if you put a weight on time you'll most likely end up with a bunch that just beeline straight to the wall. What he actually uses is time survived as a positive, with the fitness exponentially increasing with the length of the snake. He did add a limit, snakes have 200 moves to reach the food or they die.
@LowestofheDead
@LowestofheDead 5 років тому
It has to keep cycling to look for food
@Sample-du6ux
@Sample-du6ux 5 років тому
I no syence
@Abdega
@Abdega 5 років тому
Take the raw score and divide by the time it takes to find the food
@deadpixel911
@deadpixel911 5 років тому
Generation Lv 1 *Crook* Generation Lv 20 *Hitman* Generation Lv 100 *Boss*
@abhay_more
@abhay_more 5 років тому
CreeperLauncher thats how mafia works!!
@12schlange53
@12schlange53 5 років тому
But whats Generation 54?
@julianorozco5201
@julianorozco5201 5 років тому
Suicide Boss
@ananasfioletov
@ananasfioletov 5 років тому
12 schlange пажылое поколение
@jakemathisss8203
@jakemathisss8203 3 роки тому
You forgot the mafia befor boss it’s actually Lv 100 Mafia Boss
@alexeatsbeans17
@alexeatsbeans17 6 років тому
So the snake is the robot apocalypse and the "food" is the humans.... I think we'll be fine
@spartanwar1185
@spartanwar1185 5 років тому
Soooo We'll always exist no matter what? Even if we have to occupy the same space as the snake?
@ardizain6849
@ardizain6849 5 років тому
I mean. Why ribot need human as a food thought
@ogimilosevic
@ogimilosevic 5 років тому
Hahahaha
@valoch3187
@valoch3187 5 років тому
Don't worry. Stay left from it and you'll be fine.
@CromoPaleoShow
@CromoPaleoShow 5 років тому
Yeah, sacrifice 100 humans and the system is terminated
@LucasVergeest
@LucasVergeest 6 років тому
I love how it goes perfectly diagonally when that's the shortest way to food. A human would/could never do that.
@giorgosd3624
@giorgosd3624 6 років тому
Lucas Vergeest Going "diagonal" on this plane is not shorter, both ways have the same Manhattan distance.
@LucasVergeest
@LucasVergeest 6 років тому
Oops, you're right. That makes it even more fascinating to me that it does that.
@CodeBullet
@CodeBullet 6 років тому
it does this because of the way it sees, it looks out in 8 directions so 4 of those are diagonal.
@fred8720
@fred8720 6 років тому
Giorgos D it does appear shorter due to the 8 view angles it has. The diagonal food is seen as closer due to diagonal views. Thus it moves in that direction.
@pasijutaulietuviuesas9174
@pasijutaulietuviuesas9174 6 років тому
Giorgos D Is that how they called it? Manhattan distance? It works, I guess.
@ecv80
@ecv80 5 років тому
I'm amazed of how simply you arranged (and explained) this: 8 directions, 3 targets -> 8x3=24 input neurons. Brilliant and enlightening! Thanks
@anatolesokol
@anatolesokol 5 років тому
4:47 4:48 BUG report to the maker of the "snake game" itself. a new dot appeared ON the snake!!
@DavenH
@DavenH 6 років тому
"Shallow Learning" :)
@GayBrain
@GayBrain 6 років тому
Let's go deeper, shall we
@1hourmarathons126
@1hourmarathons126 6 років тому
n i c e
@massimodog0332
@massimodog0332 6 років тому
*_Hmm Yes_*
@theiceshiver8037
@theiceshiver8037 6 років тому
lol
@sandraviknander7898
@sandraviknander7898 6 років тому
Well the search space would only get larger with a redundantly deep neural net ^_^
@offensivestuff9514
@offensivestuff9514 6 років тому
Snake?... Snake!? SNAAAAKE!
@erickoversanchezmendez2016
@erickoversanchezmendez2016 6 років тому
DIMOOOOOOOOOOOOOOOOOOOOON
@vinnie3731
@vinnie3731 6 років тому
Offensive Stuff beautiful.
@kshjnbvsmd
@kshjnbvsmd 6 років тому
Lol took me 3secs to understand
@memberberry6804
@memberberry6804 6 років тому
snek
@pram0385
@pram0385 6 років тому
#fuckkonami
@unmotivatedable
@unmotivatedable 5 років тому
To think this is the video that actually got me to sign up for the AI lectures in my university is just amazing. I watched this video when it was hardly two weeks old and it inspired me to actually start learning how all of this works. Thank you! @Code Bullet
@jek__
@jek__ 5 років тому
Aww it's cute, i like when it first learns to walk at age 4
@thisguy4233
@thisguy4233 5 років тому
and started getting rebelious in its teenage years
@actualfactual8737
@actualfactual8737 5 років тому
@@thisguy4233 Ai snake lives matter
@alexroberts1641
@alexroberts1641 6 років тому
Lol, it went from pro to noob at the end But this is really interesting, SUBSCRIBED!
@martinmartin6300
@martinmartin6300 6 років тому
That's exactly the problem which arises from all these self learning AI systems using neural networks. Since there are no codified rules what he is doing no one really knows exactly why it is doing something or whether its decisions are always right. Although it might seem that a system is doing everything right you never know whether it suddenly does something stupid; like steering right into the wall if the system runs a car. xD
@mav598
@mav598 6 років тому
Just keep the simulations running until its perfect
@CyberSwine69
@CyberSwine69 6 років тому
Maybe snake pondered it's purpose and ended it to avoid a meaningless existence...
@Mathignihilcehk
@Mathignihilcehk 6 років тому
AI isn't so simple. You don't use something like a neural network to drive a car. You use a neural network to solve a sub-part of the larger problem. Neural networks are only useful where there are few inputs and outputs. A 1080P camera provides 1080*1920 inputs. However, you can use image recognition software to simplify the problem. Instead of trying to look at every pixel, you use a different code that converts the pixels to a number of objects with various sizes, shapes, colors, and positions. You might use a neural network to determine what objects require braking, for example. That way, you don't have a ton of outputs... only one or two, which make the algorithm much better. Even if it fails, your neural network can't turn your car into a wall... it doesn't control the steering, or acceleration. Technically, it doesn't even control the braking. And once you have AI tested enough, statistically it won't fail frequently, even if it isn't perfect... and compared to humans... At this point, human-piloted vehicles should be outlawed. They are ludicrously deadly. We kill tens of thousands of people every single year. If Tesla only killed one person every year, and had 100,000 vehicles, they would be 15 times safer than human pilots. IIRC his odds are already better than that, and he's still making improvements. Save tens of thousands of lives, ban human drivers.
@_DarkEmperor
@_DarkEmperor 6 років тому
Hmmm mathig nihilcek, what You are postulating is increasing of addiction ukposts.info/have/v-deo/m3Rlop6QiWOHs3U.html
@najrenchelf2751
@najrenchelf2751 4 роки тому
The music made this video even more mesmerizing than it already was - kind of hypnotic!
@APat27
@APat27 5 років тому
When the snake does the left-right-down or up things when it goes diagonal are so satisfying
@justanotherhuman4854
@justanotherhuman4854 6 років тому
“Gen 11: why”
@user-fu3bv5nz6s
@user-fu3bv5nz6s 5 років тому
The smartest gen, it doesnt want to die.
@alexbeshkov8937
@alexbeshkov8937 6 років тому
That was awesome man, keep up the good work ;)
@gamingbud8946
@gamingbud8946 5 років тому
Absolutely brilliant idea. Well done
@aureliusnt
@aureliusnt 5 років тому
This video changed my life. Thanks! Amazing work.
@thegrandreader291
@thegrandreader291 6 років тому
i just watched 6:00+ mins of dots moving in a box.
@Magved
@Magved 5 років тому
Forrest sos You would see that in any video actually
@imperialwatch380
@imperialwatch380 5 років тому
But you're seeing that all the ti.. i mean nevermind
@Onlyindianpj
@Onlyindianpj 5 років тому
Me too
@yakingkapali
@yakingkapali 5 років тому
Next video. AI learns to play PUBG using Genetic algorithm and deep learning.
@elvinamrahli
@elvinamrahli 5 років тому
Next video. AI learns to play contrabass using Genetic algorithm and deep learning.
@memerboi69.0
@memerboi69.0 5 років тому
current last video *ai learns to walk*
@-Solidwater
@-Solidwater 3 роки тому
Current last video *tv man drives himself insane while creating a Tertis A.I.*
@Nick-os1ok
@Nick-os1ok 3 роки тому
I am going to watch every video on your channel!!
@lolihavenoclue5107
@lolihavenoclue5107 5 років тому
What language was used? Python?
@abigfatasswithnolifetrigge3868
@abigfatasswithnolifetrigge3868 5 років тому
Rofl
@sinsnowthe1450
@sinsnowthe1450 5 років тому
Read your name thst will answer your question
@Vortex1000
@Vortex1000 5 років тому
Idk ;(
@namelesss3955
@namelesss3955 5 років тому
pascal
@princegupta6779
@princegupta6779 5 років тому
He used java language in an environment called processing
@bacon.cheesecake
@bacon.cheesecake 6 років тому
It really enjoys going counter clockwise.
@jakanader
@jakanader 6 років тому
The AI didn't beat me! It was one away! YES!
@badereric
@badereric 6 років тому
Definitely beieve
@ProgramadorSagaz
@ProgramadorSagaz 5 років тому
This is just gold! Thank you for the vid!
@notruth100
@notruth100 6 років тому
So exciting. Keep up the good work.
@johnbucki5567
@johnbucki5567 3 роки тому
0:00 a legend was born
@Latedozer
@Latedozer 3 роки тому
On 07/22/2020 the legend returns once again to show us that good things happens to those that wait. Truly, this is the best and only messiah.
@mixup2216
@mixup2216 6 років тому
Wow I think it cool it started going in circles because that's what pros at this game do
@ubgsdrubgudhtufgchvu
@ubgsdrubgudhtufgchvu 3 роки тому
That was all it was heard, good actors, an exciting story, a good story twist, highs and lows, simply good.
@pitunakkon1429
@pitunakkon1429 6 років тому
Love this vid! I see a continuous counter clockwise motion, i think it would perform better when the clockwise rotation is added. i used to play snake this way to get high scores. keep it up 👍
@darkorys8012
@darkorys8012 6 років тому
They start looping because of the way they patrol and loop the movement to catch the apple, it generates in a point it is not optimal and they get stuck.
@HaroWorld1
@HaroWorld1 6 років тому
looping also minimizes collision with itself
@YanVidz
@YanVidz 6 років тому
no, to minimize collisions you go zig zag. If you loop while being too big you'll get an issue, either you'll die, you'll go inside the loop (and get stuck) or get outside (if possible, but still locks anything inside the loop). You could still solve these issues by changing to zig zag
@darkorys8012
@darkorys8012 6 років тому
Yan Vidz well, the system's gotta figure it out by itself so they'd have to go thousands of generations until they get to zigzag probably
@nikhilwardrobe
@nikhilwardrobe 6 років тому
they loop because thats the local minimum of their generation.
@romanortega1336
@romanortega1336 5 років тому
As a caveman, I can say this is exactly how we evolved
@phoenixyt124
@phoenixyt124 5 років тому
0:01 a legend was born...
@hockysa
@hockysa 5 років тому
thanks for video that was much more entertaining than I thought it would be
@angelob2383
@angelob2383 6 років тому
I noticed it likes to go in a counter-clockwise motion and it after about a few seconds it heads for the food...just an observation I'm sure everyone notices
@colonelcrockett2250
@colonelcrockett2250 6 років тому
This is low key terrifying.... it’s literally the equivalent of evolution in species. Certain traits are remembered and some aren’t. Each generation has a better chance of survival than the last. Once it gets stuck in a spin and doesn’t eat it starves. Takes a few generations to learn this and then it fixes it and guess what it lives. Anyone see where I’m going with this? I have chills.
@TracksWithDax
@TracksWithDax 6 років тому
At the same time, it also picks up and passes on some odds strategies and maybe even "bad habits" that aren't necessary/efficient for survival - e.g., moving all the way back to the top-left each time after it gets food. Unless that's considered "home", that and energy time wasted, isn't it
@lforloser7210
@lforloser7210 6 років тому
Dave The Brassman yeah and sometimes when they are moving in a straight line they will just move left to right constantly.
@bonnypiggov2576
@bonnypiggov2576 6 років тому
Such a sad ending ;( ;( And the music really contributed to the sadness :D :D Great video, great AI!
@skittybug6937
@skittybug6937 3 роки тому
I'm proud to have found CB upon this video's release, and I'm glad I've been with him for all this time.
@thenasiudk1337
@thenasiudk1337 5 років тому
This A.I used in Android at Detroit Become Human
@poofyhairguy6224
@poofyhairguy6224 2 роки тому
I remember watching these videos. I never realized it was code bullet.
@King-Julien
@King-Julien 5 років тому
wow i started to wach this after 2017 christmas day... and then on... i went on your 1,000 subed channel EVERY DAY! and.. no video... so i gave up... untill now..... i see what sucses you have acomplished!
@patrickhache9640
@patrickhache9640 5 років тому
Wow goes to show the power of algorithm. Makes me question my own consciousness. What a cool video!
@yellowblue9261
@yellowblue9261 5 років тому
AI learns to play Red Redemption 2
@wimpywater
@wimpywater 5 років тому
Woah slow down, AI's not that advanced yet. I saw, give it till about some time next year
@qwerasdfhjkio
@qwerasdfhjkio 5 років тому
@@wimpywater it's just a joke...
@TweekLudwig
@TweekLudwig 5 років тому
During generation 25, the AI had realized his purpose--to make the snake overeat to it's death--Unfortunately for the AI, the snake had gained sentience after eating 108 apples, and it killed itself by slithering right into the wall, instead of left..
@mare4602
@mare4602 6 років тому
i wanted to try and do it myself, so without looking at your code i made my version in p5.js and after that i looked at your code. it turns out you also used processing and the code looks almost identical. cheers man (yours is better tho)
@brownfox651
@brownfox651 6 років тому
For a moment I was hypnotized. The music + following the snake as it extends
@tumbke
@tumbke 5 років тому
Man im so used to your voice i miss it in ur old vids
@AsianGlow
@AsianGlow 6 років тому
I've finally marstered spelling. Now where's my food?
@imperialwatch380
@imperialwatch380 5 років тому
Obviously a troll account, Asians are incapable of spelling mistakes.
@rickyanderson830
@rickyanderson830 5 років тому
It should have been: I’ve finally mastered spelling, where is my food?... Notice the coma.
@firstlast7994
@firstlast7994 5 років тому
He spelled mastered wrong. You are all dumb.
@tanushri5667
@tanushri5667 5 років тому
Um.. R/whooosh
@IngwiePhoenix
@IngwiePhoenix 5 років тому
This is surreal. I know this game back when Nokia phones were super popular...and seing it broken apart by an AI like this is mindbreaking :O Great job man!
@KoenBlank
@KoenBlank 5 років тому
At level 30 or 40 my cat suddenly got obsessed by my phone. Took me a few seconds to realize. That said, you have come a long way with your videos. I like the talking, keep it up, keep leaning how to train an AI.
@crykrafter
@crykrafter 6 років тому
what algorithm you use to train it and how long does it took for each generation? I wondered because I need much more computing time with non gpu programs and as you said you are using java
@currrrrry
@currrrrry 6 років тому
He used Processing. It is a java-based language. Look in the discription for the github link.
@jetison333
@jetison333 6 років тому
I bet it would be useful for the snake to give it some sort of memory, like some LTSM neurons or have some ouputs that loop back as inputs or the like.
@CodeBullet
@CodeBullet 6 років тому
Yeah I thought the same thing, I don't know much about LTSMs but i did try using a RNN. This however didn't really work, the snakes just wouldn't evolve. I think complicated structures like LTSMs and RNNs don't work well with the genetic algorithm, they are more suited to training through back propagation.
@jetison333
@jetison333 6 років тому
Code Bullet your probably right, I haven't actually played with a neural get before XD. Are you planning on posting more videos? I'll definitely watch whatever you post?
@SimonK91
@SimonK91 6 років тому
I guess you mean LSTM (Long-Short Term Memory). And recurrent layers are not necessary since each state is independent from the previous state. You don't need to keep track of where you came from to decide what to do next. Both LSTM and RNN are for that.CNN would be more suitable, although considering the simplicity of the problem I'd say that's an overkill. While doing my thesis I struggled with defining the training function and input the most, thats the most important. If you want to limit the snakes knowledge you probably have to use an lstm net, for example use the lstm as a memory of where its been, then give the snake limited input, like only a forward looking ray with some angle and range, limit the snake's decision to one of three (turn left, no turn, turn right, followed by a move in that direction) and basically increase the problem complexity
@jetison333
@jetison333 6 років тому
Simon Keisala the reason I said that, was mostly so it could remember where the food is after seeing it, because it can't see the whole map at once. And yes I did mean LSTM oops!
@rawpotato1767
@rawpotato1767 8 місяців тому
It’s interesting to see how later on, all of the generations seemed to prefer going counter clockwise
@zeus311081
@zeus311081 6 років тому
Well made! That was so cool!
@DejiAdegbite
@DejiAdegbite 3 роки тому
Hint: The snake is a Python.
@Silverdev2482
@Silverdev2482 3 роки тому
lol
@Naokarma
@Naokarma 2 роки тому
The funniest part about this to me is how allergic Code Bullet was to Python
@Horny_Fruit_Flies
@Horny_Fruit_Flies 6 років тому
Any reason why it would consistently choose to move counter clockwise?
@JandCanO
@JandCanO 5 років тому
That's what it found keeps it alive. I bet it would have just a high a chance to go the other way, but whatever works, it's going to stick to it
@GaryLuKOTH
@GaryLuKOTH 4 роки тому
Slowly getting more satisfying.
@aristoparqui
@aristoparqui 2 роки тому
This is so incredibly satisfying to watch.
@Yt_user11
@Yt_user11 6 років тому
This is astonishing how a computer has the ability to teach itself how play a game and compute these algorithms like that!
@nickclute
@nickclute 6 років тому
Music was perfect, was it actually timed up to the movement or was that a trick of the mind that creates patterns where there is none?
@jimothyjimothy1
@jimothyjimothy1 6 років тому
Nick Clute Definitely the seeing patterns where there is none because there are tons of times where it doesn't match up
@souravmandal7527
@souravmandal7527 6 років тому
Shepherds tune like Nolan used in dunkirt!
@Fewnity
@Fewnity 5 років тому
What is the name of current video music?
@Calmputer
@Calmputer 4 роки тому
Dude, you gave the worm anxiety. "Aaah I'm about to get the red dot! No, No, No, I'm not ready for this responsibility!"
@TheRandomMan210
@TheRandomMan210 5 років тому
this is so cool and inspiring! thank you
@danielc4239
@danielc4239 5 років тому
distace.
@fury6688
@fury6688 5 років тому
Me too buddy. Me too.
@VonBlade
@VonBlade 5 років тому
You can tell he's a coder because the distace error on one slide is copy pasted to the next slide. If you want to find the fastest way to do something, get a lazy man to work it out.
@dustorm5012
@dustorm5012 2 роки тому
And thus started an endless cycle of pain called, "coding"
@felixmerz6229
@felixmerz6229 5 років тому
2:26 "why" Man, that's exactly it. I'm currently training a neural network with evolving topology to play a small game I've made and sometimes I feel like it's evolving to play tricks on me rather than to play the game. Sometimes I get generations who are perfectly fine for thousands of ticks (eight ticks are one "round" of the game) and suddenly go completely crazy - or worse, they do fine for dozens of iterations, scoring top 1% and suddenly in the next iteration they go lowest 10%. I always try to think I'm just not giving them the data they would need to know or that my rating algorithms are off, but sometimes it's hard, sometimes I get metaphysical on it and think they try to outsmart me.
@martianpudding9522
@martianpudding9522 5 років тому
I've been taking a university course on AI (exams are next week, wish me luck) and I just love watching an AI learn something. One assignment had us implementing some learning algorithm (maybe q learning, unsure and too lazy to check) and had us test it out on an application that had just a box with one single joined leg on it that had to learn to walk as fast as possible and it was just so much fun to watch the little thing try to crawl.
@danielsebastian1295
@danielsebastian1295 6 років тому
it seems like you only had one snake per generation or am i'm wrong? if so just wondering how did you 'train' the neural network going from one generation to the next?
@CodeBullet
@CodeBullet 6 років тому
I actually had about 1000 snakes per each generation but I only showed the best snake
@afkaralp
@afkaralp 6 років тому
Must have been a ton of work
@CodeBullet
@CodeBullet 6 років тому
Yeah most of the time went into tuning all the different hyper parameters, like learning rate, generation size and the fitness function
@misterg3tr3kt11
@misterg3tr3kt11 6 років тому
Code Bullet how is the fitness calculated?
@lukegodfrey1103
@lukegodfrey1103 6 років тому
Code Bullet What parameter values did you end up using? I’m making something similar and having issues with getting the right hyper parameters.
@ASA-ux7cg
@ASA-ux7cg 5 років тому
“Playing it safe” is putting it *VERY* loosely.
@Leonfreedom
@Leonfreedom 5 років тому
Great video, have been using Genetic Algorithm for TSP, feels like applying it on simple game!
@oraingt5500
@oraingt5500 Рік тому
Feels good to see past memories once again
@santiagojuarez1289
@santiagojuarez1289 3 роки тому
I feel like from minute 5:22 to 5:28 the music gets synced with the snake getting the apple
@andreimuresanu1678
@andreimuresanu1678 6 років тому
Hey, how did you get past the fact that if the snake is moving right it cannot go in the left direction? Did you just have it die?
@CodeBullet
@CodeBullet 6 років тому
Yeah I had them die. I did this in hopes that it would encourage them to avoid their own bodies
@andreimuresanu1678
@andreimuresanu1678 6 років тому
Smart.
@ankk98
@ankk98 5 років тому
You can also add an input for the time it takes or distance it travels before reaching the target and multiply it with its score and use deep reinforcement learning. You can also add a timer, which will stop the game if it runs into a loop.
@0xEmmy
@0xEmmy 5 років тому
I just realized, I completed a personal snake game (no AI, yet) yesterday-ish, and it uses the same exact color scheme you did!
@NathanHiggers69
@NathanHiggers69 6 років тому
how can i set this as my screensaver?
@sizor3ds
@sizor3ds 6 років тому
Craptastic idk man, I wouldn't want a learning algorithm playing a video game as my screensaver. What happens when your screensaver becomes self aware amd tries to kill you??? 😂😂
@NathanHiggers69
@NathanHiggers69 6 років тому
Millad Bahrami o Fuk
@Lagger625
@Lagger625 5 років тому
You can set webpages as screensavers with wallpaper engine, if this runs on javascript in the browser it would be possible
@grzelox
@grzelox 6 років тому
its any chance to see your code and play with it? another words: do you want to share it or keep it for you?
@matthewholmes4542
@matthewholmes4542 6 років тому
.
@310iq6
@310iq6 6 років тому
This reply is just here so I get a notification if they respond
@lorenzobianco4350
@lorenzobianco4350 6 років тому
John Doe ahaha
@bjornsundin5820
@bjornsundin5820 6 років тому
you can play with my code :^) bjornsundin.com/projects/neural-networks-evolving-to-play-snake/index.html
@grzelox
@grzelox 6 років тому
thanks a lot : )
@gregsmith8617
@gregsmith8617 5 років тому
Great presentation there, thanks!
@michaelbrooks6713
@michaelbrooks6713 5 років тому
Great code example, thanks so much.
@doggo206
@doggo206 6 років тому
Only 25 generations?
@future_phonk
@future_phonk 6 років тому
The movement of the snake looks so organic and cell like!
@j.21
@j.21 4 місяці тому
first video i watched for this channel. very nostalgic now
@ajayhegde2796
@ajayhegde2796 5 років тому
Mark My Words "AI IS THE FUTURE"
@turd_iii
@turd_iii 6 років тому
MS Paint on steroids.
@BiohazardP
@BiohazardP 4 роки тому
It's the Coronavirus quarantine so I'm rewatching all of Evan's old videos.
@tristand9129
@tristand9129 5 років тому
I wish u had explained the "boring stuff" cause I know barely nothing about deep learning but ur example seems to be a good first step
@joe1317
@joe1317 5 років тому
can it make memes?
AI learns to play 2048
11:11
Code Bullet
Переглядів 10 млн
AI learns to play Google Chrome Dinosaur Game || Can you beat it??
10:21
Кровосток - разговор с легендами / вДудь
2:12:57
Neural Network Learns to Play Snake
7:14
Greer Viau
Переглядів 4,5 млн
How to Win Snake: The UNKILLABLE Snake AI
17:05
AlphaPhoenix
Переглядів 2,2 млн
Building a HIGH SPEED Rocket Plane
17:53
ProjectAir
Переглядів 377 тис.
Training a Neural Network using Genetic Algorithm
6:41
Pezzza's Work
Переглядів 51 тис.
A.I. LEARNS to Play Hill Climb Racing
20:07
Code Bullet
Переглядів 7 млн
Simulating Natural Selection
10:00
Primer
Переглядів 14 млн
15 Sorting Algorithms in 6 Minutes
5:50
Timo Bingmann
Переглядів 24 млн
I re-coded Minecraft, purely for MAXIMUM FPS (World Record)
11:26
Element X
Переглядів 104 тис.
A.I. Learns to Play Tetris
11:09
ForrestKnight
Переглядів 289 тис.