The UNKILLABLE Snake AI (Entire 30x30 game)

  Рет қаралды 75,759

AlphaPhoenix

AlphaPhoenix

4 жыл бұрын

If you're anything like me, you'll love zoning out watching a computer play a very basic computer game for hours on end. Here's a half-hour game - the median from my best algorithm - played back at 30 fps.
CODE!
github.com/BrianHaidet/AlphaP...
Here's my original Snake AI video that explains how it all works:
• How to Win Snake: The ...
Check out the other social media for updates and ramblings:
/ alphaphoenixchannel
/ alpha__phoenix
#Snake #AI #Math
Music in this video:
I Dunno by grapes is licensed under a Creative Commons Attribution license (creativecommons.org/licenses/...)
ccmixter.org/files/grapes/16626
Operatic 3 by Vibe Mountain is licensed under a Creative Commons license
Mountain by Text Me Records / Bobby Renz is licensed under a Creative Commons license
Deserts by Text Me Records / Bobby Renz is licensed under a Creative Commons license
Stay with You by Silent Partner Acid Jazz by Kevin MacLeod is licensed under a Creative Commons license
Acid Jazz by Kevin MacLeod is licensed under a Creative Commons Attribution license (creativecommons.org/licenses/...)
Source: freemusicarchive.org/music/Ke...
Artist: incompetech.com/
Surfing Llama by Bird Creek is licensed under a Creative Commons license
BoogieBounce by Drew Banga is licensed under a Creative Commons license
Pink Lemonade by Silent Partner is licensed under a Creative Commons license
Way Out West by Chris Haugen is licensed under a Creative Commons license
Space Coast by Topher Mohr and Alex Elena is licensed under a Creative Commons license
Not the Only One by Rondo Brothers is licensed under a Creative Commons license
Move Ya by Max Surla/Media Right Productions is licensed under a Creative Commons license

