Beating BTD6 with AI

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments

Credit:b2studios

I've always loved AI and machine learning and how it learns to do things in a way humans normally wouldn't conceive of. So I thought this would be an interesting video.

Hopefully the uploader will refine the algorithm and maybe test it on different maps. Curious to see how the strat differs from human players.

👍︎︎ 2 👤︎︎ u/TenFortyMonday 📅︎︎ Aug 24 2021 🗫︎ replies

Thanks a lot for sharing. No idea it could be done in btd6, that's truly motivating to discover AI through something you like.

👍︎︎ 1 👤︎︎ u/Minuy_ 📅︎︎ Aug 24 2021 🗫︎ replies
Captions
this is balloon star defense gameplay except something isn't right there is actually no one playing this game well at least there is no human playing this game this entire playthrough was done by an ai and it's managed to reach wave 63 all by itself in fact it's actually quite formidable this begs the question how is this even possible well bluestar defense is a game that requires a large amount of skill with an emphasis on reflexes twitch aiming and positioning now if i want to program an ai i'll need some sort of way of interacting with the game with that human input if i can give a program control over my mouse it will be able to perform any function necessary to complete the game seems simple enough let's give it a shot now this program should click its own close button after a few sec what joke aside overriding the mouse control was quite trivial and i didn't struggle with it much now that we can press buttons let's give a simple drag and drop mechanism a go i want the ai to place one dart monkey so first i'll need the coordinates of the dart monkey button and then i'll need the coordinates of the tower's destination to get the coordinates i screenshot the game put it in paint and put my mouse over the locations i wanted to remember now i can tell the program exactly where to move the mouse let's code this in practice this works really well in fact this ai can place down a dart monkey in just 60 milliseconds if we add in the ability to press the start button we can now pass round one human free excellent let's see how far this ai can get i don't think it knows the round ended it's no surprise a glorified macro can't read but it is a huge problem up until this point there has been no reason to interpret the values on the screen but now it has become a necessity if you want to know if you can afford upgrades in towers you need to read money if you want to know if you've lost the game then refer to the life counter this solves a large amount of issues with the ai but we still have no answer for detecting when the round ends a hidden feature of the round counter is that it actually goes up the moment the round ends while this isn't reflected by the display we can see the change if we save and re-enter the current game only one question remains now how do i read those values the best way to read the values is to extract them from the processor's memory yes i know this is technically hacking but i'm not altering any information and the information i extract from the process is available to humans from the display so as far as i'm concerned this is legit anyway if i want to read the values then i need to know the addresses if you don't know what memory addresses are they're like real addresses memory addresses hold values and numbers say like a man who waits at a house to give you his number when you arrive sometimes this can even be a new address which can send you on a small treasure hunt until you finally reach the prize with the help of an app called cheat engine i was able to locate the values i need and by extension i was able to build a map of where each of these values lied relative to each other you can think of this as a suburb that you know back to front if you know one address you'll be able to find all of the others it turns out this concept is crucial to the success of this ai because this metaphorical suburb is constantly teleporting such as the nature of the game's programming language c sharp luckily at an entry point the money value whenever you enter a new session in bloom's tower defense money is always equal to 650. i was exploiting this fact by using cheat engine to scan every address and code until i found that value since 650 is a very unique number for a variable it is almost always the money address after my a millionth time of doing this process manually i realized i could automate it and with this automation my memory system was finally complete so what else does this ai need to know to function oh that's right the prices so many prices there are 23 towers in the game and each one has 15 possible upgrades and since each difficulty has its own set of prices we have to add up each unique set resulting in 1450 price values i had to enter most of these values in manually and it was not fun besides the costs the ai also needs to be aware of the rules of upgrades so things like only two parts can be upgraded at once only one path can be upgraded more than three times don't upgrade a buccaneer to a trade empire things like that there's also a special nuance that needs to be taken care of the upgrade menu can appear on the left or the right hand side of the screen depending on the tower's location practical for game design not practical for our ai at this point the ai has gained enough features to be capable of completing a playthrough without any human assistance apart from strategy of course as you'll see soon to start out with i defined a simple strategy for the ai to follow place as many ninja monkeys and cannons as you see fit then i throw it into the map town centre on easy and let it run wild and boy did it run wild the ai showed a strong sense of initiative and well thought out placements easily blasting through the first 39 waves without losing a single life but it was ultimately overpowered by a single moab balloon however it was not done yet after changing the map to monkey meadows and allowing the ai to place dart monkeys i was once again blessed with more brilliancy the ai repeated the success of its first run and made it up to wave 40 for a second time and once again attempted to deflate the moab the moab stormed through its defenses taking heavy fire from all directions but it was not budging and our ai looked doomed to meet the same fate as its first run but i underestimated the ai's resilience expertly using the life counter as a buffer the defense has cut the mob down just in time to absorb the punishment left over our ai had taken a huge punch but it was still standing at this point i was almost satisfied with the ai's achievements but i could tell it was destined for greater things i decided to round the difficulty after medium and gave the ai full freedom to place and upgrade any tower it wanted with its new capabilities the ai climbed higher and reached way 59 on his first medium run this time it was not foiled by a moab but by an unrelenting wave of regenerative balloons that multiplied and promptly bulldozed their way through the fences despite sword's best efforts this is commonly referred to as a regen farm by experienced players a regen balloon can split into multiple parts if it is allowed to regenerate each part will grow back into its original essentially creating copies of itself the ai dealt with this on a second run a bit ironically by using one of the only manually controlled towers in the game to do the majority of its damage using this peculiar strategy the ai went through the remaining waves with ease deflating the vfb and claiming its second victory against the game on the hard difficulty but ai opted for more dense defenses placing more towers than before which led to some interesting behavior as it tried to squeeze everything into place yeah but once again the ai managed to power its way through every single wave destroying the wave 63 ceramic spam and the wave 78 camouflage span then after a large struggle with the z omg took that down too only one more goal stood in its way chimps at this difficulty the game has become so hard that merely placing random towers will never be enough to win it was time for the ai to gain its final ability a brain you might be wondering how it's even possible for a program to learn things consider this digital fish it must eat food to survive if it eats enough it reproduces if it doesn't it ceases to exist the fish vary in speed which is determined by its genetics fish carry their genes onto their descendants sometimes with slight mutations let's see what happens if we chuck these fish into a tank with a steady supply of food at the start all fish are quite slow and all is peaceful however as we observe the population 15 generations on we can see a notable change in their behavior if we look 30 generations on this change has become more prominent than before and at generation 60 they have become absolutely savage heat-seeking missiles while i didn't force them to become faster they just did simply because the faster ones were able to survive longer the balloon's ai will work in the exact same way except instead of fish we try several different strategies then we will use the one that gets the furthest to create several new variants we repeat this process indefinitely just like in the fish simulation until eventually the strategies become strong enough to be chimps i i use this technique for weeks upon end until finally it came up with the winning strategy our aio's defense starts with sorter placed between two different tracks always a solid option it later expands with an engineer monkey and surprisingly remains idle until wave 28 where it upgrades the engineer just in time to deal with the lead balloons during waves 30 and 40 the ai was quite satisfied with its distribution of towers and decided to start ramping up its damage output by placing a super monkey the ai soon encountered his first moab and promptly destroyed it with little effort between the mortar the engineer and the ice tower the defenses were already becoming quite stubborn during race 40 and 50 the ai started preparing his towers for major upgrades the ice tower was given a big boost alongside the super monkey money was starting to accumulate fast and the balloons were not making the defenses pay for it on wave 60 the ai decided to intimidate the bfb with housing which was quite effective wave 7380 was smooth sailing and the ai was showing success with some pretty unconventional strategies but the ai knew there were bigger fish to fry so it saved 40 000 to upgrade its first tier 5 tower of this run this alone was enough to stop ddts in their tracks scraping just enough money together the ai bought its second tier 5 tower before wave 95 this allowed her to deal with large clumps of moab class balloons with ease the bid was tricky it needed to be damaged and fast the ai failed over and over again trying to destroy this behemoth but it eventually found a solution the extremely fast sniper monkey would eventually wear out the bad and with the combination of the ice tower the bag took more damage than it could handle and the defenses slammed the door shut on any hope the balloons had to make it to the end victory was victory was ours and with that final achievement that concludes this video [Music]
Info
Channel: b2studios
Views: 377,638
Rating: 4.9696183 out of 5
Keywords: bloons tower defence 6, bloons tower defense 6, btd, btd6, btd5, btd bot, btd ai, ai, bot, arthur, is, stupid, bloons tower defense ai, bloons tower defense plays itself, plays itself, bloons evolution, kanye west, b2studios, games, video, video game learning, ai btd6, c++ bloons bot, how to make bloons bot, lazy bloons tower defense, bloons td6, bloons td 6, bloons td 5
Id: QoEMoSbGvbM
Channel Id: undefined
Length: 10min 39sec (639 seconds)
Published: Fri Aug 20 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.