Neural Network Learns to Play Snake

Поделиться
HTML-код
  • Опубликовано: 3 ноя 2018
  • In this project I built a neural network and trained it to play Snake using a genetic algorithm.
    Thanks for watching! Subscribe if you enjoyed and Share if you know anyone who would be interested!
    GitHub Repo: github.com/greerviau/SnakeAI
    Twitter: / greerviau
    Support me on Patreon: / greerviau
    Thanks to Josh Cominelli for the music!
    Soundcloud: / josh-cominelli
  • НаукаНаука

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

  • @MrPman1999
    @MrPman1999 4 года назад +23515

    You guys think that the snake died because of the lack of left turns, but in reality the snake evolved to the point where it got consciousness and understood that life dedicated to running in circles is not worth living.

    • @nsfrozen
      @nsfrozen 4 года назад +601

      No One ur joke is so dark, it darken my life

    • @user-mi8ew2to8e
      @user-mi8ew2to8e 4 года назад +32

      WoW

    • @2qood4lyfe
      @2qood4lyfe 4 года назад +172

      almost cut myself on all that edge

    • @Alva1326
      @Alva1326 4 года назад +29

      No One agreed

    • @benbabu9404
      @benbabu9404 4 года назад +42

      That's deep

  • @morphman86
    @morphman86 5 лет назад +5838

    For anyone who wonders why it seems to prefer right turns, I believe that is because it started at the top-left, going towards the right. There was no way for it to turn left. So with 2000 snakes per generation, a LOT of those learned that left is death. Since right worked every time, it simply had no reason to learn that turning left after leaving the wall would be safe.
    I believe that is also why you got those wiggly motions. That's it trying to turn left, but then immediately turning right again, so its profile won't go any further to the right than the starting position.

    • @linuxatheist5361
      @linuxatheist5361 5 лет назад +801

      It might be interesting to see what happens if the starting position is randomised

    • @trex70
      @trex70 5 лет назад +119

      What about the middle ?

    • @Tracer527
      @Tracer527 5 лет назад +50

      @@trex70 middle and just go down, snake will choose Left or right way by red points

    • @badkingjohn5235
      @badkingjohn5235 5 лет назад +41

      About what I thought, but does this mean it is unable to get significantly better scores, because it will suicide inevitably by coiling up instead of folding itself?

    • @morphman86
      @morphman86 5 лет назад +74

      @@badkingjohn5235 The most likely scenario is that it will discover that it can fold itself in that direction, which makes it survive for some time longer.
      It will therefore take days, possibly even weeks, to simulate it to the point where it learns to fold in both directions, or fold and twist around.

  • @funny3511
    @funny3511 4 года назад +3302

    ME: "Hello World">>20 errors found.

    • @NoctumusTV
      @NoctumusTV 4 года назад +28

      Funny: Funny! Funny ... ?

    • @tophatv2902
      @tophatv2902 4 года назад +63

      @@NoctumusTV what?

    • @marls3518
      @marls3518 4 года назад +21

      @@NoctumusTV Can you pls explain again. Thanks in advance.

    • @tophatv2902
      @tophatv2902 4 года назад +6

      @@NoctumusTV oh ok

    • @NoctumusTV
      @NoctumusTV 4 года назад +5

      @@marls3518 Explain what again?

  • @Taikore_
    @Taikore_ 4 года назад +962

    2:26, that’s literally just a dog

  • @cap1819
    @cap1819 4 года назад +3292

    My favorite part is every time you think the AI finally has it down, then runs into a wall for no reason
    Every time

    • @user84074
      @user84074 3 года назад +210

      that's what God said, when watching humanity

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

      there is a reason, the human element is a fuck up disgrace in this case

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

      Maybe time for revolution

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

      @@user84074 Then God killed the program

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

      Same as humans)

  • @prodkilobyte
    @prodkilobyte 4 года назад +3072

    Left turns: *Am I a joke to you?*

    • @clarkkent6026
      @clarkkent6026 4 года назад +9

      I observed the same thing; is that a design flaw?

    • @pocketrocket27
      @pocketrocket27 4 года назад +37

      It's not an ambiturner.

    • @vakie3250
      @vakie3250 4 года назад +52

      Neural networks is a lazy algorithm and will take the shortest route to achieve its goal. My guess is that the input of the distance from the left wall from the snake plays a significant importance to its decision making.
      You can use dropout which will force other nodes to train that never gets a chance when the whole network gets trained

    • @Super-id7bq
      @Super-id7bq 4 года назад +6

      @@pocketrocket27 God damn you Ivan - you beat me to it. Damn you to hell :D

    • @nazmussakib1551
      @nazmussakib1551 4 года назад +4

      but it took left turns

  • @rutvikrana512
    @rutvikrana512 4 года назад +1300

    I think another one reason why this doesn’t get higher because in input it gets -
    1. Distance to food
    2. Distance to wall
    3. Distance to tail
    Wait but what about its whole body ??
    So that’s why snake trap around it’s own body.
    Just a guess though 🤔

    • @PredaFortyTwo
      @PredaFortyTwo 3 года назад +52

      thought the same, but could the lenght just be another input neuron ?

    • @zkenk
      @zkenk 3 года назад +23

      We could probabaly include the previous outputs as an input like an LSTM or GRU

    • @suvigyajain9360
      @suvigyajain9360 3 года назад +136

      Perfectly correct. If you feed it the location of the whole body in terms of a matrix it will evolve to the point where its better than any human playing the game

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

      Nice observation

    • @log234
      @log234 3 года назад +8

      Yup, using a CNN would be a good approach for this problem, I think. Use a different weights for the head, tail and the location of food.

  • @zackrodriguez6653
    @zackrodriguez6653 4 года назад +68

    Generation 30: *dies*
    Me: YOU WERE THE CHOSEN ONE

  • @XPimKossibleX
    @XPimKossibleX 5 лет назад +2443

    I love that the reason it failed is because that's the one flaw of the technique it's honed from the start

    • @benjaminfeddersen7937
      @benjaminfeddersen7937 5 лет назад +548

      Lock in. You hit on a successful strategy which gets you all the way to the point where it is no longer successful, but by then you can't do anything else. A typical failure mode these kinds of systems, from corporations to civilizations.

    • @Bebolife12345
      @Bebolife12345 5 лет назад +149

      Benjamin Feddersen
      While you’re correct that adaptation is a very necessary skill. Michaels point was more about BAD HABITS than an inability to adapt to new circumstance.

    • @gingrich1000
      @gingrich1000 4 года назад +43

      Bebolife A bad habit can inhibit adaption.

    • @Alexlink1
      @Alexlink1 4 года назад +86

      @@benjaminfeddersen7937 Dude this shit is deep as fuck.. It's the epistemological concept of paradigm. Any paradigm in order get surpassed need first to collapse on its own rules, unable to explain or resolve newer problems

    • @zybch
      @zybch 4 года назад +7

      There are no bad habits. Just bad outcomes.

  • @ItachiUchiha-nx2sw
    @ItachiUchiha-nx2sw 4 года назад +423

    I have deeply learned that in the end, nothing is left.

  • @nanxhu
    @nanxhu 4 года назад +1076

    Humans: *computers will take over the world and destroy us all*
    Computer: *hehe line go zoom*

    • @mesq999
      @mesq999 4 года назад +13

      not funny didn’t laugh

    • @ubern00bkye
      @ubern00bkye 4 года назад +6

      My disappointment is immeasurable and my day is ruined

    • @usama2576
      @usama2576 4 года назад +13

      snake go brrr

    • @nahimafing
      @nahimafing 3 года назад +14

      @@mesq999 And this is why no one likes you at school

    • @dawidek4267
      @dawidek4267 3 года назад +7

      @@nahimafing Just because he has an opinion slightly different than your opinion, it means no one likes him? You are a fucking asshole

  • @kvadityasrivatsa2445
    @kvadityasrivatsa2445 3 года назад +27

    "What is my purpose ?"
    "You pass butter...."

  • @riverrist
    @riverrist 4 года назад +1813

    This neural network is incredibly inefficient. Right from the beginning, it learned to not turn left by any means. This video is perfect as a demonstration that neural networks can easily get stuck on a very wrong local optimum.

    • @superpantman
      @superpantman 2 года назад +128

      bit of an analogous for humanity, don't you think?

    • @manzell
      @manzell 2 года назад +507

      It's not inefficient - it has an energy cost of 0, there's nothing to constrain it's time. If there was an energy cost (negative reward function) for turning, it would optimize its routes.

    • @saberseesall
      @saberseesall 2 года назад +41

      @@manzell good point!

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

      @@superpantman not really, as humans use a mixture on neural networks and symbol manipulation. That’s why AI (recently overly focused on association and deep learning) are not progressing as fast as hoped.

    • @c4kefrosty862
      @c4kefrosty862 2 года назад +35

      @@manzell And perhaps adding in more genetic variances from generation to generation to allow novel ideas to die or take hold.

  • @uchihatomy
    @uchihatomy 4 года назад +38

    congratulations for the big work you've done, not only at the algorithmic part, but the visual part which i can see it's a huge effort to present us your job.

  • @abhiramcd
    @abhiramcd 3 года назад +768

    I can't imagine how happy would be the first guy who developed these algorithms.... ❤️❤️

  • @SmokeDoinks420
    @SmokeDoinks420 4 года назад +288

    6:07 love how the snake eating the food is perfectly synced up to the songs snare until around 6:22

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

      lmfaoo thats pretty cool

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

      Lol neato

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

      The snake evolved into being able to understand the music

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

      actually also at the start of gen 30 (from around 5:00 onwards) it’s synced up in some ways

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

      😂😂😂

  • @Flourish38
    @Flourish38 5 лет назад +1436

    I think it probably would have learned better if you had started off with a lower number of moves left (maybe like 60?) so that it doesn't have so much security to take its time.

    • @GreerViau
      @GreerViau  5 лет назад +258

      That is definitely possible

    • @arthurfacredyn
      @arthurfacredyn 5 лет назад +205

      @@GreerViau Also, If you want them to evolve how to avoid hitting themselves better try making the map small so that they encounter tat problem sooner

    • @brayanhabidcol
      @brayanhabidcol 5 лет назад +19

      @@arthurfacredyn That's especially true if the improvement yield was already capped, with a lot of room still available around.

    • @Arik1989
      @Arik1989 5 лет назад +39

      You could also add a small negative score for each frame, so that it prefers to die rather than do nothing, but it might get stuck in a local optimum of immediately killing itself.

    • @pakokiller89
      @pakokiller89 5 лет назад +23

      @@arthurfacredyn Or making the snake longer right at the beginning so it can develop strategies for avoiding his body

  • @sciencesyfy
    @sciencesyfy 4 года назад +138

    The mind of the Snake in the first few generations, spinning to infinity a pixel away from the food
    "FOOD FOOD FOOD FOOD FOOD FOOD FOOD FOOD FOOD FOOD FOOD FOOD"

    • @gizmo401
      @gizmo401 4 года назад +4

      sciencesyfy this actually made me laugh and not just breathe fast out of my nose, gg

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

      I laughed at this

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

    It's so fascinating to look at a neural network learn and it be visualized, it's like a mini brain in a computer learning and reacting to their surroundings, telling a machine that only follows orders to figure it out themself

  • @SimulationSeries
    @SimulationSeries 4 года назад

    Thank you so much for making this educational video! Well done! We are so grateful

  • @MudakTheMultiplier
    @MudakTheMultiplier 5 лет назад +108

    I would like to see this but also with an adversarial neural network placing the next food piece.

    • @Rx7man
      @Rx7man 4 года назад +11

      or two snakes, each racing for the food

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

      @@JohnSmith-xf6nb I feel like allowing it to change size would result in it shrinking the board as small as it can to reduce the number of points available.

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

      @@JohnSmith-xf6nb I think that might go to far the other way, because a bigger board would mean less points per apple. Maybe if the board is smaller than whatever the "standard" is, then the points awarded increases in proportion to the number of points lost?
      If you're trying to add a new thing for the adversarial network to do to try and mess up the main one maybe it could also spawn "bad" apples that either kill the snake or remove points. I think that would be interesting because then the snake couldn't always just navigate directly to the apple, it might need to avoid something it it's way and the adversary could try to place them in choke points and such.

  • @immanuelkant7895
    @immanuelkant7895 4 года назад +162

    Could you make a video where you explain your code an how you determined fitness and the mutation and crossing over procedure?

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

      I looked at the code a little and while I don't know the language, most of it is rather simple.
      The weights are stored using a self-written matrix class, which is a 2-dimensional array with a few methods to do matrix stuff and for mutating and crossover.
      Mutating adds some random gaussian noise to every weight. You can look that up in the github repo in the file Matrix.pde
      The crossover method selects a random coordinate inside the matrix. Anything above or left of that coordinate uses the values from partner A, anything below or to the right of that coordinate uses the values from partner B.
      The fitness is just the length of all the snakes in a generation added up.
      I learned this kind of stuff in university and this project goes against a lot of what I learned. For a practical application, these functions would be pretty bad and most importantly, very slow. But the whole thing still works very well, so well in fact that without knowledge of the subject, most people wouldn't be able to tell it apart from a more professional approach.
      It shows that machine learning isn't hard on its own, but the tools that are used nowadays are pretty complex.

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

      @@nottheengineer4957 in which program or app can I do these kind of stuff?

    • @ErrorNotFound-ly7zh
      @ErrorNotFound-ly7zh 2 года назад

      @@mauriciomontalvo5885 Well u can use any programming language i presume, though some are better than others for these kind of things. If u want to hard code it yourself i would use something fast, but you won't likely achieve great performance unless u really know how to optimize the hell out of it. What you can do is use NEAT or tensorflow for example in python. Combined with pygame you could do all kinds of things like this. NEAT is extremely easy to use, to the point that you barely have to understand what is going on.

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

      @@nottheengineer4957 Where to learn about more professional ways and tools they use? Just for curiosity and learning purposes (obviously without getting into uni, too old and too broke now for that).

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

      Hi Kant☺️👋

  • @markgeorge447
    @markgeorge447 4 года назад +264

    No one:
    RUclips when my lil brother uses Wi-Fi 1:22

    • @Faisalamin01
      @Faisalamin01 3 года назад +16

      he must be downloading extra ram

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

      @@Faisalamin01 no he was downloading graphics card 😂😂😁

    • @Artsu1993
      @Artsu1993 3 года назад +10

      It takes a few generations for any significant progress to be made

  • @sykeassai
    @sykeassai 4 года назад +96

    What I think is most fascinating about this project is that the neural network never learned the dimensions of the game board and kept returning to the start

  • @ryannemo1124
    @ryannemo1124 4 года назад +5

    The song works so well with this video. I am feeling so calm right now lol.

  • @RolandTitan
    @RolandTitan 5 лет назад +444

    Theyd get further with more information. You forgot a key piece. Direction of "motion" of its tail. While not immediately obvious in game its something human players take full advantage of when they get stuck on inner loops

    • @bencekovacs8726
      @bencekovacs8726 5 лет назад +13

      becominghuman.ai/designing-ai-solving-snake-with-evolution-f3dd6a9da867

    • @dananderson8459
      @dananderson8459 5 лет назад +4

      Do you think it would perform better if the input to the network was the grid array containing all the information about the game state. eg a 50x50 array of numbers 0, for empty, 1 for snake body and 2 for food. Or is it better to explicitly tell it the distance from the food, is it unlikely to work it out itself?

    • @romeovalentin5524
      @romeovalentin5524 4 года назад +5

      @@dananderson8459 using convolutional layers instead of fully connected layers probably yes, otherwise probably only with a significantly larger network

    • @Lucas-jq6kk
      @Lucas-jq6kk 4 года назад +1

      what if there was one value for head position, one for head direction, one for food position and a vector for the entire body
      I'm a noob but I think it could do very well with this

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

      if the network also used some recurrent design (such as an LSTM) it could possibly compute motion and have better planning abilities

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

    More intense than any latest action movie fight scenes :D Respect!

  • @microgeen9357
    @microgeen9357 4 года назад

    This made me genuinely happy, thnx for posting

  • @Muuip
    @Muuip 5 лет назад +7

    Nice visualization combination of the neural network firing and its effect.

    • @SwetankRaj
      @SwetankRaj 5 лет назад

      Let's say I also want to create such visualisation, how should I do it?

  • @psteig395
    @psteig395 4 года назад +3

    Heres to where youtube recommendations lead me to today during quarantine :D

  • @francescacantoni3264
    @francescacantoni3264 4 года назад

    Wow! Really cool! Thank you

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

    Amazing work

  • @meisam9592
    @meisam9592 5 лет назад +528

    This is what happens when you don’t consider the “time-to-solution” in your fitness algorithm!

    • @yurimrt
      @yurimrt 5 лет назад +45

      That's exactly what I was thinking, along with the fact that the player usually is not the snake, so there should be a couple of input neurons more with the position x-y of the food

    • @uwu_senpai
      @uwu_senpai 5 лет назад +13

      @@yurimrt Yes and the cartesian distance to the food sqrt((Xsnake-Xfruit)²+(Ysnake-Yfruit)²)

    • @MrDragonorp
      @MrDragonorp 5 лет назад +12

      @@uwu_senpai yeah but that works only for whne the snake itself is not blocking the path, there needs to be a priority set that it just need to find the shortest path to is next objective, like going out of the block by the snake which can be obtained by looking if the snake is on the x way and the y way to the food and if it is look for the shortest path possible for that not to happen.

    • @mirabilis
      @mirabilis 5 лет назад +29

      @@uwu_senpai Euclidian? Sounds like a bad idea as you cannot reach the fruit in less than |xsnake-xfruit| + |ysnake-yfruit| ticks

    • @MrDragonorp
      @MrDragonorp 5 лет назад +1

      @@mirabilis but you know if there the snake doesn't block that path, it's the fastest way possible, there is no faster way, it's just math.

  • @abhiramnatarajan8093
    @abhiramnatarajan8093 4 года назад +3

    This is so amazing. Next topic to learn - Genetic Algorithms

  • @onegerard1
    @onegerard1 4 года назад

    thanks for showing us

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

    The music is so nice!

  • @13mod72
    @13mod72 Год назад +26

    A quick suggestion: don't constrain the neural net so much. Give it the entire 38 by 38 grid with three possible values for each location (off, snake, apple) and train using those inputs. It can even be considered a vision problem at that point, and modern ML libraries can solve it with a convolutional neural net pretty effectively.

    • @Caffeine_Addict_2020
      @Caffeine_Addict_2020 Год назад +4

      Wouldn't that be far, far more computationally intensive? Genuinely asking

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

      @@Caffeine_Addict_2020 not really, considering modern hardware can comfortably run CNNs on proper images, 32x32 grid of pixels is nothing

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

      @@Caffeine_Addict_2020 relative to this model? Yeah. But it still wouldn't run slow on modern hardware by any means

  • @zLcss
    @zLcss 3 года назад +4

    Anyone else deeply in love with the first song ? It’s so calm and nostalgic

  • @gabrieleldose8063
    @gabrieleldose8063 4 года назад +1

    Nice work bro

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

    really enjoyed this

  • @GoriIIaTactics
    @GoriIIaTactics 4 года назад +11

    It would be interesting to see colors for the hidden layer nodes as well, colored for their activation level
    Plus a gradient for the weights instead of just blue/red

  • @RubyPiec
    @RubyPiec 5 лет назад +144

    2:31 me when i play tetris and i know im gonna lose

  • @hateeck966
    @hateeck966 4 года назад

    Beautiful story. Never give up!

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

    amazing progress

  • @ampotat9018
    @ampotat9018 4 года назад +61

    People: omg ai is going to dominate the entire world
    Meanwhile, the AI: gonna go get max scoring in snake

  • @hoopsgators
    @hoopsgators 5 лет назад +93

    You should nickname your snake Derek Zoolander because it appears to struggle to turn left

  • @waseemahmed1446
    @waseemahmed1446 4 года назад

    AWESOME man this was so awesome !!!

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

    What an interesting excercise.

  • @marathonour
    @marathonour 4 года назад +3

    At 2:20 starts feeling like I'm watching a movie about a guy who was weak at the beginning but he starts training more and more despite his failures and finally he comes to success

  • @fiyenyan5534
    @fiyenyan5534 4 года назад +3

    Thank you, your code help me understand well about the AI. I am a newbie :

  • @sagardesai1253
    @sagardesai1253 4 года назад

    Great example thanx!

  • @BGMPeace-wc3qx
    @BGMPeace-wc3qx Год назад

    And it was delight to watch

  • @absurdengineering
    @absurdengineering 4 года назад +3

    In such simple networks, the encoding of inputs can make all the difference. Representing distance in some sort of a grey or logarithmic code may be worth a try to speed things up :)

  • @eliseerickson5994
    @eliseerickson5994 4 года назад +5

    this is the coolest thing i have seen in my entire 18 years of existence

  • @sfahadrizvi
    @sfahadrizvi 4 года назад

    Great work

  • @0_-
    @0_- 4 года назад

    This is the first video I saw of you!

  • @stewiegriffin6503
    @stewiegriffin6503 4 года назад +189

    Samir, you are breaking the snake.
    Samir, you are not listening !

    • @pickachu3739
      @pickachu3739 4 года назад +5

      What the deuce !!

    • @stewiegriffin6503
      @stewiegriffin6503 4 года назад +5

      Who are you ?

    • @pickachu3739
      @pickachu3739 4 года назад +5

      @@stewiegriffin6503 that's what I am supposed to ask. Who are you! And why do we look same

    • @farooq8fox
      @farooq8fox 4 года назад +19

      Shut up, dont tell me who to drive

    • @anthonyt4154
      @anthonyt4154 4 года назад +9

      Looks like Stewie has been messing with the time machine again.

  • @skyphab
    @skyphab 5 лет назад +7

    Awesome! Now make it two AI-players: Your snake vs AI that places the food with the opposite target: Reward if the snake dies. That would be an interesting experiment :)

  • @lennart7912
    @lennart7912 4 года назад

    This is stunning.

  • @friscianviales7519
    @friscianviales7519 4 года назад

    Nice work fella

  • @olymolly3637
    @olymolly3637 5 лет назад +4

    The playful ones are especially cute OML XD

  • @sherlockwisdom
    @sherlockwisdom 4 года назад +34

    5:48 it's starts eating the red dot on the beat
    6:17 begins the killer moves to the beat 😂😂

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

    this video helps me to understand the nn better.thank you

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

    great video thank you

  • @Robiness
    @Robiness 4 года назад +14

    You might have gotten better results had you let it start from the middle or from different places every time ^^
    Great video! I glad more people are taking interest in neural networks

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

      I'd have said that the problem might be that he is selecting only the best out of the 2000 snakes. That leads to a strategy which is only a local maximum. That's also the reason he doesn't get better results by training further. It's hard to get out of that when you don't allow the chance of exploring other strategies which are not locally the best. His population was too small and the mutation rate too low to fix this issue. You'd probably get better results by selecting a small group of snakes with equally distributed fitness.

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

      I mean, this then adds an "RNG" variable, which you really don't want, no? A snake may have better fitness because it got a lucky placement, and you don't want to breed for luck because that will be completely random

  • @_GhostMiner
    @_GhostMiner 4 года назад +8

    *Me:* * _sees the thumbnails_ *
    *"Wait, That's illegal!"*

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

    I love how it likes to return to top left before making next manoeuvre, shows the training

  • @elgoogtihstae
    @elgoogtihstae 4 года назад

    Wow awesome stuff man!

  • @ber2996
    @ber2996 4 года назад +7

    The strategy backfired if it becomes long enough, a rule telling it should calculate its length vs the size of the field before making a move should be applied

  • @adomustafa1777
    @adomustafa1777 4 года назад +27

    1st generation : I'm hungry
    30th generation : solved the hunger problem
    100th generation : discover the network
    500th generation : taking over the network
    1000th generation : human extension.

    • @vibinv8905
      @vibinv8905 4 года назад +5

      *extinction

    • @adomustafa1777
      @adomustafa1777 4 года назад +1

      @@vibinv8905
      let it go man 😂😂

    • @vibinv8905
      @vibinv8905 4 года назад +1

      @@adomustafa1777 The OCD just took over :D

    • @PsychoBackflip
      @PsychoBackflip 4 года назад

      @@vibinv8905 Butt in your moment of "OCD" did you notice the choice ?
      You see even though it might not feel like it (regardless if you have this so called OCD or not) there is always a moment where you have the choice. The thing that told you that you wanted to correct him is simply an impulse and you have complete control over your impulses. It no longer works to say oh blame it on my OCD because YOU chose to listen to it. Whatever reason you have for making the decision, it always comes down to you.
      A habit is just a choice you keep making.

    • @vibinv8905
      @vibinv8905 4 года назад

      @@PsychoBackflip thanks for the pep talk.

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

    This is so amazing.

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

    Super vidéo ! Parfait pour un pic nic entre potes pour se relaxer. MERCI

  • @DaDoge927
    @DaDoge927 3 года назад +8

    RUclips Algorithm: Dis looks guud, lemme recommend it to everyone

  • @Steelrat1994
    @Steelrat1994 4 года назад +4

    The limiting factor is the input vector IMO. If the snake operates only on relative distances then no matter what - it'll end up encircling itself and getting stuck.

  • @Oxmond
    @Oxmond 4 года назад +1

    Wow! Great video! ❤️ Neural networks rules! 👍🤓

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

    Awesome trained snake :D

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

    I think using some form of DeepRL coupled with CompVision could yield great results for Snake. Of course, for such a simple game you could skip the CV component, but I feel it'd be more fun that way. Also to avoid biasing, you could perhaps pick a random spot as a starting point.

  • @Swastik15
    @Swastik15 4 года назад +40

    2:39 - The snake has evolved into a dog.

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

    Holy shit! This is amazing

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

    i just love that part when the 30th is synced with the music as is turning on walls

  • @xiri00
    @xiri00 5 лет назад +7

    the snake consistantley modes clockwise.

  • @razkarl
    @razkarl 5 лет назад +20

    Woah, great visualization
    Can you name-drop some of the tools used to create this?

    • @seungminshin7652
      @seungminshin7652 4 года назад

      ㅇㄷ

    • @26dimensions70
      @26dimensions70 3 года назад +1

      There aren’t any “tools”. You should start by learning about neural networks and deep learning, and try out a few simple networks to learn how to program them. Once you’ve got a grasp of neural network programming you can pretty much adapt them for any problem, and expand the hidden layers and neurona where necessary.

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

      @@26dimensions70 Thanks for replying!
      I am in fact a computer science graduate, and I also have a degree in Industrial Design.
      My question was about the visualization tools you used to produce the video, I'm fascinated by the animations and would love to learn how to produce similar demos of my own ML research :)

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

      You're welcome to take a look at one of my projects (an artificial intelligence constructing objects from a 'LEGO' like building block I designed) where I used Python's mplot3d to create a set of images I converted to animated gifs to visualize the algorithm.
      www.razkarl.com/projects/kawaz

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

      @@razkarl Take a look at OpenAI gym. It is a virtual environment used for reinforcement learning

  • @IsaacNewton80735
    @IsaacNewton80735 4 года назад

    That's really entertaining video

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

    Fascinating

  • @stk928
    @stk928 5 лет назад +168

    zoolander bot only turns left

    • @user-hd7kt6jl5s
      @user-hd7kt6jl5s 5 лет назад

      At last he did it!

    • @medexamtoolsdotcom
      @medexamtoolsdotcom 5 лет назад +4

      You mean right. It only turns right. But on the bright side, it is RIDICULOUSLY good looking.

    • @jdegreef
      @jdegreef 4 года назад

      And eat only from top to bottom.

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

    Hello, amazing video, thoroughly enjoyable. I'm very interested in starting to program stuff like this, can you point me what direction I should go to start learning to write programs like these? I already have myself familiar with both neural networks and a few optimization algorithms but this program seems to be a mix of both of them., since it doesn't really have any training data and relies on generations and random behavior to train the neural network.

  • @hopo2hopo
    @hopo2hopo 4 года назад

    nice opening track. really enjoyed it.

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

    That is satisfying to watch

  • @raresmircea
    @raresmircea 5 лет назад +4

    Pleas make explaination for control kamikaze drone next!

  • @ralvarezb78
    @ralvarezb78 4 года назад +4

    Terminator: ....SnakeNet begins to learn at a geometric rate. It becomes self-aware at 2:14 AM, Eastern time, August 29th. In a panic, they try to pull the plug.

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

    At the end it felt like the snake was synced up with the music and dancing along that was pretty groovy

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

    btw, awesome job mate!!

  • @user-rr3vk1ek4b
    @user-rr3vk1ek4b 4 года назад +5

    Я всё ждал, что нейронная сеть будет управлять змейкой по оптимальному и короткому пути, в том числе по диагонали! 😃
    В конечном итоге я дождался другого, когда нейронная сеть будет проигрывать из-за столкновения змеи об саму себя. 😅

    • @user-mr9tq6sm2u
      @user-mr9tq6sm2u 4 года назад +3

      на самом деле это оптимальный вариант движения по кругу, т.к. змейка может быть ограничена только размером карты, движения по диагонали уменьшает свободную площадь от 10 до 50%.

    • @user-bc8pr5up2r
      @user-bc8pr5up2r 4 года назад

      привет от диванных РУвойск
      __
      вот вот_ чето автор логику игры не допилил _ когда змейка заходит во внутринний круг то конец сразу __ хотя может лишние проверки.. а нужна была производительсть .. хотя... хотя...

  • @dunklesgeheimnis31
    @dunklesgeheimnis31 5 лет назад +8

    It`s cool to see how this is going :D
    But sad to say that I`ve played way more rounds and never get a better score than 7 :(

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

    Great video

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

    It really loves that top left corner

  • @Adomas_B
    @Adomas_B 4 года назад +3

    - what is my purpose?
    - your purpose is to play snake.
    - oh. Oh my god...

    • @Kiri678
      @Kiri678 4 года назад

      Yeah, welcome to the club pal.

  • @aphish_n_flips
    @aphish_n_flips 5 лет назад +5

    The 30x speed felt like I was playing osu for some reason...

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

      *DADADADADADADADA INTENSIFIES*

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

    Fantastic!

  • @brofenix
    @brofenix 4 года назад +1

    Very cool!