Now I want a heatmap to see which nodes it ran over the most.
@smg222 жыл бұрын
Mee too
@masi4164 жыл бұрын
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.
@AlphaPhoenixChannel4 жыл бұрын
Haha I found it pretty hypnotic
@AlphaPhoenixChannel4 жыл бұрын
Wish there was a single half hour song I could have used
@nekomimicatears2 жыл бұрын
@Gurifu how so?
@PeterNjeim2 жыл бұрын
@@AlphaPhoenixChannel Symphonies can last hours
@softpaw6234 Жыл бұрын
You're actually watching a visual representation of the logic the computer uses to play said computer game
@relaxnation17734 жыл бұрын
How do you not have more subscribers? This stuff is so entertaining!
@AlphaPhoenixChannel4 жыл бұрын
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!
@MimicGriphon3 жыл бұрын
This has aged well...
@England913 жыл бұрын
@@AlphaPhoenixChannel I think looking in depth into AI is a niche thing that not many people go looking for or at
@shadoww73013 жыл бұрын
@@England91 *The entire fanbase of CodeBullet*
@clockwork_mind3 жыл бұрын
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.
@jasoncrimmel3 жыл бұрын
This is the most stressful thing I've ever watched.
@1ucasvb4 жыл бұрын
Looking at the final behavior, it really looks like your two heuristics are pretty damn good, especially AppleFearMode. Nicely done!
@AlphaPhoenixChannel4 жыл бұрын
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!
@ouzoloves3 жыл бұрын
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
@DanBowkley6 ай бұрын
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.
@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
@SpencerTwiddy4 жыл бұрын
13:38 to 13:50 hurt to watch😂
@AlphaPhoenixChannel4 жыл бұрын
Ugh yeah...
@oakinwol3 жыл бұрын
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
@VocalMabiMaple3 жыл бұрын
@@oakinwol good play sure. Still hurts to watch.
@matthewhubka63503 жыл бұрын
@@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
@oakinwol3 жыл бұрын
@@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
@gallium-gonzollium3 жыл бұрын
3:00 Snake used box. It’s very effective.
@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.
@voxelfusion98943 жыл бұрын
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!
@piwi20053 жыл бұрын
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...
@NekuZX3 жыл бұрын
Everybody gangsta until the snake turns into a brain
@Zappygunshot2 жыл бұрын
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.
@technomatic66653 жыл бұрын
One pattern I noticed it use frequently was a space filling curve called “Hilberts Curve” and that was really cool to see!
@voxelfusion98943 жыл бұрын
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.
@mcsuperplayer2 жыл бұрын
@@voxelfusion9894 yeah but at some Points a order 1 hilbert curve was used to fill tue area
@redrumtheartist62752 жыл бұрын
I don't care if this was years ago it's still so satisfying to watch
@Robert_McGarry_Poems3 жыл бұрын
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!
@jacobdeal8434 жыл бұрын
Glad to see you are still making content after all this time :P
@sofia.eris.bauhaus4 жыл бұрын
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 😎)
@6Twisted3 жыл бұрын
This would make an awesome screensaver
@asdfghyter3 жыл бұрын
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.
@asdfghyter3 жыл бұрын
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).
@asdfghyter3 жыл бұрын
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.
@asdfghyter3 жыл бұрын
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.
@asdfghyter3 жыл бұрын
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.
@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)
@markmuir73383 жыл бұрын
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 😂
@nocaca79293 жыл бұрын
BIG BRAIN 9:20
@Kogacarlo3 жыл бұрын
The last 30 seconds are like detecting a gravity wave: Brrrrrrrp!
@russt27933 жыл бұрын
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.
@liam32842 жыл бұрын
the same strategy should scale to any square grid. 100x100 might take a rather long time though.
@BloodAsp2 жыл бұрын
This is the first video that I watched on 16x speed. Condensed it down to nearly 2m.
@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 Жыл бұрын
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.
@Torthrodhel3 жыл бұрын
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.
@HighlandCatz3 жыл бұрын
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
@responsiblparty3 жыл бұрын
I gotta admit, I found this very emotionally comforting.
@tlwalker19622 жыл бұрын
Truly mesmerizing!
@nilspochat86653 жыл бұрын
This time it's snake who's asking "why are we here? just to suffer?"
@furlockbones3 жыл бұрын
the ultimate chill/study video
@simonstrandgaard55033 жыл бұрын
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.
@martinmarkmarkovics77543 жыл бұрын
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...
@martinmarkmarkovics77543 жыл бұрын
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..
@Zappygunshot2 жыл бұрын
Hmm, this is essentially a very convoluted randomised labyrinth generator...
@furlockbones3 жыл бұрын
look like it's creating a brain
@kadenhesse97773 жыл бұрын
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_2 жыл бұрын
The AI would undoubtedly overtime find the fastest path given deterministic placements, and if given depth, will plan ahead.
@m_affiliates4 ай бұрын
@@roadtrain_considering it's not machine learning, and therefore cannot learn, I'm not so sure it would do that
@TheKarolism3 жыл бұрын
Alright AI, you win I give up. This was exhausting to watch.
@jemand712 Жыл бұрын
thank god the music still sounds good on 1.75x speed was fun to watch
@whoeveriam0iam142225 ай бұрын
7:17 weird moment when it got close to the apple and then turned away to go around
@keenanuriu27034 жыл бұрын
Nice grooves, man. 9:36
@peanutsans67802 жыл бұрын
i dont think i blinked at all dude my eyes hurt so fuckin bad. 10/10
@youforgotthelinkinthedescr6798 Жыл бұрын
Sometimes I wonder if youtube audio library music comes with the audio already clipping just to save you the effort
@mattkrambeer61133 жыл бұрын
This is like a dog chasing its own tail, if it had an IQ of 300.
@Sundude053 жыл бұрын
Fire Logo Get it bad pun
@AlphaPhoenixChannel3 жыл бұрын
=)
@Sundude053 жыл бұрын
@@AlphaPhoenixChannel yay you replied but the logo is great
@shatterhacked Жыл бұрын
I don't even understand this and I appreciate the mechanics of this
@kymiram78652 жыл бұрын
Black (HC Grid): most likely for snake AI to get ran over White (HC Grid): most unlikely for snake AI to get ran over
@logancontracier71259 ай бұрын
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
@RyluRocky Жыл бұрын
This music is giving me advertisement trauma.
@snowiePL3 жыл бұрын
An optimal solution would be interesting to watch
@ferociousfeind85383 жыл бұрын
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.
@JustWasted3HoursHere3 жыл бұрын
Imagine watching a human doing this live on an arcade machine back in the day (like "Nibbler" from Rock-Ola).
@Thenotfunnyperson3 жыл бұрын
I don't think it is possible.
@JustWasted3HoursHere3 жыл бұрын
@@Thenotfunnyperson No doubt! But I would stand in utter disbelief at that superhuman achievement if I saw it.
@italixgaming9153 жыл бұрын
@@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.
@thomasmann35603 жыл бұрын
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.
@nycki933 жыл бұрын
how cute, you taught a computer to be claustrophobic!
@iseriver39823 жыл бұрын
Now you need to build the robot that can play snake on an old Nokia.
@johnflux13 жыл бұрын
Thanks for crediting me :)
@AlphaPhoenixChannel3 жыл бұрын
Your code is way cool!
@zrebbesh8 ай бұрын
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.
@AlphaPhoenixChannel8 ай бұрын
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
@zrebbesh8 ай бұрын
@@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.
@phildem4142 жыл бұрын
This thing is hypnotising 🤩🤩🤩
@KudaKeileon2 жыл бұрын
I want a screensaver of this.
@Oscar-vs5yw3 жыл бұрын
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?
@moxiesmotel4 жыл бұрын
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.
@researchinbreeder3 жыл бұрын
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.
@4real6813 жыл бұрын
that looks like that thing where my shit gets pushed through
@Lego_Whis9 Жыл бұрын
Aztecs building temples be like
@breadfan_852 жыл бұрын
So satisfying.
@bejoscha3 жыл бұрын
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...
@peterdriscoll40703 жыл бұрын
It reminded me of Roadrunner. He never gonna get caught. Meep meep.
@midchicken65993 жыл бұрын
so true peter
@Jafarnk.4 жыл бұрын
shared
@trouaconti78123 жыл бұрын
For this not only the strategy but the dexterity of maneuvering the snake and even if good at it you're gonna bump into your own body from time to time...
@Marc_Wolfe3 жыл бұрын
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.
@alfonsmarklen13453 жыл бұрын
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
@uncreativename57362 жыл бұрын
I guess we can call this an ' A* path-finding algorithm with a "Hamiltonian bias" '
@nikolatasev49483 жыл бұрын
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.
@AlphaPhoenixChannel3 жыл бұрын
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
@nikolatasev49483 жыл бұрын
@@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.
@Jay-ng5yf2 жыл бұрын
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.
@MrHucast2 жыл бұрын
This was my first run-through of Snake on my 3210, how did you get your hands on it? 😅
@tippyc23 жыл бұрын
i just watched your edited video on this. the final behavior is pretty good, but there's still some weird things going on. It's too indirect when there's a clear path, and it needlessly gets stuck on the grey path a lot. I think you can improve how you choose which path to follow at any given time, and save some cpu time. But creating the paths is a bit beyond me, so i'll just lay out my idea in case anyone's interested. It needs to pick the best path and stick to it as much as possible. So the priority of the new choose path algorithm is reaching the apple in the shortest possible number of moves. Before I start, I'm gonna throw out the blue path. It's just chewing up cpu cycles, and we're never gonna follow it. 0. Starts when an apple is consumed 1. choose current path 1a. Check YELLOW path condition, "apple inaccessible". if yes, use YELLOW path algorithm, proceed to step 2. 1b. Plot the RED path from current _vector_ to the apple. Check hamilton cycle for RED path + current snake position. if valid cycle is found, proceed to step 2. 1c. Plot the GREY path from current _vector_ to the apple. Check hamilton cycle for GREY path + current snake position. if valid cycle is found, proceed to step 2. 1d. Use PREVIOUS hamilton cycle path, proceed to step 2. (fall back if none of the new algorithmic paths are able to complete a valid cycle) 2. Proceed XX%* along current path. *step size should depend on how far we've traveled on the current path, and by how much of the board is filled with snake 3. Repeat step 1 until we reach the apple * You might notice this skips the task of reanalyzing at every step. But the snake will never corner itself because you're always following a valid hamilton cycle. Even as the snake's tail vacates squares there will always be a valid (if inefficient) path, because the previous path included the now vacated squares. At the beginning of the game when the snake is small and easy to navigate, you use a large % step and if you miss a more efficient path you havent lost too much. Near the midgame, use a small step size, because you are more likely to make use of the vacated squares. At the end where there isn't much real estate available, even the least efficient path doesnt cost us much in terms of distance traveled. The step size should also depend on how far into the current path the snake is. Frequency should increase as the snake gets closer to the apple. In order for this to work properly while skipping reanalysis steps, the yellow path would need to follow a complete hamilton cycle. It currently appears to function because it reanalyzes every step, so is able to catch conditions where the yellow path would cut off "loops" of the map. And the result is that it falls back to the previous hamilton path anyway. But if i want to follow the yellow path and skip reanalysis, the yellow path needs to be guaranteed good. That could be fixed by redefining the yellow path to include a valid hamilton cycle.
@The4gotNdeath2 жыл бұрын
Can your algorithm be applied to MicroMouse? That would be pretty cool to see
@tyspaulding20253 жыл бұрын
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
@tyspaulding20253 жыл бұрын
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:)
@alisherbirzhanov52154 жыл бұрын
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?
@AlphaPhoenixChannel4 жыл бұрын
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*
@Onmur2 жыл бұрын
This would be a rad screensaver.
@godsinbox2 жыл бұрын
I got rsi in my thumbs just watching it
@matuili26333 жыл бұрын
What's the song at 9:36? Edit: It's Acid Jazz by Kevin McLeod
@micaldomlancer14942 ай бұрын
Something I'm curious about is how much time did the AI spend actually following the Hamiltonian path? The AI seemed to 99% of the time just completely ignore it so was that path actually necessary?
@AlphaPhoenixChannel2 ай бұрын
Technically 100% of the time. Its always following A Hamiltonian path, even if its not the one it started the move with
@230kittygamer72 жыл бұрын
Who else watched the entire video from start to finish? It'll go by a lot faster if you set to to x2 speed
@DiamondSane3 жыл бұрын
When 2x is not enough
@eclipse13533 жыл бұрын
Even I wouldn´t ever have done that... maybe with weeks to solve it in steps but NOT LIKE THAT
@ryansamarakoon82684 жыл бұрын
That is one phat snake
@isopod124 жыл бұрын
make a video about this ai gameplay but without the aspects (without the lines and stuff)
@italixgaming9153 жыл бұрын
32:19 Level 1 completed!
@iamofgoneyes89973 жыл бұрын
Oh shit....
@Jafarnk.4 жыл бұрын
❤️❤️❤️
@cycygamingfrenglish Жыл бұрын
Now do with 5 apples
@Bahrzy20022 ай бұрын
I made a faster one : kzbin.info/www/bejne/aGqkmK2lntiNhKcsi=1lsbk0U-K4kps18a
@Sam-qn4ly3 жыл бұрын
Is there a way to "find the shortest path" using a standard pathfinding algorithm and then turn that into a Hamiltonian path?
@JustinVallon3 жыл бұрын
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.
@alienrobot5304 жыл бұрын
Gives me anxiety
@AlphaPhoenixChannel4 жыл бұрын
Right?!
@Zushi_hedgehog2 жыл бұрын
who else just found a cool new screen saver?
@v.gedace15194 жыл бұрын
Take a look here: kzbin.info/www/bejne/i3rCemmpf72UgNk fast, generic, ..., abbreviation functionality inclusive, ... Complete code: github.com/UweR70/Hamiltonian-Cylce-Snake
@bejoscha3 жыл бұрын
Thanks for stealing another half hour of my lifetime...