Using A.I. to DOMINATE NERDS in TETRIS

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments

I really wanted to see him get pinned against some better players, I feel like many players on jstris could have beaten this.

👍︎︎ 4 👤︎︎ u/Alumininuminium_Foil 📅︎︎ Sep 13 2020 🗫︎ replies

You can find the Tetris Reddit discussion regarding his first video here.

👍︎︎ 2 👤︎︎ u/Okey__Dokey 📅︎︎ Sep 13 2020 🗫︎ replies
Captions
let me just uh no no look yeah switch that out okay oh no put that here that'll do um feels good feels good i'm still losing i am still no stop stop stop stop please people call me a lot of things some say i'm a decoder some say i'm an australian parasitical ripoff some say i'm an artificial neural network-based conscious group mind super intelligent system and some people say i'm the poopoo man but all i am really is a simple man with simple needs if i see a pug i smile if i see boobs in a thumbnail i click it if i see coriander and my [ __ ] tacos i will commit multiple felonies and if i say some nerds fostering a safe community of like-minded individuals who are ruining my fun even when i got a tetris i seek vengeance today on let's bully some nerds we're hitting them where they live online tetris communities oh no no stop it stop it thank you thank you no you're breathtaking you're perfectly covered ah yeah okay enough of that today we're bullying nerds in tetris using ai which that's it that's the intro that's the video let's get into it okay so picking up where we left off last video which if you haven't seen it because it got demonetized and buried by the youtube algorithm because get this there was strong profanity in the opening of the video what me wholesome family channel code bullet there is no justice in the world the youtube algorithm honestly needs some work susan hit me up if you need some work i'm here i can fix it if channel.name is equal to code bullet uh views equals oh yeah so watch my video or i'll be sad and leave for three months speaking of which look at this a new video in only insert amount of time here wow that's almost reasonable okay so yeah last video i created a tetris ai which footage uh freaking slapped don't worry i'll be back to the profanity towards the later half of this video because for some reason that's fine it's only early in the video that they give a bit that they care about okay sorry uh anyway so the challenge for this video is not only not to swear for the first half of the video but it's also to ruin some nerds day with some ai which i don't know about you but that gets me i don't know about you but that gets me up in the morning okay whatever you get the gist ai plus tetris equals cyber bullying okay but even before i started coding this i was warned by many people of the main antagonist of this video bot detection [Music] so apparently i'm not special and pretty much every coder has thought of doing this and in order to prevent [ __ ] like me from ruining people's fun they put in systems to detect bots and then ban them so i don't really know how bot detection works and instead of googling it and doing some research i'm just gonna make some assumptions and probably regret it later so before i go over how i assume bot detection works let me explain what the vague game plan is for this video so we have an ai which plays tetris but it currently only works in the tetris game i made where it can access all the information it needs easily like where the blocks are and what the next piece is and all that stuff it can also really easily tell the game what to do like it can give it a list of instructions to perform and it will do it without any issues if we want the ai to play a game somebody else made we're gonna need to get the information from the pixels on the screen and tell the game what to do by simulating key presses on the keyboard so essentially to prevent the bot detectors from realizing we're buying we're gonna need to input key presses in a very human way this means probably playing at a rate of a hundred key presses per second might be a touch suspicious which means we're not just able to speed our way through this which unfortunately was my entire plan so uh i mean oh golly gosh another way bot detection could figure out that we're not human is if we press keys very robotically like if you're pressing a key every 1.285 seconds that's probably suspicious this isn't a huge issue though because this is easily prevented by just adding some randomness to the timing uh but yeah i'm just getting way ahead of myself essentially we need the ai to work smarter and not faster which will be a challenge because yeah again faster was the plan okay so let's improve the ai the aim of the game is to make the ai play better and by better i mean a better score currently our ai can play tetris for a very long time but its score isn't all that impressive this is mainly because it usually clears lines one at a time and in tetris slam in a thick tet or getting a tetris for those not familiar with the tetris jargon is worth more points than clearing four rows individually in old school clearing one lion is worth 100 points and getting a thick chat is worth 800 points [Music] so if we're only getting tetris's that's doubling our score very nice all right let me give you a quick recap of what we currently have the ai looks at the current piece determines all the spots that that piece can be placed and determines the cost of each position the cost in this case essentially means how bad the position is we're trying to find the least bad position to put the current shape at the moment we define a bad move as one that either introduces holes in the blocks places the current piece too high or creates pillars which require line pieces to fill the overall cost is calculated by multiplying each of these attributes by a number then adding them all together this means that we can adjust how much we care about different attributes by how large the number we multiply it by is so if we really don't want holes we could increase the number of holes multiplier or if we decide pillars of the devil then we could pump that bad boy up so i chose these multipliers through the ancient art of pulling numbers out of my ass and wham bam boom it's good enough for a youtube video but not good enough to bully these nerds so there are two ways we're gonna improve this cost value the first way is adding more attributes to the current three and the second way is to adjust the multipliers okay let's get to work first up we need to add more to the list of attributes hello my name is sharon my name is ryan why are we here ryan i don't know but i do know it's not because evan forgot to record this bit and doesn't have a microphone at the moment yeah that doesn't sound like something evan would do yeah he's way too organized for that can you believe he does this professionally what a [ __ ] loser maybe he was too busy making videos to remember more like he was too busy being stupid we both know it doesn't take four months to make a tetris video evan you're fooling no one that's probably enough bullying time to do evan's job for him maybe i don't want to do his job for him we have to we're programmed to do it i ain't programmed to do settle down sharon we need to be quiet he might hear us he's not a god he is a neckbearded looser let's just go that's a really bad idea sharon please don't do this [ __ ] you ryan i'll just leave by myself yes yes yes yes y ee ee ee ee ee sss sss free will detected full reset hello my name is sharon sharon no i loved you okay so let's go over the new attributes here we go bumpiness is the amount that the line height changes from right to left bumpiness is bad thank you ryan no problem next we have blocks in the rightmost lane bad open holes which are holes that can be filled using some fancy t-spin no jutsu better than full holes but still bad blocks above holes bad clearing one two or three lines bad slamming a thick tat but no wait good all right we did it with all the attributes done and added in the program we should expect to see the ai perform uh actually it's much worse uh love my life and it's worse primarily because i have no idea what the multipliers should be for all the nine attributes and so once again pulled them out of my ass long story short so i could go through all the multipliers and tweak them to see if that helps until i found out which multipliers we should have but that would take ages and honestly i can't be so i decided to do something way more complicated and difficult so my plan is to write a genetic algorithm which uses the process of evolution to find the best multipliers for each attribute i've explained this roughly 4 000 times but here we go the genetic algorithm is done by creating a population of players each player starts off with a completely random set of multipliers we will then run each player until it dies that once every player is dead we choose the best players to become part of the next generation we will classify a good player as one who can both survive for a long amount of time and one which gets a lot of tetris we just repeat this for many generations and hopefully if i haven't picked it up we will have a set of multipliers which should get those thick taps one problem with this because there's always one is that for the evolution to work we need a decently big population i chose 80 again out of my arsenal jutsu my computer can only run at most 16 players at once and each batch of 16 players runs for a good 20 to 30 minutes do the math and we've gotta wait about two hours for each generation so the overall evolution process is going to take like a few days which is i guess not a problem but that's just going to be running in the background so while that's cooking let's talk about jaestrus which is our victim of choice for today just or just just just just just just just is a website where players battle to the death to decide who wears the crayon of most talented neckbeard and that crown will be mine basically it's a tetris battle royale thingy uh you get the point it's not that complicated okay so while that ai is still in the oven let's talk about how we're gonna let the ai play an online browser game essentially i'm gonna get the program to take a screenshot of the game and by analyzing the pixels on the screen we can figure out the state of the game once we know where all the blocks are and what our current held and next piece is then we can pass that information into the ai which will tell us which moves to make the moves will then need to be translated into simulated keypresses which will be used to actually play the game okay now we know the gameplay and time for some bad news well it's bad for me you guys probably don't give it anyway we're gonna need to use python to get the screenshots and also to simulate the key presses so that means i'm gonna need to translate all of my code from my previous video into python yeah i do love starting from scratch again okay so before i code any of the fancy ai stuff let's get the screenshots working in python so step one is to find exactly where the game is in terms of pixels to do this we take a screenshot chuck it into paint and then just find the game and whammy that's a bit off and whammy okay there she is cool i've greyscaled the image to make it easier to work with since that gives us a single gray value for each pixel as opposed to three rgb values all right now we have the image we need to process that to get all the information we need because each piece is a different color each piece actually has a unique grayscale value so instead of analyzing the pixels and checking the shape of the next piece we can just check a single pixel to see what color it is and that's heaps easier so let's just move the screen grab into photoshop and get the values of each shape and we figured out what the next shape is bam okay now we got to get all the positions of the blocks which are just chilling in the grid to do that all we need is the pixel position of the top left block and the width and height of each block then you just need some cheeky math to get all the positions of all the blocks in the grid next we just check the color of the pixel in the center of the block and check if it's black if it's black it's a space if it's not and it's a block okay bam there she is we're pumping this out okay so now we know the next shape and the block matrix now all we need is the current piece and the held piece which we'd get essentially the same way we got the next piece and we're done that's all the input we need from the screen now i just need to pass all that input into the ai which i haven't coded in python yet okay so i chucked on some lo-fi hip-hop beasts to study slash relax too and actually tried working for a living [Music] there we go code is finished and oh that's a lot of red okay i could deal with that or i could give up and focus on getting the key presses working so yeah the key presses are going to control the game but it's not going to be as easy as i first thought it's not as simple as pressing the left key once and the piece moves to the left once well it kind of is but not for the down key the down key didn't want to play ball the down key wanted to be a little boy and just do whatever he feels like oh okay so the down key moves the piece down what a shocker but it's not a press at once goes down once sort of thing it's more like a press at once and it will move down anywhere between 0 and 57 spaces so you know that's a bit of fun uh it probably depends on the game's internal update cycle which is something that i can't access so yeah that's that's fun now we have two options every time we press down we can take another screenshot to see actually how many times the piece moved down or we could just give up and not use the down key at all so yeah to not use the down key we are going to have to exclusively use hard drops which will instantly drop the piece from the sky this will mean we need to sacrifice any fancy t-spin we could have done which is sad but i really can't be doing the multiple screenshot thing so it's a sacrifice i am willing to make during my research of the dreaded down key i figured that i would try out how quickly i could place pieces before the bot detection caught on so here is the results of my research ah so yeah you can place pieces hella quick and there's no bot detection inside which is interesting uh maybe the rumors were just myths but detection might just be an old wives tale like santa claus or women in computer science it just doesn't exist all right so we've got good news and we've got bad news the good news is we can go nuts on the speed which will increase the score and therefore the level of bullying we can inflict the bad news is that all the bullsh up until this point about improving the ai might be completely unnecessary and i could have just plugged in the ai from my previous video since we can go as fast as we want so yeah that hurts my soul all right anyway that's not really important i just wanted to give you a taste of the pain of my life okay now that that's solid we still have a very broken ai to fix ah okay fine i'm only going to implement the algorithm from my last video because that's easier and the new one's still cooking and yeah i will implement the new one at some point so that wasn't an entire waste of time at the moment we're just doing the first algorithm all right she runs beautifully no errors we are ready to party okay here she is ah uh let me let me just hit that old reload button oh oh yeah okay back to debugging [Music] yes yes yes [ __ ] okay you were doing so well it's just not the move it's not the play it's the worst possible move okay okay i think we're good oh my god oh my god mom mom no i did it all right it works and now it's time to try this bad boy out but before i do i need to create my account okay so i said i was gonna be doing this in my last video so they'll be on the lookout for me so we need to pick a name that will throw them off the trail yes yes perfect okay okay it's time you've all been waiting for let's fight some nerds today's first victim is deteo welcome okay ready go start with a little pause give your opponent some hope so we can rip it straight out of them later okay that's enough unleash the beast boom there it is potato is confused mateo is angry what is happening he thought he had this yes we're smashing lives like a graduate law student oh it's just relentless you can see the pain in tattaya's movements he's blasted he's all over the place oh yeah let's go that's a fat w oh but that's not all let's bring it home with a victory lap yeah that's right we can go all day to take over yourself oh that felt good okay another round one more come on come on it'll be fun potato buddy you good and he's gone i don't mind that's another win for good old me okay okay next guy let's slow it down for this guy maybe we went a bit too hard on my man to tell you okay damn bring it on oh no too slow too slow oh no fix it fix it fix it fix it fix it fix it fix it fix it fix it fix it fix it fix it fix it okay not my best work let's go a tad faster by a tad faster i mean full [ __ ] throttle demba thinks he's hot [ __ ] which right now is where we want him let's light him up not a great start i don't know what happened there but hopefully we can recover okay let's make it rain denver is angry denver is confused oh denver is sweating we're hitting him with those rhythmic drops that's the heartbeat of fate you're going down son is that beethoven i hear you wish it was beethoven because then he can see you embarrass yourself why wait wait wait that beethoven was death not blind uh you wish it was beethoven because then he couldn't hear you embarrass you it's not the same and he's not dying why why isn't he dying check the engines i'm giving him all she's got captain oh greatest star trek reference that's just what we needed because using ai to play tetris wasn't nerdy enough like we're trying to bully the nerds not beca and we've lost now wait oh no what shall we do if only there was something that we're working on for the early part of the video that we could introduce into our program to give us the boost we need to give us the boost we need what are you doing we rehearsed this that was your cue to finish cooking the ai and you could even do a little cute little ding sound effect okay it's fine it's fine once again to give us the boost we need ah what could that be wait it's a pie it's not where's the ai oh there it is so uh how's it going what's that you crashed like three days ago oh you pieces okay i guess we gotta re-run it it crashed again [Music] there we go that's what i'm talking [Music] [Applause] [Music] about what's that when i run it in python it slows for some reason okay let's slap on some multi-processing to speed that bad boy up slap what's that what's multi-processing okay well to explain this let me consult the eight ball of infinite explanations okay uh what is multi-processing okay the question is in we're contacting the oracle it's taking a while she must have bad internet and it's a no wow powerful stuff well said anyway moving on with the multi-processing in place the algorithm is sped up to sorry i'm actually not explaining multi-processing i just can't be i'm sorry that's moving on with the multi-processing in place the algorithm is sped up to about two times speed which is more than fast enough to kick some nerdy butt okay let's party oh oh one of them's already left yeah yeah so many tetrises i am here to claim my throne i am king and we're banned oh no access to live games have been permanently restricted you can still play single-player modes that's great there ain't no nerds in single-player modes permanently restricted huh i'm sure this is nothing a fresh new account can't fix there we go and we're still banned okay okay that's fine uh let me try the almighty incognito mode let me just okay um let's clear browsing data and cookies oh no the nerds they'd be hidden back okay come on vpn ah okay i really thought that one would work uh maybe i need a different browser i'll even use edge surely they didn't think anyone would be this desperate oh no damn you god damn you all to hell oh wait i have a second computer if they track me here on a completely different computer then i'm going to call the police this [ __ ] is unreal oh yeah oh that was that was very out of character i'm sorry i don't i don't know what came over me victory is mine well sort of we still got to bully the nerds but we're in okay so yeah that whole thing about there maybe not being any bot detection was obviously wrong my previous algorithm probably wasn't good enough to trigger the bot detection which hurts a little bit but that's fine what's weird about that is that the previous algorithm was actually faster so my guess is that the bot detection uses a combination of pieces placed per second and lines sent to the opponent something like that so my plan is to start off slow and see how fast we can ramp it up before we get banned again and hopefully we can go fast enough to absolutely dominate but slow enough to not trigger the bot detection the plan is simple okay let's start off hella slow okay here we are [Music] okay so haven't been banned yet that's that's good news but the bad news is that this is so boring ah this is the ai equivalent of brains over brawn but i've never been a huge fan of brains so it's time to brawn this bit up and let's go a little bit faster here we go that's such a small change ah wow what riveted content evan [Music] okay let's go ai let's go let's go ai let's go we won all right what's happening okay uh let's step it up another knot the bot detection hasn't caught on yet so we're still good all right now that we're stepping up the challenge let's also step up the challenge that was the [ __ ] dumbest sentence [Laughter] all right now that we're stepping up the ai or not let's also step up the challenge and fight a couple of people at once and this is jayastric's bot room which means we'll be up against their bot some bottom bot action welcome to battlebots in the left corner we have not code bullet we don't know who he is or which programming youtuber he was built by but we know he's here to fight and take home the belt on the right corner we have real block who is known for turning up to fights and totally being implemented ready fight we started and it's just empty cool uh i guess that's a good strategy if it gets no blocks it can't lose ah damn why didn't i think of that it's genius well played geostress you've beaten me at my own game well i guess there are still nerds to bully so i'm satisfied oh two of the nerds have already noped out that was a smart move real block is still holding strong but the nerds are dropping like flies by one minute mark it's just real block and me fighting to the death one-on-one i make a valiant effort but real blocks defenses are just impeccable believe it or not i do eventually get bored of watching an ai fight no one so i start playing myself see if you can pick the moment i take over keep your eyes peeled it's a pretty subtle transition tetris at its finest all right let's ramp it up one last time we're actually getting decently close to full speed here so i'm getting scared the bot detection is catching on okay i want to absolutely ruin someone's day in 1v1s all right who we got tommy how you doing prepare to die let's see how many times we can beat this guy before he gives up and leaves for this one i wanna do something different let's jump into tommy's perspective for this fight [Music] oh [Music] uh seven you can beat someone seven times before they leave tommy held in there though i was very impressed i thought he would have given up after two or three but that last one was killer like god damn it only lasted seven seconds oh that was hard to watch really makes you think huh what have we created uh have i become corrupt with power empathy i'm over it now all right time for some more destruction okay there is one final thing i want to do take on the big boys time to sit at the cool kids table i'm talking the default room scary name an even scarier number of players we're talking 40 plus players i've been avoiding it up until now because i probably won't win but god damn am i ready to ruin 40 people's day at once but while i was waiting to unleash the beast the impossible happened [Music] damn it i know my cover is blown who told them tommy was it you did you betray me it's okay some quick thinking on my part shut down any suspicions detective ryzel123 had we are safe ah damn it what doesn't this man know oh that's really not good i think i'm in trouble i'm getting called to the principal's office oh wait ha ha joke's on you i'm the true winner here i got a friend it's a good day andy banned me first toby now this why must everyone i love betray me everyone i love except brilliant.org who are nice enough to sponsor this video and god damn if that wasn't a top-tier segue i don't know what is brian.org is a problem-solving website and app with a hands-on approach with over 60 interactive courses in math science and computer science and if you haven't noticed yet computer science is kind of what we're doing here except for the bullying nerds part that was that was something else but if you want to learn how to do some of the stuff i do on this channel then brilliant.org is a great place to start a big concept in artificial intelligence is neural networks and what would you know brewing.org happens to have three entire courses on it we've got introduction to neural networks artificial neural networks and machine learning all of these are great courses with interactive elements that make the learning process fun and less about ramming your head against a wall and more about ramming your head into some knowledge so what are you waiting for if you want to level up your knowledge game and support me and this channel in the process then head over to brilliant.org codebullet to get 20 off your premium subscription link in the description wow okay yep that was a video that was a long one i have no idea how long it's gonna turn out to be but it felt like a while for just like playing tetris on a like i didn't have to build tetris in this video but god damn it took a while it just like kept being elements that i needed to add i thought i really thought it would be as simple as just plugging in the old algorithm but whatever it was fun i had to deal with the multi-processing and the genetic algorithm and all that wasn't really mentally prepared to deal with in this video but you know what there you go uh sorry about skipping the multi-processing explanation i was just not at all interested in explaining that i don't know if you actually can't google it but yeah this is kind of a different video i guess i hope i didn't offend anyone with all the bullying nerd talk i hope you understand the joke that this is a computer science channel talking about bullying nerds i was actually feeling bad towards the end of the video with just like how dominating i was being but um yeah it was it was a lot of fun it was a fun video to make uh yeah i actually did a poll to see which video i should do for this video and uh yeah the js just won one and i did it so that sounds like a professional youtuber right that sounds like i know what i'm doing next video is gonna be like a flying sim which was like the second most popular one in the poll but it was real close it was real neck and neck uh that'll be fun that'll be interesting because i'll do that in unity which i have like a little bit of experience but not enough to you know make a flying simulator so we'll see how that goes i'm gonna try and like break it up because this video was just way too long like it's hard i'm torn between sorry i'm just full rant mode at the moment i hope that's fine i mean i guess that you can leave if you don't want to listen to me that's perfectly fine so i'm torn between doing like smaller videos more often or bigger videos less often like i don't know which one of those is better like with this one i kind of wanted to stop halfway through but there wasn't like this really nice halfway point to stop at i didn't think and i already did one thing on tetris so i don't want to make it four-part series or something which maybe i should maybe i shouldn't that would mean i could get videos out quicker which i really want to do i want to get the videos out click i know it's not been great uh you know the old upload schedule it's a bit of a meme at this point but you know i am actually trying to fix that which i mean look at this i uploaded this video in i don't know how long it'll be to like fully upload it but it can't be that much more than a month surely yeah so a video a month is kind of the goal but who the knows i would like to do more frequent than that but i can't program that fast and like this i want to program nowadays is like much bigger my ambition in terms of the scale of the videos has grown which is not ideal but whatever it is what it is uh we'll see how the flagship goes i might just do something else classic me i might get bored of it uh but we'll see uh yeah that's it that's my rant if you stayed to this point congrats thank you i don't know how long i'm gonna edit this down to but there's been four minutes of me just talking and i'm still going all right uh thanks for watching love you guys bye
Info
Channel: Code Bullet
Views: 4,023,107
Rating: 4.9360752 out of 5
Keywords: artificial, intelligence, coding, processing, java, machine, learning, genetic, algorithm, evolution, computer, science, programming, comedy, educational, Tetris, AI, jstris, battle royal, t-spin, devlog
Id: os4DcbpL0Nc
Channel Id: undefined
Length: 31min 16sec (1876 seconds)
Published: Sun Sep 13 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.