Пікірлер: 162
@herzglass
@herzglass 2 жыл бұрын
Now I want a heatmap to see which nodes it ran over the most.
@smg22
@smg22 Жыл бұрын
Mee too
@masi416
@masi416 3 жыл бұрын
I'm not playing a game, I'm not playing a computer game, I'm not watching someone playing a game, I'm not watching someone playing a computer game, I'm actually watching a computer playing a computer game... This is a really relaxing muisc video.
@AlphaPhoenixChannel
@AlphaPhoenixChannel 3 жыл бұрын
Haha I found it pretty hypnotic
@AlphaPhoenixChannel
@AlphaPhoenixChannel 3 жыл бұрын
Wish there was a single half hour song I could have used
@nekomimicatears
@nekomimicatears 2 жыл бұрын
@Gurifu how so?
@PeterNjeim
@PeterNjeim Жыл бұрын
@@AlphaPhoenixChannel Symphonies can last hours
@softpaw6234
@softpaw6234 Жыл бұрын
You're actually watching a visual representation of the logic the computer uses to play said computer game
@clockwork_mind
@clockwork_mind 2 жыл бұрын
I really like AppleFearMode, because even though it sometimes makes silly-looking decisions, it's like it's playing strategically and planning for the future. The snake never makes a maze for itself in the process of grabbing several apples, it will always go out of its way to coil itself into a big block in order to keep most of the board clean for future maneuvers. It becomes obviously important even just a third into the game.
@relaxnation1773
@relaxnation1773 4 жыл бұрын
How do you not have more subscribers? This stuff is so entertaining!
@AlphaPhoenixChannel
@AlphaPhoenixChannel 4 жыл бұрын
Haha I wish I knew. I think my stuff isn’t shareable enough to hit that critical mass for “virality”. I’m glad you like it!
@MimicGriphon
@MimicGriphon 2 жыл бұрын
This has aged well...
@England91
@England91 2 жыл бұрын
@@AlphaPhoenixChannel I think looking in depth into AI is a niche thing that not many people go looking for or at
@shadoww7301
@shadoww7301 2 жыл бұрын
@@England91 *The entire fanbase of CodeBullet*
@jasoncrimmel
@jasoncrimmel 2 жыл бұрын
This is the most stressful thing I've ever watched.
@1ucasvb
@1ucasvb 4 жыл бұрын
Looking at the final behavior, it really looks like your two heuristics are pretty damn good, especially AppleFearMode. Nicely done!
@AlphaPhoenixChannel
@AlphaPhoenixChannel 4 жыл бұрын
I have seen some slightly frustrating behavior from applefearmode because if it’s heading along the Hamiltonian path towards the apple it won’t by itself veer away. There are improvements that could be made for VERY slight returns. But overall yeah I’m really happy with it! Thanks!
@ouzoloves
@ouzoloves 2 жыл бұрын
Love how you can see the steps per apple on the graph start fast, then slow down before accelerating hard at the end. good job
@SpencerTwiddy
@SpencerTwiddy 3 жыл бұрын
13:38 to 13:50 hurt to watch😂
@AlphaPhoenixChannel
@AlphaPhoenixChannel 3 жыл бұрын
Ugh yeah...
@oakinwol
@oakinwol 2 жыл бұрын
Lol, why? Part of controlling the outcome of the game is not just getting the apple but also controlling where it'll span next. It's spawn space control to prevent situations where you could ever get stuck because of where it spawns next. It's extremely good play
@VocalMabiMaple
@VocalMabiMaple 2 жыл бұрын
@@oakinwol good play sure. Still hurts to watch.
@matthewhubka6350
@matthewhubka6350 2 жыл бұрын
@@oakinwol if you pause at 13:42, you can imagine a slightly different Hamiltonian path that goes through the apple and then continues on the path it went on. It could then stick to the new Hamiltonian path, and it would be perfectly fine
@oakinwol
@oakinwol 2 жыл бұрын
@@matthewhubka6350 For sure I'd imagine there are several paths that could do it. I guess I think of it as moreso algorithmic, because I can imagine that if I was going to play snake and get to that level of progression I would have to adopt se behaviors that have nothing to do with where the apple is. Like I might adopt a mindset that I attempt to fill in existing gaps to minimize my bodys footprint on the map whenever it reaches a certain threshold. A human might do that to give the maximal chances of success in any given situation. And it would a very astute strategy to take, which is why I guess I don't see it as painful when I see a computer doing it. It makes sense to me even if it's not the fastest potential path in that specific situation
@piwi2005
@piwi2005 2 жыл бұрын
Very nice ! Brougth me back to old memories actually. The yellow path is so frustating... One really wonders if a two line heuristics, like for the Euler horse problem suddently does not solve things like a magic wand. On the one hand, you get that you'd prefer maximizing big empty spaces instead of geting stuck into weakly connected small spaces, but on the other hand you kind of see that defining such a measure of "parcelness" would involve some minimisation of the amount of fixed points in the set of possible Hamiltonian transformations, which seems again computationally hard. The snake eats its tail...
@BusterBeachside
@BusterBeachside Жыл бұрын
I would've called "AppleFear" mode "survival" mode lol. That's essentially what it's doing. In every other mode, it's prioritizing getting to the apple, but it enters AppleFear only when prioritizing the apple will get it killed. But it also seems to put itself into AppleFear/Survival Mode more often than it needs to as a result of prioritizing the apple. Mostly when it decides it wants to go in a straight line to get it when it has very little available space, meaning it ends up walling itself off and having to utilize its escape route. Although I think near the end, it doesn't really matter if it tries to play cleanly first or go for the apple first since there's so little space, it'll end up creating a "survival mode" situation no matter what. But mostly in the middle, I think it could be possible to save even more time if you could somehow get it to play a little more cleanly (Less going in straight lines when doing so inevitably cuts the available area in half, which could mean the snake can take a more direct path towards the next apple instead of zig-zagging around trying to not box itself in). I really have no idea, though! 😉 Just my observation
@Robert_McGarry_Poems
@Robert_McGarry_Poems 2 жыл бұрын
Now, to make an AI that can change the speed and tone of the music with the rising and falling action in the game. Great work!
@gallium-gonzollium
@gallium-gonzollium 2 жыл бұрын
3:00 Snake used box. It’s very effective.
@russt2793
@russt2793 3 жыл бұрын
Yo I got a question, is there any chance you could do make a snake winning ai with a 50×50 or a 100×100 for snake? Cause its honestly satisfying to watch the game be completed as your focused on the snake growing till it covers up the while board.
@liam3284
@liam3284 Жыл бұрын
the same strategy should scale to any square grid. 100x100 might take a rather long time though.
@sofia.eris.bauhaus
@sofia.eris.bauhaus 3 жыл бұрын
speaking of NP-hard problems: i wonder if a SAT-slover could find an optimal solution in in a bearable amount of time. they seem to be pretty clever beasts nowadays. i think it may help to think about it more turn-wise than real-time, from one apple to the next, i guess the biggest hurdle there would be to take the receding tail into account. anyway, great job! you got new a subscriber! (also i watched the video at 144 fps by speeding it up x4.8 😎)
@jacobdeal843
@jacobdeal843 3 жыл бұрын
Glad to see you are still making content after all this time :P
@Torthrodhel
@Torthrodhel 2 жыл бұрын
Now imagine this is a hedge maze and the goal's to get to the red dot. You're not as quick as the hedge making snake. And if it finishes, it closes in on its own tail and the red dot's gone forever.
@markmuir7338
@markmuir7338 2 жыл бұрын
I watched the whole video intently! It's like watching 3D printing - I can't get bored, but realize it's maybe not the best use of my time 😂
@furlockbones
@furlockbones 2 жыл бұрын
the ultimate chill/study video
@Zappygunshot
@Zappygunshot Жыл бұрын
A way I can see you'd be able to improve this algorithm is if the snake was aware of its own length at any given time, and could calculate the amount of moves it'd have to 'waste' before being able to take a direct path to the apple without depriving itself of an escape route. Another big one would be to calculate how big of a hole it'd trap itself into once it detects it's about to do so (essentially when the line turns yellow), and where the first opportunity for it to escape would present itself. That would allow it to take some 'risks' (that aren't actually risks) that it's currently too afraid to take because it can't look ahead far enough.
@NekuZX
@NekuZX 2 жыл бұрын
Everybody gangsta until the snake turns into a brain
@Kogacarlo
@Kogacarlo 2 жыл бұрын
The last 30 seconds are like detecting a gravity wave: Brrrrrrrp!
@voxelfusion9894
@voxelfusion9894 2 жыл бұрын
The fact that you wrote it for MATLAB is what's most impressive. I nearly died trying to implement breadth first search in matlab for a different project, and while it worked, matlab is definitely the most obtuse language I had the misfortune of using. Not to mention matlab being a paid and proprietary program, so barely anyone could use it. I prefer python for both programming and number crunching. It's much easier to work with, I'd give it a try!
@redrumtheartist6275
@redrumtheartist6275 Жыл бұрын
I don't care if this was years ago it's still so satisfying to watch
@whoeveriam0iam14222
@whoeveriam0iam14222 8 күн бұрын
7:17 weird moment when it got close to the apple and then turned away to go around
@technomatic6665
@technomatic6665 2 жыл бұрын
One pattern I noticed it use frequently was a space filling curve called “Hilberts Curve” and that was really cool to see!
@voxelfusion9894
@voxelfusion9894 2 жыл бұрын
Hilbert curves are those squiggly fractal patterns, but that isn't what it's using here. He's using what is called a Hamiltonian cycle (the dark green line) which is a continuous loop that covers all points in the grid once. The ai switches between following that cycle and going straight for the apple to optimize the game.
@mcsuperplayer
@mcsuperplayer 2 жыл бұрын
@@voxelfusion9894 yeah but at some Points a order 1 hilbert curve was used to fill tue area
@tlwalker1962
@tlwalker1962 2 жыл бұрын
Truly mesmerizing!
@ajreukgjdi94
@ajreukgjdi94 Жыл бұрын
After watching this, I kept thinking about the adjustments you made to the A* algorithm for preferring straight lines and wondered how it would fare if there was an additional reward for straight lines that left an even number of rows between its new path and its tail. And 2 would be the ideal number. When it needs to go back and fill it, this should allow it to drop down and back out once instead of doing a whole zigzag to cover the gap left behind.
@keenanuriu2703
@keenanuriu2703 3 жыл бұрын
Nice grooves, man. 9:36
@johncavanaugh3960
@johncavanaugh3960 2 жыл бұрын
Great stuff
@6Twisted
@6Twisted 2 жыл бұрын
This would make an awesome screensaver
@responsiblparty
@responsiblparty 2 жыл бұрын
I gotta admit, I found this very emotionally comforting.
@minecaftlichking
@minecaftlichking 2 жыл бұрын
I've seen the process video of this, mist have been a pain to get the A.I this far with all the different patterns you have to program
@kadenhesse9777
@kadenhesse9777 2 жыл бұрын
Great video as always. I wonder what would happen if you didn't randomly place the apple. What snake patterns would emerge for given placement conditions? Might be interesting
@roadtrain_
@roadtrain_ Жыл бұрын
The AI would undoubtedly overtime find the fastest path given deterministic placements, and if given depth, will plan ahead.
@DanBowkley
@DanBowkley Ай бұрын
I wonder if an algorithm that tries to keep the snake in as compact of a shape as possible would work better. It would prevent getting itself trapped, and it would sort of force the apples to appear in places where they wouldn't interfere with the snake in the first place.
@asdfghyter
@asdfghyter 2 жыл бұрын
I feel like the "Go along the edges" heuristic would benefit from being even more aggressive. For example at 19:03, the apple was just one space away from the wall, so the snake was doomed to fill the entire space to the right unless it kept snuggly to the right wall. I believe the heuristic "always go along a wall if the apple is fewer than 2 squares away from the wall (unless the snake is too short for it to matter)" would be a pure improvement, given that an apple 1 square away from a wall/snake will always partition the board in two when you try to take a shortcut.
@asdfghyter
@asdfghyter 2 жыл бұрын
Also, at 19:10, it would have been very beneficial to go towards the apple at the edge from head on, instead of first going to the wall and then turning, because it could have chosen which side to go towards depending on where the next apple is. Not sure what the best heuristic would be for that, but maybe a special case case for apples along a wall that prefers to hit them from head on instead of from the side (unless we were already following a wall).
@asdfghyter
@asdfghyter 2 жыл бұрын
Another random idea: I wonder if we could randomly smooth out the stored hamilton path, so it doesn't look as random. That is, make random local transformations on the path that preserves the large-scale shape but makes it less zig-zagy. Not sure if it would affect the performance at all, but it might give an interesting visual effect.
@asdfghyter
@asdfghyter 2 жыл бұрын
At 22:29 it feels very much like we could just go the straight path, but I'm guessing there is some parity based argument for why it would be completely impossible to make a hamiltonian path without going straight into the region to the left and filling that first, before proceeding to the right region. Like, imagine that the whole grid is a chess-board. Since the leftmost region has an odd number of squares, the square you exit onto must have the same colour as the square you entered through. This means that, despite there being a two-wide gap in the bottom, we can't use that to wait until later with entering the region, since that would mean entering from a black square and leaving onto a white square.
@asdfghyter
@asdfghyter 2 жыл бұрын
I wonder if this parity argument could actually be expanded into a full algorithm for determining the hamiltonicity of a sub-region of a grid? It should at least be useful as a very powerful optimization of a more brute-force based algorithm, by splitting the whole thing into simple regions and having an O(1) algorithm for determining where you are allowed to enter and leave such a region. I'm not completely sure though.
@BloodAsp
@BloodAsp 2 жыл бұрын
This is the first video that I watched on 16x speed. Condensed it down to nearly 2m.
@gardian06_85
@gardian06_85 Жыл бұрын
to cut the time (maybe even logarithmically) in the middle 3rd of the gameState (when the snake orphans){goTowardApple} it just seems very "inorganic" for the system when there is a clear chance to deviate by 2 nodes orphaning 1/10th the graph (event though there is enough room to potentially avoid apples that would cause a loss state and re-Hamiltonian-ize the graph) to then go on a magical journey traversing 50% of the graph when the re-Hamiltonian-izing would take 1/2 the moves used. another approach would be to re-insert the snake into the graph of nodes, but given them a weight > then traversing every available node reducing per index of the snake body with the tail being no increase, and the index directly behind the head having a value~(totalNodes*50)
@nilspochat8665
@nilspochat8665 2 жыл бұрын
This time it's snake who's asking "why are we here? just to suffer?"
@youforgotthelinkinthedescr6798
@youforgotthelinkinthedescr6798 Жыл бұрын
Sometimes I wonder if youtube audio library music comes with the audio already clipping just to save you the effort
@bejoscha
@bejoscha 2 жыл бұрын
Would have been interesting to have a graph showing what "mode" the snake is in (feel apply etc.). It flashes too quickly on the screen...
@matuili2633
@matuili2633 2 жыл бұрын
What's the song at 9:36? Edit: It's Acid Jazz by Kevin McLeod
@simonstrandgaard5503
@simonstrandgaard5503 3 жыл бұрын
I have also made a snake AI, that is slightly different. My AI can play against a 2nd player, so there is a lot of prediction about the opponent player. My code is on github under the name "SwiftSnakeEngine". Enjoy all your videos. Greetings from a fan.
@Zappygunshot
@Zappygunshot Жыл бұрын
Hmm, this is essentially a very convoluted randomised labyrinth generator...
@furlockbones
@furlockbones 2 жыл бұрын
look like it's creating a brain
@lwardrop2453
@lwardrop2453 Жыл бұрын
The thing about this program solving this complex Hamiltonian Cycle is that it’s only successful as a snake game player if it behaves in a way that completely covers any nodes that would take it out of a Hamiltonian Cycle if an apple were to spawn in that area. Virtually eliminating those non-Hamiltonian possibilities is a vital skill for this game.
@lwardrop2453
@lwardrop2453 Жыл бұрын
To elaborate: It’s harder to guarantee a Hamiltonian Cycle if the appearance of extra node blockers (lengthened snake tail) is going to eliminate your exit path, and if apples appear on the exit path it’s going to significantly increase the likelihood of a node blocker spawning in a debilitating location.
@Oscar-vs5yw
@Oscar-vs5yw 2 жыл бұрын
Would allowing the ai to take risks, not like risking itself dying, more like letting the ai cut off parts of the map instead of filling it in, would that allow for the ai to be a faster?
@jemand712
@jemand712 11 ай бұрын
thank god the music still sounds good on 1.75x speed was fun to watch
@TheKarolism
@TheKarolism 2 жыл бұрын
Alright AI, you win I give up. This was exhausting to watch.
@nocaca7929
@nocaca7929 2 жыл бұрын
BIG BRAIN 9:20
@peanutsans6780
@peanutsans6780 Жыл бұрын
i dont think i blinked at all dude my eyes hurt so fuckin bad. 10/10
@phildem414
@phildem414 Жыл бұрын
This thing is hypnotising 🤩🤩🤩
@breadfan_85
@breadfan_85 2 жыл бұрын
So satisfying.
@tyspaulding2025
@tyspaulding2025 2 жыл бұрын
Would it be possible to increase apple collection efficiency if an optimisation was made to calculate the empty space around the apple so a new one has higher chance to spawn closer to the head? Maybe making the apple come closer might help it become the 'perfect' ai
@tyspaulding2025
@tyspaulding2025 2 жыл бұрын
It may be a negligable difference but possibly worth looking into, if i were to make an attempt i would try to find the path that gets to the apple without breaking the cycle while leaving as much nearby space as you can fit. If the cycle is never broken it could lead to more nearby apples and more shortcuts to increase efficiency. Love to see this content, even if im not gifted in the field i hope my insight helps, just subbed at 99.8k hope to see you there soon:)
@RyluRocky
@RyluRocky Жыл бұрын
This music is giving me advertisement trauma.
@mattkrambeer6113
@mattkrambeer6113 2 жыл бұрын
This is like a dog chasing its own tail, if it had an IQ of 300.
@moxiesmotel
@moxiesmotel 3 жыл бұрын
As a non-mathematician and a bad coder; would implementing a different behavior for early/mid/late game be feasible? If the snake would be aware of its own length and takes that into the calculation, long cycles should be avoidable. In short, if the snake doesn't need 1/3 of the playing field it would cut off by turning left instead of right, assess how long the current snake length is and whether that length + X % buffer would fit into the remaining cycle, then simply 'cut off' that area and ignore it until it is released again. I'd be curious to see the results and failure rate.
@researchinbreeder
@researchinbreeder 2 жыл бұрын
Defining the transitions would be a headache, and largely unnecessary. Plus, the current solution can reasonably be applied to a board of any size (though the exponential nature means it will struggle computationally with superboards, there's no reason it should fail outright on something as ridiculous as 1k by 1k). This means that compared to rigorously defining each state of the game and tuning an algorithm for that portion, the algorithm showed is actually (relatively) elegant. Besides, the Nascar and AppleFear modes essentially implement a soft form of early/mid/late play anyway. The various functions cause it to coil tightly in not-quite-the-corner in the mid and mid-late game, meaning less of the snake is exposed to the play area and, somewhat inadvertently, limiting where the apple spawns. Edit: on further reading, you essentially described what the purpose of Nascar Mode is; instead of blindly following A* or the modified version thereof, it restricts turning to a single direction so that the Snake can get out of its own way, preventing loops and also reducing moves.
@KudaKeileon
@KudaKeileon 2 жыл бұрын
I want a screensaver of this.
@martinmarkmarkovics7754
@martinmarkmarkovics7754 2 жыл бұрын
Sorry for my english, but this topic is quite interesting. So I'm think it would make a more optimised path if when the last line is free to excape it could calculate the volume of the outter free space, compared, to the closing one. If the outter, let's say 70% bigger, is safe to say it's not a big problem to cut the line and close some free paths. I think it could be easily calculated from the full 10x10 space, minus the snake and the remaining space is divided by the snake's footprint (outline). Yes you have to know witch cells are covered...
@martinmarkmarkovics7754
@martinmarkmarkovics7754 2 жыл бұрын
This algorithm is looks only where "I'm" heading at. If it could looks, or remember where it comes from, it could have an easier way to think of a new route..
@logancontracier7125
@logancontracier7125 4 ай бұрын
As someone who took programming for two years in high school, you definitely have to have a lot of math skills like this dude to make a lot of cool ass programs. Coding is just a pseudo language itself
@The4gotNdeath
@The4gotNdeath 2 жыл бұрын
Can your algorithm be applied to MicroMouse? That would be pretty cool to see
@snowiePL
@snowiePL 2 жыл бұрын
An optimal solution would be interesting to watch
@thomasmann3560
@thomasmann3560 2 жыл бұрын
Literally watching a computer, do math.. but my brain thinks that it seems like a very smart computer winning at a game I've lost 1000x to.
@ArcticHat
@ArcticHat 2 жыл бұрын
how do you run the code
@kymiram7865
@kymiram7865 2 жыл бұрын
Black (HC Grid): most likely for snake AI to get ran over White (HC Grid): most unlikely for snake AI to get ran over
@Sam-qn4ly
@Sam-qn4ly 2 жыл бұрын
Is there a way to "find the shortest path" using a standard pathfinding algorithm and then turn that into a Hamiltonian path?
@JustinVallon
@JustinVallon 2 жыл бұрын
The shortest path might end up making some part of the maze unreachable, meaning a Hamiltonian path could not be constructed. So, you could do something like: of all the possible hamiltonian paths for the current snake, choose the one that moves towards the food.
@JustWasted3HoursHere
@JustWasted3HoursHere 2 жыл бұрын
Imagine watching a human doing this live on an arcade machine back in the day (like "Nibbler" from Rock-Ola).
@Thenotfunnyperson
@Thenotfunnyperson 2 жыл бұрын
I don't think it is possible.
@JustWasted3HoursHere
@JustWasted3HoursHere 2 жыл бұрын
@@Thenotfunnyperson No doubt! But I would stand in utter disbelief at that superhuman achievement if I saw it.
@italixgaming915
@italixgaming915 2 жыл бұрын
@@Thenotfunnyperson This is indeed possible. You don't need doing so complicated paths, the game can be done from example by going on the bottom line from the left to the right, then on the right column till the top, then down the column just on the left to the bottom (without touching the bottom line of course) then up again, and so on as many timess as necessary then you pick your item and begin a new cycle. Of course it requires a perfect timing everytime but if the speed is not too high for a human, the perfect game could be done with a lot of practice.
@iseriver3982
@iseriver3982 2 жыл бұрын
Now you need to build the robot that can play snake on an old Nokia.
@isopod12
@isopod12 3 жыл бұрын
make a video about this ai gameplay but without the aspects (without the lines and stuff)
@ferociousfeind8538
@ferociousfeind8538 2 жыл бұрын
What if the plan was to construct just one hamiltonian cycle every time an apple appeared (or, at least, every time the current cycle would take longer than the A*'s solution to getting the head to the apple) with as short a distance between the snake's head and the apple as possible, because really, the game is as good as static until the apple is gotten and a new apple is spawned? I think if you compress all the hard work into the frame a new apple spawns, and no computational work until those sparse moments when the apple is gotten, you'd be able to make a faster snake AND a faster-to-record snake. You could see in advance the exact path the snake will take to the next apple, and see where it could make optimizations and work from there.
@Sundude05
@Sundude05 3 жыл бұрын
Fire Logo Get it bad pun
@AlphaPhoenixChannel
@AlphaPhoenixChannel 3 жыл бұрын
=)
@Sundude05
@Sundude05 3 жыл бұрын
@@AlphaPhoenixChannel yay you replied but the logo is great
@alfonsmarklen1345
@alfonsmarklen1345 2 жыл бұрын
I think that you should probably be able to make improvements to the snake if you make an ai that just ingnore the Hamiltonian cycle when you obviously don't have any reason to follow it, like when you don't have any spaces that a 2x2 block would fit in. As soon as you would have a reason to use a Hamiltonian cycle just calculate one
@peterdriscoll4070
@peterdriscoll4070 2 жыл бұрын
It reminded me of Roadrunner. He never gonna get caught. Meep meep.
@midchicken6599
@midchicken6599 2 жыл бұрын
so true peter
@alisherbirzhanov5215
@alisherbirzhanov5215 4 жыл бұрын
From 0:26 till 0:27 why doesn't snake choose the most optimal algorithm, but makes some fluctuations? I mean, couldn't the Hamiltonian cycle construction be neglected at the beginning?
@AlphaPhoenixChannel
@AlphaPhoenixChannel 4 жыл бұрын
If it just suddenly tried to latch onto a Hamiltonian cycle after a few minutes, there’s no guarantee it would work and I didn’t take the time to program it to gamble. But you’re right overall - it’s slower at the very start with this algorithm than straight A*
@Jafarnk.
@Jafarnk. 4 жыл бұрын
❤️❤️❤️
@nycki93
@nycki93 2 жыл бұрын
how cute, you taught a computer to be claustrophobic!
@Jafarnk.
@Jafarnk. 4 жыл бұрын
shared
@shatterhacked
@shatterhacked 10 ай бұрын
I don't even understand this and I appreciate the mechanics of this
@4real681
@4real681 2 жыл бұрын
that looks like that thing where my shit gets pushed through
@ryansamarakoon8268
@ryansamarakoon8268 3 жыл бұрын
That is one phat snake
@alexandertorres-wo8dz
@alexandertorres-wo8dz 11 ай бұрын
Aztecs building temples be like
@zayyd7
@zayyd7 4 жыл бұрын
Wow
@uncreativename5736
@uncreativename5736 2 жыл бұрын
I guess we can call this an ' A* path-finding algorithm with a "Hamiltonian bias" '
@zrebbesh
@zrebbesh 3 ай бұрын
You can still shave several thousand moves off this game. Right now the snake is coiling until its tail gets out of its way, as though the tail will NEVER get out of its way. But it will, and you know exactly how long it's going to take. So when an apple is on the screen it can save moves by diving into closed spaces NOT containing the apple, if the closed space contains its own tail. It can know when its tail will get out of the way leaving a shorter safe path to the apple. To put it another way, you are seeking an A* path through time as well as space, with the condition that the path must always leave an escape route to the tail, and there are possible path segments in the future that are not available in the present.
@AlphaPhoenixChannel
@AlphaPhoenixChannel 3 ай бұрын
Oh my god that’s an amazing way to think about it. A* on a 3D grid where each step is mandated forward in time. That’s so simple I love it
@zrebbesh
@zrebbesh 3 ай бұрын
@@AlphaPhoenixChannel Yeah. On further consideration, it suffices to find the shortest path that goes to the apple *AND* *THEN* the tail, in that order, then follow that path until the location of the apple changes, and repeat. You'll still get lots of coiling, but only in the late game when it's becoming necessary.
@v.gedace1519
@v.gedace1519 3 жыл бұрын
Take a look here: kzbin.info/www/bejne/i3rCemmpf72UgNk fast, generic, ..., abbreviation functionality inclusive, ... Complete code: github.com/UweR70/Hamiltonian-Cylce-Snake
@MrHucast
@MrHucast Жыл бұрын
This was my first run-through of Snake on my 3210, how did you get your hands on it? 😅
@Marc_Wolfe
@Marc_Wolfe 2 жыл бұрын
Looks like a bunch of wasted recalculation when filling spaces to wait for tail to be out of way; and a case for "if tail WILL be out of way, just go to apple" instead it waits until the path is cleared, then stops stalling.
@nikolatasev4948
@nikolatasev4948 3 жыл бұрын
Dammit, I'm writing this right now. AI works perfect for grids up to 8x8, then starts stuttering and fails miserably around 12x12. Need more optimizations. Why did you use 30x30, it would have been so much easier otherwise :D Edit: at least please tell me this is a replay, not real-time.
@AlphaPhoenixChannel
@AlphaPhoenixChannel 3 жыл бұрын
haha I chose 30x30 specifically to make all exponential solutions completely untenable. I think that some of the blobfinding I do here might be n^2 but that's probably the most expensive to scale. If matlab is rendering images (like these videos I posted) it only funs at about 2 fps, but if you take away the imaging, the actual snake algorythm runs at a couple hundred FPS (gets faster at the end of the game when there are fewer open spaces). The plot of execution speed on a Ryzen 5 1600 is at 15:45 in my main video about the snake: kzbin.info/www/bejne/ioDTc5acl6aahsk
@nikolatasev4948
@nikolatasev4948 3 жыл бұрын
@@AlphaPhoenixChannel I'm not sure what to make of the FPS... you calculate one step per frame? My AI plans the whole path to the food on a separate thread, main thread moves the snake and renders it, sees where the new food drops and sends it to the AI thread to plan again, so no frames involved.
@godsinbox
@godsinbox 2 жыл бұрын
I got rsi in my thumbs just watching it
@YouTubeChannel-nf2nw
@YouTubeChannel-nf2nw 9 ай бұрын
Cooool
@EvilRamin
@EvilRamin 2 жыл бұрын
@OworBenard
@OworBenard Жыл бұрын
GG
@johnflux1
@johnflux1 2 жыл бұрын
Thanks for crediting me :)
@AlphaPhoenixChannel
@AlphaPhoenixChannel 2 жыл бұрын
Your code is way cool!
@Onmur
@Onmur Жыл бұрын
This would be a rad screensaver.
@Jay-ng5yf
@Jay-ng5yf Жыл бұрын
Terrible idea: create a genetic algorithm that awards points based on both number of moves between apples and number of apples collected, let the computer run for like a week (or so, I don't have a good sense of how long it would take), and see what solution to the game it comes up with.
@eclipse1353
@eclipse1353 2 жыл бұрын
Even I wouldn´t ever have done that... maybe with weeks to solve it in steps but NOT LIKE THAT
@italixgaming915
@italixgaming915 2 жыл бұрын
32:19 Level 1 completed!
@iamofgoneyes8997
@iamofgoneyes8997 2 жыл бұрын
Oh shit....
@alienrobot530
@alienrobot530 3 жыл бұрын
Gives me anxiety
@AlphaPhoenixChannel
@AlphaPhoenixChannel 3 жыл бұрын
Right?!
@DiamondSane
@DiamondSane 2 жыл бұрын
When 2x is not enough
@ditokum
@ditokum 2 жыл бұрын
why it need to fill the blank?
@ditokum
@ditokum 2 жыл бұрын
I'll make an A.I. more fast than you.
@ditokum
@ditokum 2 жыл бұрын
and I'm a Taiwannese so maybe I have some typo.
@ditokum
@ditokum 2 жыл бұрын
How long the delay?
@Handles_Are_Bad.Phuk-them-off
@Handles_Are_Bad.Phuk-them-off 2 жыл бұрын
50x50 snake grid
@AlphaPhoenixChannel
@AlphaPhoenixChannel 2 жыл бұрын
ow oof my processor
Your College Essay Didn't Get You Accepted, You're Just Rich
14:26
Robert Tolppi
Рет қаралды 971 М.
Normal vs Smokers !! 😱😱😱
00:12
Tibo InShape
Рет қаралды 117 МЛН
SHE WANTED CHIPS, BUT SHE GOT CARROTS 🤣🥕
00:19
OKUNJATA
Рет қаралды 14 МЛН
100❤️ #shorts #construction #mizumayuuki
00:18
MY💝No War🤝
Рет қаралды 20 МЛН
Miracle Doctor Saves Blind Girl ❤️
00:59
Alan Chikin Chow
Рет қаралды 38 МЛН
AI Battle Royale of 100 SNAKES in C++ - SFML Gamedev - Devlog
13:51
Algorithmic Redistricting: Elections made-to-order
26:48
AlphaPhoenix
Рет қаралды 414 М.
Overcomplicating GOLF by simulating every possible shot
14:00
AlphaPhoenix
Рет қаралды 440 М.
Centrist - Extremist mode on hard difficulty
12:53
Struggle of Combat
Рет қаралды 805
Procedural 2D squares grid. v2
0:57
Benerot Empire
Рет қаралды 285
Neural Network Learns to Play Snake
7:14
Greer Viau
Рет қаралды 4,5 МЛН
Making the World's Smallest Play Button (2^12 subscriber special)
11:11
8 Maze Generating Algorithms in 3 Minutes
2:47
Ready Set Python
Рет қаралды 49 М.
How does PLANETARY RADAR actually work?
14:02
AlphaPhoenix
Рет қаралды 50 М.
🤔Почему Samsung ПОМОГАЕТ Apple?
0:48
Technodeus
Рет қаралды 456 М.
How charged your battery?
0:14
V.A. show / Магика
Рет қаралды 2,4 МЛН
Теперь это его телефон
0:21
Хорошие Новости
Рет қаралды 1,7 МЛН
Куда пропал 3D Touch? #apple #iphone
0:51
Не шарю!
Рет қаралды 595 М.
POCO F6 PRO - ЛУЧШИЙ POCO НА ДАННЫЙ МОМЕНТ!
18:51
iPhone 12 socket cleaning #fixit
0:30
Tamar DB (mt)
Рет қаралды 1,8 МЛН
Power up all cell phones.
0:17
JL FUNNY SHORTS
Рет қаралды 48 МЛН