Dominating an Online Multiplayer Game using Python and OpenCV.

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
welcome clarity coders in today's video we're going to bought a brand new i o game called fishington.io i had a member of my discord that created this spot the start of this bot it was automated uh casting and catching of fish i wanted to take it to the next level and push the limits of what we could do with this plot and see if we could trigger a ban now as you can tell from the dark hood a lot of you in the discord think that i'm being tracked down or that i'm gonna be banned for my bots or different things like that i'm here to show you it's just the opposite i think they're allowing me to play these games because my bots look like humans and it creates more players for their game a bigger player base so in this video we're going to push those limits and we're going to create a bot to see how long we can run in this game and how blatant we can cheat and see if we get all the riches or if we feel the wrath of the band hammer let's not waste any more time and jump right in [Music] so user brought this to me in my discord and we're going to look at his github here if you haven't go in the description and star this project it was really cool to begin with and we're going to take it to the next level in this video now what we want to do first is we want to grab a copy of his project and see how it works and see how we can improve it i know it can't do a couple things that he talked about that he wants to be implemented so that's what we're going to try here so the first thing i'm going to do is i'm going to fork his github project now what that allows us to do is it allows me to stay linked to his projects so people know where i got the base of this code but we'll be able to add features and add code without messing with his project if he wants to take it in a different direction later so we're going to fork that project you'll see now we have our own copy we're going to go to our desktop and i'm going to clone that onto our desktop you can boot up whatever code editor you want to use i'm going to boot up visual studio code and then let's go ahead and boot up the game as well and take a peek at it so much like your first time playing a game your first time looking at someone else's code you want to figure out what exactly it's doing so if it has a nice documentation page you can look at that if you know the individual you can talk to him i talk to him on my discord a little bit and start learning how the code works also for us we need to start learning how this game works so what i know about this fishing game is it's made by the same company that makes betrayal which is probably the most popular knockoff of among us i don't want to offend people i don't know if it was first or not i assume it was after among us but it's kind of the same idea so they created this game where you can catch fish very relaxing collect them try to get bigger fish try to get more money and better gear so as i boot up this game we're just gonna get started with a game and see what we can learn from it so first things first we got to pick a name now i want to make this obvious so i don't mind connecting it to my youtube or them knowing that i'm a bot so i'm going to go ahead and do youtube clarity coders or something along those lines oh and it won't fit so we'll just do youtube cc now i'm obviously not famous so no one's gonna know what the hell that means but we'll stick with it anyways now as we start the game we're going to learn some of the mechanics and then we'll go over the code so the mechanics of the game are fairly simple you're going to click and hold to cast so you're going to click and hold it'll start the bar and then when you let go of the mouse button it's going to release and throw you can leave your bobber in for what appears to be like 20 something seconds before it pulls it in automatically you can also pull it in at any time by single clicking if you catch a fish it'll make this little splashing animation and you can single click and it'll pull it in now one thing that i noticed right away that we might be able to use later is the fish will stay on the line when it's splashing for quite a bit of time so we have some time to work with there now if you look at his code and i've been talking to him a little bit so i know kind of how it works it's able to cast so it's able to throw out a line and then catch fish automatically now the issue is that he said out of the gate is it doesn't work very good on other people's computers because he's using exact pixel values so the cast mechanics don't work at all on my computer however right out of the box the bobber does appear to work and it can catch a fish but we want to fix both of those issues so the first thing we're going to do is make sure that we can locate the bobber and then it works on everyone's screen and we also want to make sure the fishing mechanics themselves work now my goal here was to create a bot that's a little ridiculous over the top obvious that it's a bot or cheating so my goal is to fish for at least 24 hours straight or more and see if we can either gather all the resources catch all the fish or if we get banned so the first thing we want to do is create a dynamic way of finding where this catch meter shows up so we can use it to catch the fish now the catch meter shows up and you click and hold to move the bobber to the right and it's got to be within inside the green for your catch bar to fill up when you release the button the bobber moves back to the left so you're trying to keep it inside of that green area so we're going to dynamically find this bobber and then update the positions that we're taking our screenshot for this bobber catch opencv window so we're going to grab this when it falls all the way to the left we'll use paint and we'll copy and paste it and then we'll use some template matching and after all that we have the ability to update these two values and make our screenshot dynamic so now it should work on anyone's computer now already you can tell that this file is a little messy so we have our entire bot all inside one file i'm gonna break out our bot code to be in its own file for a couple of reasons so i'm gonna create a class and another file that'll be our bot and we can put all of our bot functions in there then inside this main file it'll be just like a driver program so it's just going to decide when the bot runs when it fishes when it sells things like that now because we're separating this out we can actually run our own tests on just the bot when we're implementing new code so i'll explain that with one of the biggest improvements we need to do in this program so in order to fish for 24 hours straight you'll notice that our basket can only hold six fish now you can upgrade this basket over time but no matter what the basket has a limit so what we need to do is we need to be able to sell our fish on the fly so we need to be able to go to go up to the market press spacebar then click through these menus so we can select fish individually or as i found out later you can hit the select all button and then sell the fish now the beauty of putting this class in another file is we can test it without running the rest of the bot code so as we implement this fish menu which we're going to use template matching just to click these buttons again we can test just the cell portion and you'll see here that it seems to be working pretty good now if you don't understand classes and you want a more detailed tutorial click on the link above it's one of my it's actually my very first tutorial on youtube it's about classes it's actually pretty good go ahead and click that and check it out now the casting was broken when i used it on my pc now i'm sure it worked on my discord user's computer i'm sure it was working for him and you can see in the gif that he posts there that appears to be working but on mine it wasn't so so we're going to make it a little more dynamic and a little less reliant on individual pixels so what we're going to do is rethink the mechanics altogether now we could do template matching and see if we catch a fish and blah blah blah and all these fancy things but something i've noticed and we want to keep this as simple as possible anytime we're making a bot we want to keep it as simple as we can so we don't want to jump to ai we don't want to even jump to template matching if we don't have to in this case if you'll notice we can just cast wait 10 seconds and then pull it in one of two things is gonna happen in that case either we will have a fish on the line and we can go into our catch mechanics or we don't have a fish on the line and we can simply cast again so our fishing method is as simple as that we're just going to cast out a line wait 10 seconds and pull it back in over and over and over and over again so with those two improvements made we basically have our bot upgraded now you know how talented i am i'm no uh i'm no code bullet so this isn't gonna take a hundred tries i'm probably gonna get it on my first chance so i went ahead and with this in mind i set it up to run overnight and i called it good as you can imagine i had great excitement the next day because i was excited to tell my discord user how great the new bot was and how i'm gonna make this awesome video for him that he can watch but when i got to my pc this was the screen i was greeted with now originally i thought wow we did it right either we caught so many fish that we got banned or the server died or something like that i was very disappointed when i reviewed the footage to see that i had something wrong with my cell mechanic so it wasn't actually selling the fish now i went down a dark rabbit hole so i tried using some different libraries to click because i thought the clicks must be off somehow or they must not be registering when it was trying to sell the fish and if you review the tape it's just inconsistent right he goes there then he leaves and he comes back i don't know the boss all over the place so i added some libraries and did some unnecessary work and tried to find the problem i started the bot again i left it for another night running and i awoke to the same damn message now it's a code bullet video so i really had to dig deep in my programming because it worked when i tried in the class but it wouldn't work when i would run the main bot program now this comes to our discussion of threading so one thing that my discord user implemented right away that i continued with was he had a thread for the computer vision cat catching mechanism and he had a thread for the fishing mechanism and i stuck with that idea now what threads allowed us to do is it allows the computer vision to work at the same time or appearing to be at the same time as the fishing mechanic so when we throw our line out and wait 10 seconds it would normally freeze our camera but it doesn't in ours because we implemented threading while threading is great and it solved an issue with our program and being delayed and looking uh blocky it caused an issue i forgot that it was still trying to fish while i went to sell our fish at the market so it was randomly clicking spots on the screen which threw off our menu but only when the full bot was running if i run the standalone class the cell mechanics work perfect so all i had to do was say hey if we have if we're full of fish and we're going to sell stop fishing right we can't fish anyways so once i did that i was able to run the bot get it set up and we're ready to test again now let's start this test and and see what we get going here as you see we catch a lot of fish and we're passing a lot of time i left the bot and kind of came back to it at different times and we're already in the lead in the on the top of the leaderboard and different things like that for some reason at different times my bot would close the leaderboard i'm not totally sure how it was doing that but somewhere it must have been clicking on it but we continue on now if you waited this long i got a story for you we one thing that spurred on this video or this idea of getting banned i guess are trying to get banned was a conversation that i had with a company of my most popular video so if you haven't seen it i have a fall guys video out where i create ai that plays ball guys now i had a lot of comments on that one about getting banned and different things like that and actually what i experienced was exactly the opposite eight months after i released it i actually had mediatonic the developers reach out to me and asked me to work on a contract with them to implement more of my bots presumably that's an assumption by me but they wanted me to work on a contract i declined but it it brought something to light some of these games want extra players they want a bigger player base so if i make a bot that looks like a real player and no one can tell the difference that sounds great to them but we're pushing the limits here as you can see here we're moving into the territory of not a human right i seen a couple of fishermen that had caught a couple hundred fish but that was pretty much it you can see now we're pushing the limits with a thousand and up now the one thing that made this spot so powerful was its ability to sell the fish and keep progressing one thing that could happen and did happen to our bot is once we got up to the thousand mark and we were crushing it we had fished way over 24 hours so we accomplished our goal didn't get banned caught a ton of fish made a ton of coins and resources in the game but eventually chrome the little pig died on us probably because of memory or whatever and the game stopped playing so one thing that you could do to improve this bot is implement some type of feature that refreshes the web page after so long or even deeper maybe you could close out a chrome and reopen it that's a couple of options if you beat my score if you catch more fish let me know in the comments in the discord somewhere and i will surely give you credit in the next video if you want to learn python from scratch click on the link above i'm doing a full tutorial series if you're like wow this is cool but i can't do it myself that's what i'm going to teach you right jump into this course stick with me we're covering everything in that's it for now if you enjoyed this video leave me a comment below and until next time keep coding you
Info
Channel: ClarityCoders
Views: 179,486
Rating: undefined out of 5
Keywords:
Id: X2bRXcCvmKY
Channel Id: undefined
Length: 14min 31sec (871 seconds)
Published: Wed Sep 22 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.