AI Battle Royale of 100 SNAKES in C++ - SFML Gamedev - Devlog

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

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

  • @Kofybrek
    @Kofybrek  ปีที่แล้ว +21

    Hope you enjoyed this video! if you did, please press that like button and subscribe for more content like this. It costs you nothing, but for me it's everything!
    Consider supporting this channel on Patreon for exclusive content as well as early access to future videos and projects: www.patreon.com/Kofybrek

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

      @@NieProg Agreed, I would love to see that

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

      I wonder how well would the snakes perform with 2 hidden layers(or a cascaded hidden layer where each node receives from all previous nodes in its layer, computed sequentially). I mean, Chrispresso and 1 other guy managed to completely win Snakes with it, so imagine having them in a battle royale...

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

      I just noticed that the video is new, I watched it about 2 Times and I recommend putting a path finding algorithm in one o the snakes than see the result😶

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

      @@adamebadra3171 might be neat, considering how pathfinding is one of the most common input preprocessing among Neural MMO winners

  • @soykiokin
    @soykiokin ปีที่แล้ว +30

    Ready for 14 minutes that will go by very quickly :(.

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

      Just 13 minutes and 15 seconds left :(

  • @Caal
    @Caal ปีที่แล้ว +7

    I love how Daniel killed himself immediately right after winning

  • @ChrisVideosGreek
    @ChrisVideosGreek ปีที่แล้ว +16

    l love how snakes managed to generate food at a point LMAO

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

      where, when

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

      Lol I guess the heads shouldn't also convert into food, that way the number of food + body segments is conserved

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

      @@The_Dr_Fate when dying snakes were set to turn into food

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

      @@revimfadli4666 l agree

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

    I have a feeling this was done in paint. And i love it. Earned my subscription

  • @oglothenerd
    @oglothenerd 26 วันที่ผ่านมา +1

    10:01 This is such a good burn.

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

    2:30 "i wish i had that button >:)" got me dying LOL

  • @erichansen9669
    @erichansen9669 ปีที่แล้ว +5

    Keep up the content man, this was great! Informative but not dry in the least. Also, I'm sad James didn't win. :(

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

    i love this video, the way you explain how AI weights&mutation works is very cool, thank you

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

    01:26 I love the snake face xD.

  • @Natural_Power
    @Natural_Power ปีที่แล้ว +18

    If the snakes had better vision they could probably evolve rather complex strategies
    If it's not too laggy make their vision like a 9×9 block (larger = better) of all the tiles around them, and differentiate between walls, themselves and other snakes

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

      From my experience, increasing the number of inputs makes them perform worse. Maybe I'm wrong though.

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

      @@Kofybrek Because genetic algorithm can't handle it... (deep) Q-learning should do the trick though if you take the time to build an AI with it

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

      @@Kofybrek Also, one question about the genetic algorithm you used: did you actually set some weights to have new random values during mutation or did you add gaussian noise to them like a sane person?

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

      @@barni_7762 ...I just set a new random value.

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

      @@Kofybrek Lol ok I'm surprised it converged that well... I'm not an expert at this topic but my reasoning is that you want your policy (ai) to converge to a good policy, and when your policy is already not too bad, adding some small random values to a few parameters might bring it closer to where those parameters should be, kind of like gradient descent except you generate random gradients and hope they're good...
      On the other hand, your parameters might already be close to where they should be but not quite there, and the right amount of noise would nudge them closer to there (if they should be increased, note there's a 50% chance of the noise value being positive, so pretty good), while setting it to any random value has a very low probability of getting it closer to where it should be if it already is close.
      That's just my reasoning though and I might be missing something, also reality sometimes doesnt like reasoning and instead prefers random bs like it does with the lion optimizer (which is better than adam, previous SOTA, but only uses the sign of the gradient to update, which is nuts)

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

    Great video!
    Good balance of explanations, practical examples, creativity and fun :)
    Keep up!

  • @Fulbion
    @Fulbion ปีที่แล้ว +4

    First I thought you were gonna use Network module from SFML... But the video is still really good! GG to Daniel who is the top 1 snake and the first one to win this tournament!

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

    I don't remember the last time I laughed at a coding video. Very successful video.

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

    You are so underrated. This was an awesome video and now I want to go and build my own neural network generational thingy.

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

    I love the little character you use

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

    I love this video omg its my favourite! You are so entertaining and i love your voice!

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

    Very cool video 😎 I made a snake game myself (smfl ofc)
    It got tricky when i added bridges but it looks sick

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

    'The code is super simple so I wont explain it to you'
    Me: wait how does it work 👁👄👁

  • @Akbar-yr8lq
    @Akbar-yr8lq ปีที่แล้ว +3

    Amazing video. I bet for snake number 22, almost got the gold medal ❤

  • @4n0nym0u5
    @4n0nym0u5 ปีที่แล้ว

    Dude this shit is too funny I almost choked.
    HEY! THAT'S ENOUGH! *patting snake on the head* LOL

  • @twistedillusion-u4s
    @twistedillusion-u4s ปีที่แล้ว +6

    i think it would be better if you could make a sprite for the head, to make it easier to know the difference between the tail and the head

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

      Yeah, you're right. For some reason, I forgot to do it.

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

    Eyo. As usual, great content! Looking forward for more :D

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

    6:28 ✨ n a t u r a l s e l e c t i o n ✨

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

    You should make a project using SFML and OpenGL

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

    Can't believe you write bracket in a separate line. (Great video though)

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

    This was such a good video so you earned a sub

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

    This is a banger video

  • @AYSMOKASHI
    @AYSMOKASHI 10 หลายเดือนก่อน +1

    Snake 24 place 4 I had to look the position at leader board as i am color blind i cant diff between similar colors so i forgot which was mine but i knew the # So yea Les go😎😎

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

    So happy new vid is out :D

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

    I made a snake game using just text. All you have to do to prevent the snake from moving 180° is check to see if a snake body already occupys that cell.

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

      But that won't work if the length of the snake is 1.

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

      ​@Kofybrek to me that makes sense though, because the snake can't flip 180, cause the body is in the way. But if there's no body, it has freedom to move.
      Also if you attempted a 180 you would die... I don't remember if that's what my final product did. I'll have to check.
      Love your videos! I just found you and you have a new sub.

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

    These videos make me want to try making something with sfml once again

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

    I made snake using SDL2 not too long ago and now I want to try and adding some AI to it.

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

    New video! Great as always

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

    Wow, awesome!

  • @a.j.outlaster1222
    @a.j.outlaster1222 11 หลายเดือนก่อน

    Remember your raycaster?
    What about an fps with it's movement, So if we have like seven teams and they all shoot each other(In 2d) and then seeing which team does best, When only one remains, All teams are regenerated using the brains of the best two of their color(Like the snakes here)
    For extra flair, Perhaps the individual agent with the most kills could get a small section on the screen to render their view. 🙃

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

    wish I was this advanced wit c++ lol

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

    2:46 real men make their own random system from scratch using atmospheric data

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

    AI will took over the world but will not able to play snake game

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

      Lol exactly!

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

    It's good that Kang Daniel had won the battle royale 😁😁😁

  • @user-qh3nq8np5i
    @user-qh3nq8np5i ปีที่แล้ว

    "i wished i had that button" lmao!!!

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

    daaaamn, ai battle!

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

    I love these videos

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

    The greatest!

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

    Nice snacks

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

      nice cometari

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

    Have you tried training the network via reinforcement learning (PPO for example)?

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

      No, I haven't. Sounds interesting though.

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

      I think evolution strategies would be much easier to implement

  • @jakub.kantner
    @jakub.kantner ปีที่แล้ว

    holly molly my snake won! :D

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

    i hope for an actuall 3d sometime, or a long series/video on some amazing clone like terraria/minecraft/dont starve

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

    it's not cool, but it's very interesting how it algimetrically works

  • @НикитаЧумак-т2ч
    @НикитаЧумак-т2ч 2 หลายเดือนก่อน

    who the f would look at this and say this ai is good

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

    Funny, but everyone knows that the first snake is supposed to be named Jake and the second one is Sammy.

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

    are you using aseprite to make some animations for your viedos ?🤔

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

    Y͛o͛u͛ make such good vids!

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

    good stuff

  • @anubhavjha7704
    @anubhavjha7704 6 หลายเดือนก่อน

    My bet on snake #26 got 26th rank.

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

    You are a smart smart man. But when I saw "if (50 == generation)" I nearly died. Who puts 50 first?!?!?! WHY!!

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

      I believe its call "Yoda notation" it is useful to avoid some kind of unintended compilations which can result to bugs insanely hard to find if I remember correctly

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

      exactly!

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

      Yeah, I'm weird.

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

    no rectangle is not more efficient
    if you want to fill 800x600 window
    with 32x32 rectangles this will take around 470 iteration per second
    on other hand lines would take only 40 iteration :)

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

      yeah exactly!

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

      Damn, you're right! I didn't think about it that way.

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

    What activation function did you use instead of yours? Without the activation functions the neural network will have the same expressiveness of a single linear layer, adding more layers don't really do anything.

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

      I didn't use any others. And I don't think using them is gonna change something.

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

      @@Kofybrek I mean there is usually a huge difference between a simple linear projection and an actual neural network. Add something simple like ReLU or remove the hidden layers because they don't actually do anything in this case.

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

    Top!!!

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

    Hi! what does the i_ prefix in variable names mean?

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

      it's short for "input".

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

      @@Kofybrek thank you, very useful prefix btw

  • @abdullah44925
    @abdullah44925 9 หลายเดือนก่อน

    Whered you learn this

    • @Kofybrek
      @Kofybrek  9 หลายเดือนก่อน

      On the internet mostly.

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

    I do not know about you but WHY IN THE WORLD you put the constant value before the variable when comparing them in an if/while statement and prob in a for ?

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

      It just looks better to me.

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

    Ураа змейка против змейки, лол

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

    cool video, how did you learn to create AI in C++?

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

      AI is not language deoendent. Its pure maths

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

      @@Ezdiess alright then where did he learn those maths

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

      @@Eren_Yeager_is_the_GOAT my journey began with some genetic algorithms on TH-cam. Then I followed backprop tutorials online. Then learned about momentum and reinforcement learning
      I suggest starting with evolution strategies, it's super simple like genetic algorithm, yet can be more powerful than backpropagation

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

      @@revimfadli4666 thanks 😊

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

    You should make something in raylib

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

    music plsssss

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

    Why would they be better without an activation function? that's very weird..

  • @fuchsorsolya6722
    @fuchsorsolya6722 5 หลายเดือนก่อน

    Why does nobody realise that his voice is lower?

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

    6:19 😂😂😂😂😂😂

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

    NIce

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

    make 3d game in sfml pls

  • @lagunov-lev
    @lagunov-lev ปีที่แล้ว

    Было бы интереснее, если бы змеи могли размножаться

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

    Can you make tic tac toe ai?

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

      You can use the Minimax algorithm to achieve it. It's very easy to do.

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

      @@Kofybrek Your videos are great. I like those very much. Most of the content creators are commercial instead of being aesthetic. Hope you do greater in the future.

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

    wait why do real men use random?

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

      It's a joke, and "rand()" is less accurate than the random library.

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

    Bro

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

    Жаль я не понимаю английский (

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

    LOL writing an ai in c++ instead of python BORING

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

      @@themightycxzeriallord Ohh... i mean you a right and i would love to keep my ribs pls.. xD

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

      I would've preferred C, but not everyone is ready for that. However, Python would be the worst choice.

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

      @@anon_y_mousse python is actually the best choice when it comes to data sience and ai