AI Learns to play JUMP KING

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments

CodeBullet's videos are always hella fun.

👍︎︎ 4 👤︎︎ u/GeneticSplatter 📅︎︎ May 02 2022 🗫︎ replies
Captions
[Music] all right new code bullet video hey guys welcome to a new hi has this ever happened to you if so do I have a product for you introducing code bullet doc mode what an innovation now you can enjoy code bullet videos without permanent damage to your retinas just kidding [ __ ] this is my house flash bomb that's right [ __ ] your retinas I don't give a sh don't you ever tell me what to do again don't ever in other news I will be changing the background to a dark gray and that was my idea and mine alone Anyway video [Music] [Music] jumping is a game designed to be as frustrating as possible like people complaining how wider video is jump King is like the inbred offspring of Mario and getting over it platforming at its worst and it's pretty fun there is a small problem with the game though and that is that I suck at it believe it or not anger management has never been a strong suit of mine so imma do what I do best and quit before I punch another hole in my wall and by quit of course I mean I'll remake the game from scratch then add an AI to play the game so I can pretend that I actually beat it which is arguably harder and probably takes longer than just beating the game but I never claimed to have good time management skills either so what are we waiting for let's get this party started alright first step is we gotta remake the game so let's get coding alright so let's get the jumping happening first and then we'll work on the king [ __ ] later sorry move on all right oh There She Goes okay yeah okay I'm good okay that wasn't really that hard but jumping is done and now we have to work in the Collision Logic the world of jump King can be separated into a bunch of lines which are all either vertical horizontal or diagonal so if we just get the square to collide with each of these lines correctly then we chill so let's start with the most basic one which is just a floor line for the dude to land on oh yep didn't even load cool just needed a touch lower all right there we go very nice okay yep that makes sense yeah so all I've managed to do so far is draw a line on a screen but that's progress baby and you can't take that away from me okay now let's actually get the dude to collide with the line uh and So the plan is every frame we're gonna check to see if the boy is colliding with a line and if he is stop him falling stop the process for doing this is actually really simple all we need to do is just steal some code from someone smarter than me like Jeffrey Thompson here and it's done the magic of programming baby and here she is I'm coming for you Jeff I swear to [ __ ] God You better lock your doors Chief I trusted you and you [ __ ] me oh wait no I fixed it that's my bad sorry sorry Jeff sorry it happens my bad yeah that was me that was on me but it's not all sunshines and rainbows is it Jeff there's a small problem those amongst you who use their eyes to see things probably picked up on the fact that this looks like this is because when it lands it's just kind of freestyling where it stops it just stops wherever it wants to and this has to do with the timing and the frames and stuff but I won't bore you with the explanation and what I mean by that is I can't be bothered explaining it so the plan to fix this after we've detected a collision we're gonna need to snap the square to the line it collided with just like no no just like this hey all right all right up down looking good it's time to get some left right from happening all right let's test this out there he goes all right I touched too much juice on that one that's better no it isn't uh there we go okay very nice now if the game was all flaws we'd be set but life's secure so we're gonna need some walls and the main problem with walls is they're not flaws which means I'll have to do some more work which is very sad uh so we can actually reuse the Collision logic because vertical lines are still lines and when the player collides with a wall all we're gonna have to do is invert the horizontal movement so if you're going left now we're going right really not that hard like three lines of code uh it probably didn't need to complain about it but whatever let's try this out hey there we go nice very cool oh [ __ ] so turns out the Collision logic I've implemented is extremely primitive and falls apart as soon as the player collides with two lines at once which happens a lot this problem has to do with the order in which we handle collisions so this is the situation this is the previous frame very cool no collisions here we're chilling but we move forward one frame then oh we have two collisions we are no longer chilling if we do the wall Collision first we're Gucci we bounce back like we should but if we do the floor first we jump up and it looks terrible and wrong and like not physics so yeah we could just always prioritize wall bounces first but then there are other cases where we should do the floor first so the current plan is to move the player the smallest amount possible so if the wall bounce requires the smallest correction then we go with that this works most of the time and let's just round that up to all of the time and move on great now that that's done and we'll have no further repercussions we can start making the game pretty some people say you should finish coding the game's mechanics before you start working on the art style but those people haven't met my attentions fan and I'm sick of math so let's get artistic now art is a lot like programming it takes of hard work and dedication to get really good at it but if you are really serious about it it is something that anyone can succeed at now don't get me wrong there will be hardships and sometimes you will want to quit but with enough drive and enough power you can stay hungry and you can develop words to live by so yeah that's done we've got the background done now I'm just gonna code a quick tool to help me place the walls and stuff so it all matches the background that I luckily all the walls and [ __ ] are placed under 20 pixel grid so placing them accurately is actually pretty easy okay let's take it for a spin hey I know the play is just a square at the moment but I actually think this looks really legit I think this looks really cool so far I've just been eyeballing the jump height and stuff but it is super important that we get the jump high exactly spot on otherwise it'll be impossible to finish the game or it might be way too easy to finish the game we need to get that height perfect so after tweaking the jump force and gravity like 50 40 times this is the result which I'm actually like super happy with I think it looks great if you don't think it looks that good then you can go ahead and leave a dislike YouTube cares about your opinion about as much as I do and look at this we got a game here it needs a little work but it's looking solid and by work I mean drawing the character and by drawing I mean plagiarism but so I don't get sued I'm gonna add a small touch oh my God he's perfect look at him jump he's so cute yes I am so happy with that I'm so happy with that and you know what else I'm really happy with today's sponsor nordvpn whoa that was clean [Music] hey little guy you must be new here welcome to YouTube just don't go over there oh Spooner man no no no no when nordvpn gave me an explanation of their product I looked at them for a moment then I spat at their feet don't dishonor me in my family I said I've been naughting up a storm for years now it's the best VPN around and it's easy to use you just do a single click and whammy I'm in France now uh are we uh I can't do a French accent this bit was really dumb your VPN is now more than just a VPN it's modeled than a VPN get it because no they get it with their new threat protection you are now protected from malicious websites malware trackers and intrusive ads vpns are really great but they can't stop you from being an idiot on the internet that's until now so to support this Channel and try nordvpn with a 30-day money-back guarantee go to nordvpn.com code bullet to find out more that's nordvpn.com codebullet to get an exclusive deal just for you guys Link in the description okay back to the video okay so the next big step is to make all the levels I've done one level but there are like 44 of them so I am putting that off as long as I can but one thing I actually have to do before I make all the levels is that there are some lines which are 45 degrees I don't want to talk about it I'll save it for my therapist next I added some sound effects just to make sure players know when they [ __ ] up oh yep that's it makes me want to just punch an infant that's what we're going for and whammy it's time let's make ourselves a game now as previously stated I am not very good at this game it's hard all right and in order to draw the backgrounds with my fantastic artistic abilities I'm gonna have to be able to get Beyond level two which at the moment is ambitious so the workaround is to watch a speedrun of the game which is a great way to rub in-house I am at this game but it works 44 level backgrounds later and now all we have to do is draw all the lines which make up each level so I put on some bangers and got to work [Music] and that's the last level only took like two hours and it was tedious but whatever it's done now and before I show off the game there are a couple of areas that needed some more work there's a snowy area where there's a constant blizzard that pushes you around that was easy no problems there at all and there's an area which is slippiest but once again a couple lines of code no sweat okay it is time to show off my masterpiece feels weird saying that because all I'm doing is copying someone else's work but you I'm proud of it okay I'm gonna show it off the only way I know how falling down the entire way [Music] [Music] thank you [Music] foreign and that's it that's jump King done it's buggy it's got the bare minimum amount of Animation but it's just as aggravating to play as the original so I think that's mission accomplished all right it is time let's say I that [ __ ] [Music] wow okay uh yeah AI okay let's go AI okay so the plan for the AI is very simple I'm gonna whip out Old Faithful and Charles Darwin this I'm talking The evolutionary algorithm sounds sexy and is sexy we just generated a bunch of Jumpy boys and make them do random moves then the ones that perform better get to live on and the ones that don't get executed it's the same Strat that I would use for raising children if I was allowed near them anyway those who live on get all nasty and then babies happen then we mutate the babies just for fun and whammy we got a new generation that's better than the last keep that up for a while and you got some smart boys okay let's assemble the squad okay so adding sound effects is potentially a mistake I think I'm gonna mute the audio for the rest of this one thing that is great for finding all the bugs in your game is running 500 players at once doing all random [ __ ] I was planning on pretending that they didn't exist and just editing the video around them but this is really gonna [ __ ] up everything so it's bug fixing time again okay that wasn't too bad let's try running that again get it because he's old he's old now hey that's better okay so the plan is we're only gonna let these guys have a certain amount of moves that way they can optimize say the first five moves before they work on the next five also if a player reaches the next level then I'm just gonna have all the players start from that point instead of running the whole thing again and again and again because that will take forever especially with 44 levels finally before I let these boys fly I need to define the fitness function which is what we use to tell if a player is good or not so we know who to kill this is fairly simple for this game if up good if down bad uh yeah that's pretty much it there are some levels where I need to add further incentive because the ideal path goes up and then down and then up again and the guys will never figure this out because they will refuse to go down since we've taught them that Dan is bad so to fix this I added a little collectible which if the AI collects it will be rewarded that way it'll be encouraged to actually go down and get it uh any more questions no great because I couldn't hear you even if I wanted to which I don't so it's go time [Music] [Music] foreign [Music] thank you [Music] thank you [Music] thank you [Music] [Music] thank you [Music] [Music] thank you [Music] thank you [Music] thank you foreign [Music] [Music] [Music] thank you foreign [Music] thank you foreign [Music] [Music] [Music] foreign [Music] [Music] [Applause] foreign [Music] thank you [Music] foreign [Music] foreign [Music] [Music] foreign yes yes [Music] we did it let's go so good I'm gonna just Chuck the full run in the background so you can actually see what was going on because it's kind of hard to see when there's 500 players going at one specifically what the line is but um this is it it's not the most optimal I'll be honest uh I could have optimized a little more to make it do it in the fewest moves possible but I didn't want to do that to be honest I don't have a great reason that probably would have been a good thing to do but here we are I didn't do it and I'm certainly not going to do it now overall super happy with the game I think it looks great um I'll consider uploading it I don't know if this might just be all [ __ ] now I can upload it if you want to play my version of the game if you played the original and you want to see how similar or different they are I think that'd be interesting Link in the description for that probably that took so long to edit down you have no idea the actual run itself was like three and a half hours and then uh even at four times speed which is what it was playing at like 40 minutes which is just you just can't put that in a video so I had to edit it down and get it down to like 10-15 minutes uh so we were skipping all over the place I don't know if you noticed but like sometimes there'd be like a 20 generation gap between cuts I will put the full video out on a second Channel I've got going um called code bullets day off I haven't uploaded there yes this will be first upload yeah go check it out like And subscribe of course uh subscribe here as well if you haven't probably subscribe here first then code for this day off that's going to be objectively worse content God I gotta work on the sales pitch for that that's a bad one yeah I'm hoping just a 40 minute video no Cuts just the whole thing uh some chill music in the background if you want to see like specifically how the AAA learns how it figures out each different level because some levels took ages some levels took like five minutes um and I had to cut that down because you know you guys attention span is ridiculous but that's jump King done let's go video took a little longer than expected that's uh better than a year but it's still three months is a while uh in my defense Eldon ring came out so you know that didn't help thanks again to nordvpn for chucking on a fat sponsorship for this bad boy I appreciate it and yeah that's it for me thanks for watching enjoy the rest of the video and I will see you in the next one later boys foreign [Music] foreign [Music] [Music]
Info
Channel: Code Bullet
Views: 7,293,965
Rating: undefined out of 5
Keywords: artificial, intelligence, coding, processing, java, machine, learning, genetic, algorithm, evolution, computer, science, programming, comedy, educational
Id: DmQ4Dqxs0HI
Channel Id: undefined
Length: 27min 12sec (1632 seconds)
Published: Sat Apr 30 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.