imgur.com/a/PltFdMu i imagine it could look something like this... it took my computer 5 seconds to solve the field. to be fair, i had to tell him to only open safe clicks, else it still would search. also what am i doing here
Yes please. And dont use a grid just colorcode all the possible stats (undiscovered, discovered, marked, 1-8, bomb) so the result is just a FullHD image with colores!
Your ai needs more parameters. There are many situations in which the ai picks randomly when the location of mines can be deduced by numbers not directly adjacent. A human player can solve maps with many mines consistently where your ai tries and fails dozens of times before finding a map easy enough to be solved without more complex parameters.
@@peepock7796 Maybe? We don't know how exactly he computes which squares are more likely to have bombs. If it's pure brute force then I guess it would always work.
@@NXTangl There is no way, for a human or an AI to ALWAYS win. Even in smaller configuration with only a few mines it's possible that they form an island where you don't know how the interior might look like. A common scenario you can think about is a 3x4 area that has mines at the perimeter (10 mines) so the middle 2 squares are unknown. Imagine you're only missing one mine. So you have a 50:50 chance since there is no way to know or determine which of the two unrevealed squares contains the mine. In larger grids with more mines this can happen even more frequently. Having 2 configurations of 3x3 (8 mines surrounding one square) it's also impossible to tell which of the remaining unknown center squares have a mine. The only way here is brute force. Of course you should keep those undecidable squares for the end as this could help to figure it out. Maybe all those undecidable squares should be mines in which case we know all of them, or they should all not contain any mines because you already found all. However any case in between requires guessing There are more cases than the two I mentioned which are undecidable.Though it usually boils down to some variation those cases (apart from even larger cases where a 2x2 area is enclosed by mines). Note that when two unknow squares are surrounded by mines, it also doesn't help when the perimenter has holes at the long sides. because if there's only one mine in there you don't know which one. In the end the game is a gambling game since the distribution of mines is random. Yes the original minesweeper ensured that the first click is never a mine, but that was the only adaptive part of the game. The grid is either filled with mines after the first click, or if the first click would hit a mine we can swap the mine with any free square during the click. As far as i know he actually considers all information available and actually does a probability distribution between undecidable squares and picks the one that has the least likely chance to contain a mine. Of course all decidable squares have naturally a 0% chance. Have you actually seen the first video? th-cam.com/video/cGUHehFGqBc/w-d-xo.html
@@Bunny99s Well, there were definitely grids that the AI gave up on which had squares that are easily determined to not contain a mine, so it demonstrably does not consider all information available.
@@joeo3377 Well that is hard to tell from the video as there are something like 3 to 6 actions per frame. Yes I found some edge cases (specifically involving 3s and 2s) where it seems that it has not considered them properly as "linked cells". Though as I said it's actually hard to tell as in most cases you don't even see the "failed" configuration as too many steps are missing in between frames. Currently I don't have the time nor do I want check the code as it's quite a mess to follow the logic ^^. However if you think you can spot the issue, feel free to have a look: github.com/Code-Bullet/minesweeper-AI/tree/master/minesweeperAI
Can you try creating an infinite grid with a fixed amount of average bombs per 5x5 grid and letting the AI solve it till eternity, or until it dies? And I you can do that, how much average bombs per 5x5 grid is necessary for the AI to lose under five minutes or even five seconds? I'm basically asking you to force your AI to an eternal prison of minesweeper lol
I think the only thing you are missing is that most of the time there are multiple squares with the same lowest chance of being a mine. Some squares are likely to reveal more information than others. Perfect example is at ?t=50s . Although 591 of the 600 squares all the have the same chance of being a mine (96/591=16.2%), they do not have the same chance of revealing useful information. A middle piece like the one selected only has a 19.9% chance of being a blank. An edge piece has a 34.3% chance of being a blank and a corner piece has a 49.1% chance of being a blank. This info is knowable and should be used in a prefect program. Below is a spot where you are forced to take a guess. 4 of the 9 remaining squares all have the same odds of being a mine (1/5) but your chances of winning clicking differ greatly between those 4 squares. One square will always give you enough info to win while the other 3 will force you to guess again. The total future risk can be accounted for in many cases. 4 mines left in this 5x5 toy game. All the outside border is known. the 9 interior boxes are unknown. (M=mine, 3=touching 3 mines etc, and ?=unknown) 4 mines left Try to solve yourself or with your program. M 4 M M M M ? ? ? M 3 ? ? ? 3 M ? ? ? M M M 4 M M There are 5 states the mines can be in and 4 boxes have equal probability of being a mine. The portental information revealed makes one of the boxes a much better choice then the others. (you lose half as often when picking it) Can you pick the box that is the best choice?
A simpler example is the 2x4 grid B3B? / ????, with a total of four bombs. Guessing one of the two right-side squares has a 50% chance of instant kaboom, but reveals enough information to win otherwise. Guessing one of the three other squares will have only a 1/3 chance of instant kaboom, but won't reveal enough information to win without taking another 50% chance.
if im right its between the top right and middle right, im going to guess top right of the four mines two are among the bottom three squares, leaving two mines for the remaining six squares. one is adjacent to the 4 on top, leaving one mine between the middle row and top right
The thing I love about Code Bullet is he would rather sit there watching his inefficient code take an hour to process than spend 20 minutes making it more efficient and having it complete in 5
Code Bullet: "Absolutely no one asked me to increase the size of the grid even further. So I did that." Me: * immediately clicks the like button because I hadn't already done so for some bizarre reason *
AIs that learn by using evolution technically already do that. Hundreds of players are created, and the one that does the best "wins" (or is the one to evolve). But, I do see what you mean, that is a good idea :P
I'm sure he's thought about it but he's then shrugged the idea off because it was a bad idea because being AI's if they're programmed the exact same way (except one is to use another character or thing) then they'd just end up with the same results
I know this is an old comment, but if you're still interested in this type of thing, there are communities that regularly program AI for multi-player online games and pit them against each other. One of them is a channel on twitch.tv SSCAIT (Starcraft student AI tournament) which is continuously playing Starcraft: Brood War games against fellow AI's, 24/7. These are generally NOT self learning bots, but people update their bots every week or so, and they're always improving.
Watching the perfect algorithm fail on its first click makes me feel much better about my playstyle which also has me lose in the very first or second move most of the time.
@@EGarrett01 Yes, in the original Minesweeper; it generated a board. But if you clicked on a bomb, it would regenerate the boards until there no longer was a bomb there. Newer Minesweepers might be more effective (like just moving the mine).
that would actually not be that hard to code because of the simple rules of UNO, but what would be hard is everything that a highly intelligent mathematical genius would be able to do - calculating the probabilities of people having certain cards, and utilising this knowledge to be able to statistically win more games than anyone.
0:19 - "A lot of you guys." Sigh... of course you'd be dealing with people who have watched a TED talk about neural networks, telling you why the AI algorithm _that you wrote_ isn't AI. AI is a relatively simple thing to define. AI are autonomous entities, capable of taking in input and performing a desirable action, that are based on conditions that it has been given. In this case, we have a Minesweeper bot, that has been given the goal of clearing a level of bombs. It does so admirably and is clearly an aspect of AI.
Well, yes. If all forms of AI are inevitably going to take over the world, as many like to believe, then your roomba is destined to be your future overlord.
Neural Networks are a form of AI, It tries, fails, replicas the most successful and attempts again. What do you think our brains do? It fails, then tries again and whenever it works, it retains that connection/method and builds off that. Self learning, so sure this programs not about to figure out self automation and take over the world, but its a self learning algorithm that can be applied to literally everything and has been. From Healthcare to games, its doing a much better job than Humans in a lot of examples. Like diagnosing people, we give it all the information and 90% of the time its diagnoses is correct. AI? Sure it is, AI is pretty Broad. Even "Siri" is considered AI but in reality its just a program that recognizes the input and outputs the most relevant information. But again, thats all we do isn't it? We take the input and then output a response.
It doesn't apply to any computer program, if they are not autonomous. It's the difference of a remote controlled vacuum and one that periodically goes around your house for you. A remote controlled one waits until it receives a signal to move. The latter one follows an algorithm that maps out your floor automatically. But the latter one does not need to use neural networking to do so. There are vastly more efficient methods to do so.
I was wondering about this one, there was no real display of the fail points... I hate slowing down something accelerated. I guessed there were easy fails in this so called hard coded candy.
Thanks for showing what an increased bomb density does. It's fascinating to see how the difficulty increases seemingly exponentially as you increase the bomb density.
Would love it if you did like a short explanation on how you calculated the probability for the squares, not like an in-depth code tutorial, just some pseudocode. Also, I define artificial intelligence as any program that simulates learning.
The explanation is that P(bomb|tile) = Number of possible arrangements of bombs in which the tile contains a bomb / number of possible arrangements of bombs An arrangement is impossible if it violates a number tile.
Yeah, well I guess I wasn't clear enough. That simple probability is easy to think of, but that would be wildly inefficient, and can't be the way that he did it.
rosen. Nope. Minesweeper is NP-Complete. So bruteforce is the only known way to go for perfect play. You're underestimating modern hardware a bit. Only caveat is that I'd imagine for speed you'd want to be using a GPU to check all the combinations, maybe write that part of the code CUDA or whatever. Small edit: Oh... and of course you can use simpler rules for finding 100% safe/bomb spots. So check them first for obvious safe/bomb spots, then brute force when necessary.
I love how you can appeal to both coders and non coders, by explaining the coding, and by making something interesting. Thank you, and keep making these videos
Im glad you asked for my definition so here I make on up on the spot notifying you that I spend some time on the topic. The issue is with the word intelligence of course. Artificial we call most things made by humans, say "fake copies". For me, intelligence is a system within a system that makes the system stable. People are very fast labeling their algos as AI's. The closest we got to AI (in my opinion) is amazon echo. Check out its language abilities on TH-cam for more. (Horrified Amazon Echo Users Say Alexa Has Gone Creepily Insane while Laughing) Ok now back to video ;D very cool channel glad to find it (at 5am) PS.: making an unconventional Computer in Minecraft, video will come soon, might be of your intererst CodeBullet Cheers
Making the grid bigger makes it *easier* for the AI. Whateer increase in computation time there is, it would be worse for a human player. And the difficulty is best measured in Size/Bomb ratio. And once you go past a certain bomb ratio, it stops being a game of skill and becomes a game of chance.
i am so happy right now, because as far as I know, no one has asked about the song name, that means you actually have good subscribers unlike other youtubers
I see you always let it start in the corners. Why? edit: Okay, I've read some of the reactions and I think I know now. The corners do not have a lower probability of being a bomb. The only advantage I can think of is that because there are less tiles surrounding a corner there's a higher chance of having zero mines around it. This opens up more tiles, giving you a point to start from instead of having to take another guess.
You are more likely to hit a 0 so you uncover multiple squares. I pointed it out in the comments in the previous video. Weird that he didn't mention it. link explaining further. www.minesweeper.info/wiki/Strategy#First_Click
I guess it's probably because at the beginning all squares have the same chance of being a mine so the programm just starts with the first one in the array ([0][0])
I have played a lot of minesweepers, and the main reason I always start in the corner is that the corner is the place where might get a 50/50 chance and have to guess, which could mean that I might lose all the hard work I have done throughout the game. If I just start in the corner first, then I don't have to deal with this choice at the end.
Muranski's Expert Minesweeper WR is one of the most amazing records in all gaming - when you realise just how exaxctly perfect his choices and execution are. It's stood the test of time, too.
I agree with your definition of AI, but neural networks are cooler in my opinion. I like watching what the computer determines is the best way to win over time.
Neural networks are great for pattern recognition and has been improving image sorting algorithms immensely. But it's not a cure all for everything. For example, A* search is a much better alternative, if your problem is about path finding.
Just skimmed through A* on wikipedia, seems similar to Dijkstra's (as it says on the page), which I used on a homework assignment last semester for a computer science. I would agree that a neural network would certainly perform much less efficiently than this algorithm. I'm guessing the major advantage over Dijkstra's is the heuristic step? That would allow the algorithm to aim the path towards the goal rather than radially expanding outward.
That's correct. How far are you into computer science? I'm sorta surprised that you've been introduced to Dijkstra without your instructors mentioning A*.
I'm currently about to finish my third semester in the program (I'm a semester behind as I started in Physics and added the dual major). The class I was taking was data structures, and the assignment was tied to the directed graph data structure (we had a choice between adjacency matrices and using pointers, can't remember which I used). I'm currently in an algorithms class and a theory class (I really enjoyed going from regular expression to minimum state DFSA's).
Are you sure your AI is perfect? For instance, when faced with many squares that are equally likely to have a bomb wouldn't there be a square that is strategically better? e.g. squares more likely to give more useful information for future turns.
It is a simple program - no AI involved, and ye,s you are absolutely correct - it can be improved as it does not consider what choice leads to a better outcome in the long term: before it would take a single 50% chance to lose it would take a 49% chance hundreds of times in a row considerably lowering its chances in scenarios where it has to rely on chance.
Huh, I didn't consider that. I was just thinking that in situations where you have multiple choices with the same probability, deciding which is strategically the best seems awfully difficult. But you're right, it also seems plausible that in the long run there may be instances where the best move (The one most likely to lead to a winning game) isn't one with the lowest odds of you losing that turn. Like if you have a choice between say, a 50% loss square that gives you allot of information for later turns, vs a 49.99% loss square that will give you little information.
There is some technical words that easy to confuse here. AI : Artificial intelligence - software that show intelligence like people do. So hard code is still count as AI Self learning AI : Basically and AI that can improve it self. Self learning AI make for something programmer don't have concept to hard code. By leaning to statistics. Newron network AI : one type of Self learning AI design. Self learning AI will take more processing power it may better than this logic base AI at finish the game. But because it will take much more processing power it will not run as fast.
Code bullet i just wanna say im really enjoying watching these A.I videos and keep thinking of when yours will get to the point of playing Mario successfully or wait for it a larger title like halo, battlefield, Call of duty, etc
Also, for the people who say that learning is necessary... one could argue that this system is learning more about the mines over the course of a game. As it clicks, it obtains new information, and based on that information, it updates the probabilities it assigns to different things. This could be said to be learning?
I believe what's slowing it down is not the AI but the drawing and where the AI gets its information from. Without any of the restrictions of drawing and a smooth feed to the AI (I.E, not having to iterate the whole board) the board could be cleared in a few milliseconds. Even your 128x72 tile board.
just found this channel and it is AMAZING keep making videos my dude (and get a mic filter will make the videos seem a higher quality and make you more of that sweet sweet youtube money)
(Sees notification) YAY!!! Code Bullet is doing TH-cam full time now! (Watches video to 0:12) You have got to be kidding me. That guy should have made over $250.
I have a question. Why do you have to literally remake every damn game you make your AIs play? Or do you _not_ have to do that, and you just do that because you want to? Don't get me wrong, it's cool that you go that extra mile at all, but I've seen people who work with AI (both of the hard-coded and the machine learning variety) that usually _don't_ seem to do that, so it struck me as unnecessary. lol
Because it's easier and faster for him to build in the AI into the game, that can read the data directly from the game, and do inputs directly into it. Still, the AI is not cheating, because it can't read data it isn't given. - Having the AI play games that he hasn't built requires screen reading, and/or memory scanning, which is a much slower process. This is not good if he's going to run 500 entities playing the game, or games requiring more direct and exact input. It also requires analyzing the data, and there can be errors in that too. - The best videos he done on this topic are the ones about Pong and Storm The House, where he actually use screen reading.
Hey, had an idea to make it better. It looks like the AI never starts in the middle of an unclicked patch. Maybe add a line of code for when the probability of clicking a random square in there (bombs remaining/squares left) is less than the probability of clicking one of the known probabilities? This would increase chances of success for high density minefields :) Anyway, love your videos as always, love the art and narration man
This algorithm has many faults here is a list of moments your algorithm gives up a guessing when there are still moves. Here is a screenshot with my clearance from 3:38 i.imgur.com/IQeIL6g.png It has already guessed. Here is another screenshot. It has guessed more than 4 times already. i.imgur.com/J3sGOeh.png from 3:42 3:38 bottom right looks like this, reduce the speed of the video if you are looking for the mistakes. ? ? ? ? ?3 1 1 ? 1 00 ? 1 00 You fail and restart 3:40 bottom right again. ?MM ? 3 2 ? 1 0 You die before you solve it. 3:40 bottom right again ? ? ? ? 2 1 ? 1 0 Another solvable you ignore. Please stop calling this algorithm Perfect. Once I called you out in the comment section from not starting in the corner last video. You changed to starting in the corner this video, without even mentioning the change.
Exactly - these kind of links must be done to be able to beat best human players. 20y ago on fairly low level C-programming course we had task to write algorithm-based minesweep solver (communicated via stdin to mineserver and if you guessed and opened a mine you got rejected) where I did this kind of chains like dual-1's are stating there is one mine, so another 1 is telling it's adjacent square does not have mine. And -20y of Moore's law our algorithm were solving large minesweeper fields sub-second timeframe (we were competing with speed and how much you can solve). So video poster's current AI evolution is really not that impressive. Also where to start board? By minesweeper definition your first guess is always guaranteed not to contain mine. So you get coordinates of first guess, initialize board so that there is no mine and tell result. Problem is that if square reveals "1" and you have 9 unknowns around it you must guess. But on above programming course it was forbitten to guess so that "1" was the solution.
In almost all real boards, you can count the number of combinations without iterating through all of them; but you have to do it in a clever way. Consider unrevealed tiles "constrained" if there is a revealed number in their neighbourhood, and "unconstrained" otherwise; let n be the number of unconstrained tiles, and m be the number of mines whose positions are not known. Then if there are k mines in the constrained tiles, there are (n choose (m-k)) combinations of where the remaining m-k mines can be. To count how many combinations have a mine at each constrained tile: - let constrained be a dictionary mapping constrained tiles to 0 (initially) - let unconstrained be a dictionary mapping integers from 0..m to 0 (initially) - let total = 0 # total valid combinations - for each k: - - for each valid combination of k mines in the constrained tiles: - - - let c = (n choose (m-k)) - - - update unconstrained[k] += c - - - update total += c - - - for each tile p where a mine exists in this combination: - - - - update constrained[p] += c Then, the probability that constrained tile p contains a mine is constrained[p] / total. The probability that an unconstrained tile contains a mine is (1/(n*total)) * sum from k = 0 to m of (m-k)*unconstrained[k]. Even iterating through all combinations of k mines in the constrained tiles is unnecessary, since we only need to generate valid ones, this can be done with a backtracking search rather than by generating all and rejecting invalid ones. If you're even cleverer, you can split the constrained tiles into independent sets which share no local constraints. So, I have no doubt that an algorithm can follow the strategy outlined in the previous video efficiently enough for these board sizes, although given the errors Timothy noted, I suspect CodeBullet's algorithm doesn't really follow this strategy exactly - perhaps it estimates the probabilities by a Monte Carlo method instead, or perhaps it is just buggy.
And the algorithm does not look forward. That is needed because of this situation. Imagine that it has to take a risk, you can choose between a small and a big risk. If it takes the small one, it still has to take the bigger one, but if it takes the bigger one first it will get enough information not to have to take the bigger one. The AI will go for the smallest risk, but that is not going to help it. This situation is a bit hypothetical but it does illustrate how anticipating possible outcomes is an essential part of a perfect AI. The only way I could think of to solve this is make the AI calculate literally every possible game of minesweeper (you could eliminate some possibilities, but the number of games the AI would have to consider would still be astronomically high). It is probably infeasible to do this with nowadays' computers, the same way the perfect chess AI does not exist.
But most of the time there is a definitely-safe move requiring no look-ahead, so on reasonable difficulty settings a complete game doesn't require very many guesses in total - the search tree is not very deep. Also, you don't need to play out games all the way to the end if you know they already took more risk than another variation did; and deeper branches mean more guesses, usually meaning more total risk, so you're more likely to be able to prune the parts of the search tree that are deep. I think a branch-and-bound algorithm, combined with an optimised probability-measurement algorithm (like I described above), would be feasible.
Thing is there is no real way to apply the ai to another running program cause the capabilities of Processing don't support that and if there is a way it is still simpler just to reprogram these simple games
processing has the robot class that can take a screenshot and click, and you can determine which number of bombs there is by the color of the number, So it's pretty easy to implement a function to take a screenshot and spit back an array with the number of bombs. Though, when doing an AI you are often remaking most of the engine anyway, so it's not a lot more work to put a gui on it.
Yo I stumbled across your channel last night and I have already binged watched every single video. I'm a highschool senior who's going to study cs and NEAT is exactly the type of field I want learn about. Love your content and please never stop making these vids
on minesweeper the frist click should always unlock a open space and in you ai simulation it dosen't do that so that is causing it to fail a lot of the times
Most Minesweeper games guarantee, that you don't loose turn one, however depending on the difficulty it is all but granted, that you'll get an open square at your first click, I usually play with so many mines, that I have like a 25-50% chance to hit a mine, if I just click randomly xD
One of my assignments in University was to play Minesweeper on the smallest board and try to get the fastest score you can - by hook or by crook. I was able to get the score down to 3 seconds. Strategy: click randomly as fast as you can across the board 3-5 times and then click and hold the smiley face - holding the smiley face pauses the game, but then letting go resets the game right? Not if you let go outside the bounds of the smiley face! Then it resumes the game. So, after holding the smiley and planing your next 2-3 click, move away from the smiley, click the planned clicks really fast and then click and hold the smiley again. At this point, you should only have a couple click remaining and repeat the above to win! Typical speeds using this strategy were 7 seconds or under... :)
Some Weeb you're right that neural networks aren't the only kind of AI. However, pathfinding in video games is not AI because they operate based on an algorithm that devises the perfect path to take, such as A*. It would be AI if it were able to continuously adjust the algorithm it used to get a more optimal outcome each time.
Basically this is on par with saying a program that's designed to respond to user inputted responses like "hello", "hey there", is AI. Maybe 20 years ago that's what a loose term for AI was. AI has grown to mean learning from mistakes because that's the best representation of how an actual human brain works in programming (I'm sure this will change to something even more complex than NN in the next 10 years). The current status of creating AI isn't about "How do I make it do x?", it's about "How do I make the program learn to do x?". Both are very different even though it may seem similar.
This type of sentimentality is exactly the reason why AI is always viewed with such ignorance as believing that as soon as we have true AI, it's Terminator Judgment day for us all. We've been developing AI for over 60 years but each time a breakthrough is made in it, that thing is named something else and is no longer called AI. General public has been reaping the benefits of Search Engines, GPS Navigators, Recommendation Services (used by Facebook, Amazon, Netflix, etc), Autopilots, Translators, Roombas, Video Game Opponents, hell even a blasted Thermostat are all offspring from AI development. AI is a relatively simple thing to define. All AI are autonomous entities, capable of taking in input and performing a desirable action, that are based on conditions that it has been given. In this case, we have a Minesweeper bot, that has been given the goal of clearing a level of bombs. It does so admirably and is clearly an aspect of AI.
If you call this an AI every single program on your computer would be an AI, you can certainly argue for that. But it would make the term AI useless. The bot did not simply get the goal to clear a level of bombs. What it got is an exact set of instructions: loop through all tiles and calculate a probability. Although the algorithm is fast and intelligently put together, it was created by a programmer. So the intelligence of the system was introduced by a programmer, the program here is pretty much a fancy calculator. Which is more within the domain of CS than AI. I'd say for AI the program itself has to do more than simply execute the complex algorithm thought up by a human programmer. An example would be learning to complete complex tasks.
The intelligence of the system _is_ usually introduced by the programmer(s). When I said "given a goal" I do not mean that the program has been specifically told to win minesweeper but rather that it is the designer's goal. I'll admit that brute forcing your way through the entire board, to spending every action recalculating every tile and pick the least likely one to have a bomb isn't the most efficient method, but it still satisfies the definition. Like it or not, AI is that broad of a term. AI are not free thinking or self learning machines. They're usually search algorithms of various sorts. Neural Networks are a very abstract search algorithms, where the designer "trains" the algorithm until it starts spitting out correct answers. By "training", I mean that they run the search over and over again, telling it when it's correct and when it is wrong. This is also automated, simply by having the algorithm go through data with known answers and then comparing its results with the correct answers. This is the most layman I can explain it, without this turning into a bigger wall of a text than it already is. Trust me on this. AIs are not that special. Nothing demystifies AI more than taking a course in it.
v0ldelord There is a difference between an AI and a tool... Most programs are tools, and while they satisfy the conditions for AI in the input and output department, they are not actually AI. They are tools which take the input of the user and create a output after the user puts in a set of inputs. Nothing more, nothing less. AI is a logic program which creates inputs without the user, hence having intelligence. It doesn’t matter if it is simply given a line of code to follow or if it naturally learns the code, if it is capable of operating by itself with no input from the user besides coding it(if applicable) and pressing the run button, it is an AI. Minecraft has AI for everything that isn’t the player character. The AI for zombies is essentially point towards the player and walk forward. It is a bit more complex than that, but still, it did not learn any of that, it was *programmed* to do those set of actions. But it is still AI because it is able to move and do actions without input from the user.
It's not a problem of "mystifying" the basic idea is AI should be able to tackle problem without the programmer having to break down the problem itself. You should be able to program a Go playing AI without even having to learn the rules yourself (instead you need a lot of examples or a sparing partner). Of course that is still not really true at the moment because there is still a lot of smoke and mirrors in the form of fine tuning but it is the general idea.
You should make some screensavers out of the big ones. Just make a multiple hour video of your AI clearing huge _Minesweeper_ fields. That would be gorgeous :3
still wanna see 1920x1080 grid lol
imgur.com/a/PltFdMu
i imagine it could look something like this...
it took my computer 5 seconds to solve the field.
to be fair, i had to tell him to only open safe clicks, else it still would search.
also what am i doing here
Yes please. And dont use a grid just colorcode all the possible stats (undiscovered, discovered, marked, 1-8, bomb) so the result is just a FullHD image with colores!
what is that? your screen resolution?
@@febrezeninja745 well mine is 1900x1200 so uhh wait where did everyone go?
f yee
Your ai needs more parameters. There are many situations in which the ai picks randomly when the location of mines can be deduced by numbers not directly adjacent. A human player can solve maps with many mines consistently where your ai tries and fails dozens of times before finding a map easy enough to be solved without more complex parameters.
Wouldn’t that be fixed with the rule he implemented at the end?
@@peepock7796 Maybe? We don't know how exactly he computes which squares are more likely to have bombs. If it's pure brute force then I guess it would always work.
@@NXTangl There is no way, for a human or an AI to ALWAYS win. Even in smaller configuration with only a few mines it's possible that they form an island where you don't know how the interior might look like. A common scenario you can think about is a 3x4 area that has mines at the perimeter (10 mines) so the middle 2 squares are unknown. Imagine you're only missing one mine. So you have a 50:50 chance since there is no way to know or determine which of the two unrevealed squares contains the mine. In larger grids with more mines this can happen even more frequently. Having 2 configurations of 3x3 (8 mines surrounding one square) it's also impossible to tell which of the remaining unknown center squares have a mine. The only way here is brute force. Of course you should keep those undecidable squares for the end as this could help to figure it out. Maybe all those undecidable squares should be mines in which case we know all of them, or they should all not contain any mines because you already found all. However any case in between requires guessing There are more cases than the two I mentioned which are undecidable.Though it usually boils down to some variation those cases (apart from even larger cases where a 2x2 area is enclosed by mines). Note that when two unknow squares are surrounded by mines, it also doesn't help when the perimenter has holes at the long sides. because if there's only one mine in there you don't know which one.
In the end the game is a gambling game since the distribution of mines is random. Yes the original minesweeper ensured that the first click is never a mine, but that was the only adaptive part of the game. The grid is either filled with mines after the first click, or if the first click would hit a mine we can swap the mine with any free square during the click.
As far as i know he actually considers all information available and actually does a probability distribution between undecidable squares and picks the one that has the least likely chance to contain a mine. Of course all decidable squares have naturally a 0% chance. Have you actually seen the first video?
th-cam.com/video/cGUHehFGqBc/w-d-xo.html
@@Bunny99s Well, there were definitely grids that the AI gave up on which had squares that are easily determined to not contain a mine, so it demonstrably does not consider all information available.
@@joeo3377 Well that is hard to tell from the video as there are something like 3 to 6 actions per frame. Yes I found some edge cases (specifically involving 3s and 2s) where it seems that it has not considered them properly as "linked cells". Though as I said it's actually hard to tell as in most cases you don't even see the "failed" configuration as too many steps are missing in between frames.
Currently I don't have the time nor do I want check the code as it's quite a mess to follow the logic ^^. However if you think you can spot the issue, feel free to have a look:
github.com/Code-Bullet/minesweeper-AI/tree/master/minesweeperAI
Can you try creating an infinite grid with a fixed amount of average bombs per 5x5 grid and letting the AI solve it till eternity, or until it dies?
And I you can do that, how much average bombs per 5x5 grid is necessary for the AI to lose under five minutes or even five seconds?
I'm basically asking you to force your AI to an eternal prison of minesweeper lol
Cool Idea! I really want to see this!
Combativ until you die?
I HAVE DONE THAT... i just havent enabled the bot on my infinite minesweeper version zikoat.github.io/ , i can enable it if you want
The Computer Would Crash
*(Obviously)*
WaZe or you could hack into a supercomputer and run the simulation there at hyperspeed :D
CB: "WEIGHING IN AT ONLY..."
Me: please use lines of code
CB: "1200 LINES OF CODE"
Me: YES!
1200 lines of code for a decent Minecraft bot!? I could solve the universe with 1200 lines of code.
@@dannygjk but that will take 7 and a half million years, and the answer will be 42
I myself hoped for bytes, but your idea is great as well
@@youpviver6773 especially if it's only some kilobytes.
@@robertlinke2666 Wasn't it 10 million years?
I think the only thing you are missing is that most of the time there are multiple squares with the same lowest chance of being a mine. Some squares are likely to reveal more information than others.
Perfect example is at ?t=50s . Although 591 of the 600 squares all the have the same chance of being a mine (96/591=16.2%), they do not have the same chance of revealing useful information. A middle piece like the one selected only has a 19.9% chance of being a blank. An edge piece has a 34.3% chance of being a blank and a corner piece has a 49.1% chance of being a blank.
This info is knowable and should be used in a prefect program.
Below is a spot where you are forced to take a guess. 4 of the 9 remaining squares all have the same odds of being a mine (1/5) but your chances of winning clicking differ greatly between those 4 squares. One square will always give you enough info to win while the other 3 will force you to guess again. The total future risk can be accounted for in many cases.
4 mines left in this 5x5 toy game. All the outside border is known. the 9 interior boxes are unknown. (M=mine, 3=touching 3 mines etc, and ?=unknown)
4 mines left Try to solve yourself or with your program.
M 4 M M M
M ? ? ? M
3 ? ? ? 3
M ? ? ? M
M M 4 M M
There are 5 states the mines can be in and 4 boxes have equal probability of being a mine.
The portental information revealed makes one of the boxes a much better choice then the others. (you lose half as often when picking it)
Can you pick the box that is the best choice?
A simpler example is the 2x4 grid B3B? / ????, with a total of four bombs. Guessing one of the two right-side squares has a 50% chance of instant kaboom, but reveals enough information to win otherwise. Guessing one of the three other squares will have only a 1/3 chance of instant kaboom, but won't reveal enough information to win without taking another 50% chance.
Click the first « ? »
@Flat Finger Tuning. Great example.
if im right its between the top right and middle right, im going to guess top right
of the four mines two are among the bottom three squares, leaving two mines for the remaining six squares. one is adjacent to the 4 on top, leaving one mine between the middle row and top right
Thank you
The thing I love about Code Bullet is he would rather sit there watching his inefficient code take an hour to process than spend 20 minutes making it more efficient and having it complete in 5
Code Bullet: "Absolutely no one asked me to increase the size of the grid even further. So I did that."
Me: * immediately clicks the like button because I hadn't already done so for some bizarre reason *
I did the exact same thing.
yeah you can't tell me that a "perfect" algorithm would need like 10 attempts to solve that...
THANKS!!! I cringed watching this guy have no clue and proudly letting the world know he has no clue...
There can be no perfect algorithm for a luck based game.
But you can perfectly calculate the best possible chance. If you've perfected all the perfectible bits, are you not as perfect as perfect can be?
Hey, have you thought of putting an AI to play against an AI in some 2 player game?
Mugem would be the best option. Imagine saltybet with learning ai.
AIs that learn by using evolution technically already do that. Hundreds of players are created, and the one that does the best "wins" (or is the one to evolve). But, I do see what you mean, that is a good idea :P
I'm sure he's thought about it but he's then shrugged the idea off because it was a bad idea because being AI's if they're programmed the exact same way (except one is to use another character or thing) then they'd just end up with the same results
he already did this with chess
AI 1: starts the nukes towards Russia, knowing the counter strike will obliterate its opponent AI 2.
AI vs AI on Multiplayer games
I know this is an old comment, but if you're still interested in this type of thing, there are communities that regularly program AI for multi-player online games and pit them against each other. One of them is a channel on twitch.tv SSCAIT (Starcraft student AI tournament) which is continuously playing Starcraft: Brood War games against fellow AI's, 24/7. These are generally NOT self learning bots, but people update their bots every week or so, and they're always improving.
This is the kind of Recommendation i want YT to show.
A new episode of: The Recommendations
Season 12: The Dark Ages
Watching the perfect algorithm fail on its first click makes me feel much better about my playstyle which also has me lose in the very first or second move most of the time.
I thought the first click on Minesweeper couldn't be a bomb?
@@EGarrett01 Yes, in the original Minesweeper; it generated a board. But if you clicked on a bomb, it would regenerate the boards until there no longer was a bomb there. Newer Minesweepers might be more effective (like just moving the mine).
Huh
Haha puny human.
Your videos are very inspiring as I delve into the wonderful world of ai. Thanks for publishing your work!
Superintelligent AI plays UNO
brillant IDEA !
that would actually not be that hard to code because of the simple rules of UNO, but what would be hard is everything that a highly intelligent mathematical genius would be able to do - calculating the probabilities of people having certain cards, and utilising this knowledge to be able to statistically win more games than anyone.
SKYE
syke?
SKYE
Pretty sure he meant "psych".
SYKE
THAT'S THE WRONG NUMBER!
*_SKYE_*
TO KO KO KO PO POM
POM POM
0:19 - "A lot of you guys."
Sigh... of course you'd be dealing with people who have watched a TED talk about neural networks, telling you why the AI algorithm _that you wrote_ isn't AI.
AI is a relatively simple thing to define.
AI are autonomous entities, capable of taking in input and performing a desirable action, that are based on conditions that it has been given.
In this case, we have a Minesweeper bot, that has been given the goal of clearing a level of bombs. It does so admirably and is clearly an aspect of AI.
So my vacuum will take over the world one day.
Well, yes. If all forms of AI are inevitably going to take over the world, as many like to believe, then your roomba is destined to be your future overlord.
Neural Networks are a form of AI, It tries, fails, replicas the most successful and attempts again. What do you think our brains do? It fails, then tries again and whenever it works, it retains that connection/method and builds off that.
Self learning, so sure this programs not about to figure out self automation and take over the world, but its a self learning algorithm that can be applied to literally everything and has been. From Healthcare to games, its doing a much better job than Humans in a lot of examples. Like diagnosing people, we give it all the information and 90% of the time its diagnoses is correct.
AI? Sure it is, AI is pretty Broad. Even "Siri" is considered AI but in reality its just a program that recognizes the input and outputs the most relevant information. But again, thats all we do isn't it? We take the input and then output a response.
Neural Network algorithms are most definitely a form of AI. Nobody here was claiming otherwise.
It doesn't apply to any computer program, if they are not autonomous.
It's the difference of a remote controlled vacuum and one that periodically goes around your house for you. A remote controlled one waits until it receives a signal to move. The latter one follows an algorithm that maps out your floor automatically.
But the latter one does not need to use neural networking to do so. There are vastly more efficient methods to do so.
I watched half this video last year today(exactly) and I finished it a year later
This is some movie crap.
5:55 I love it how it looks like the field is litteraly melting away. 10/10 satisfaction points.
It's interesting that your AI sometimes dies when there are moves it could make that are 100% safe.
I was wondering about this one, there was no real display of the fail points... I hate slowing down something accelerated. I guessed there were easy fails in this so called hard coded candy.
@@PandemoniumMeltDown i dont think the footage is accelerated. the ai is playing so fast =b
That means its realistic A.I. to his definition lol
Thanks for showing what an increased bomb density does. It's fascinating to see how the difficulty increases seemingly exponentially as you increase the bomb density.
Make it so that evry pixel in a 4k screen is a square in the grid and use the colors of the numbers to indicate them
This version of Code Bullet is so much more polite than his future self
1:27 Nice to see a guy from my country
Yeah us Ugandans need to stick together.
NewtSniper Uganda is dead.
Astroxeon Różnie bywa ;D
Elo Polska
Ruski yes?
I started laughing when you stopped it before the ending. Love your vids! Wish they were more frequent but I get it.
its not about a grid, its about a ratio mines/squares, when u have less ratio u wouldnt have a 50/50 problems, atleast not that much
I love how organic the spread of the AI looked.
Would love it if you did like a short explanation on how you calculated the probability for the squares, not like an in-depth code tutorial, just some pseudocode. Also, I define artificial intelligence as any program that simulates learning.
Check his last video for explanation.
The explanation is that P(bomb|tile) = Number of possible arrangements of bombs in which the tile contains a bomb / number of possible arrangements of bombs
An arrangement is impossible if it violates a number tile.
Yeah, well I guess I wasn't clear enough. That simple probability is easy to think of, but that would be wildly inefficient, and can't be the way that he did it.
Sometimes brute force is fast enough.
rosen. Nope. Minesweeper is NP-Complete. So bruteforce is the only known way to go for perfect play. You're underestimating modern hardware a bit. Only caveat is that I'd imagine for speed you'd want to be using a GPU to check all the combinations, maybe write that part of the code CUDA or whatever.
Small edit: Oh... and of course you can use simpler rules for finding 100% safe/bomb spots. So check them first for obvious safe/bomb spots, then brute force when necessary.
Nice mix of pictures & black text! Really like how you implimented them both into your videos
I want this as my new screen saver.
illesizs do you have it all ready?
Yes
I love how you can appeal to both coders and non coders, by explaining the coding, and by making something interesting. Thank you, and keep making these videos
AI stands for "Algorithmic Intelligence" - Boom!
Problem solved...
Artificial intelligence...
@@alextsukada4013 you did not get it did you...?
It is about the ever going conflict of what is ab AI vs what is an Algorithm...
Overlord Alfredo ah I see, just needed some clarification. Thanks
An algorithm is a math problem in harder to learn word. Also if that were to be true we would be AI too.
Im glad you asked for my definition so here I make on up on the spot notifying you that I spend some time on the topic.
The issue is with the word intelligence of course. Artificial we call most things made by humans, say "fake copies". For me, intelligence is a system within a system that makes the system stable.
People are very fast labeling their algos as AI's. The closest we got to AI (in my opinion) is amazon echo. Check out its language abilities on TH-cam for more. (Horrified Amazon Echo Users Say Alexa Has Gone Creepily Insane while Laughing)
Ok now back to video ;D very cool channel glad to find it (at 5am)
PS.: making an unconventional Computer in Minecraft, video will come soon, might be of your intererst CodeBullet
Cheers
Making the grid bigger makes it *easier* for the AI.
Whateer increase in computation time there is, it would be worse for a human player.
And the difficulty is best measured in Size/Bomb ratio. And once you go past a certain bomb ratio, it stops being a game of skill and becomes a game of chance.
Expands grid
“That terrifying”
Expands it again
“That is the most terrifying thing I have ever seen in my entire life”
73x138 or 74x138. I lost count near the end of the vertical
Love the humor and also the DBZ references crack me up! Great work man
Wow this is very old codebullet video
Thanks homepage??
Yeah, I'm going to demand that you made a ton more videos, your channel is mighty addictive. Keep up the good work.
What I think is an AI is just a program that simulates intelligence, but artificially. Hence: *_Artificial Intelligence_*
i am so happy right now, because as far as I know, no one has asked about the song name, that means you actually have good subscribers unlike other youtubers
I see you always let it start in the corners. Why?
edit: Okay, I've read some of the reactions and I think I know now. The corners do not have a lower probability of being a bomb. The only advantage I can think of is that because there are less tiles surrounding a corner there's a higher chance of having zero mines around it. This opens up more tiles, giving you a point to start from instead of having to take another guess.
You are more likely to hit a 0 so you uncover multiple squares.
I pointed it out in the comments in the previous video. Weird that he didn't mention it.
link explaining further. www.minesweeper.info/wiki/Strategy#First_Click
I guess it's probably because at the beginning all squares have the same chance of being a mine so the programm just starts with the first one in the array ([0][0])
why would you be more likely to hit a zero in the corners? Imo it's just to keep the code simple
I have played a lot of minesweepers, and the main reason I always start in the corner is that the corner is the place where might get a 50/50 chance and have to guess, which could mean that I might lose all the hard work I have done throughout the game.
If I just start in the corner first, then I don't have to deal with this choice at the end.
ah okay I never thought of that but I'm still not sure if it's intentional since he never mentioned it
Your video are so nice and your commentary so funny ! Continue like that 😄
Now if we could just make it cure cancer..... :)
Buster McGhee what if we could just make you cure cancer..... :)
A lot of people will have to die, though...
Muranski's Expert Minesweeper WR is one of the most amazing records in all gaming - when you realise just how exaxctly perfect his choices and execution are.
It's stood the test of time, too.
I agree with your definition of AI, but neural networks are cooler in my opinion. I like watching what the computer determines is the best way to win over time.
Neural networks are great for pattern recognition and has been improving image sorting algorithms immensely.
But it's not a cure all for everything. For example, A* search is a much better alternative, if your problem is about path finding.
Just skimmed through A* on wikipedia, seems similar to Dijkstra's (as it says on the page), which I used on a homework assignment last semester for a computer science. I would agree that a neural network would certainly perform much less efficiently than this algorithm. I'm guessing the major advantage over Dijkstra's is the heuristic step? That would allow the algorithm to aim the path towards the goal rather than radially expanding outward.
That's correct. How far are you into computer science? I'm sorta surprised that you've been introduced to Dijkstra without your instructors mentioning A*.
I'm currently about to finish my third semester in the program (I'm a semester behind as I started in Physics and added the dual major). The class I was taking was data structures, and the assignment was tied to the directed graph data structure (we had a choice between adjacency matrices and using pointers, can't remember which I used). I'm currently in an algorithms class and a theory class (I really enjoyed going from regular expression to minimum state DFSA's).
Ur channel has come a long way especially the art
Are you sure your AI is perfect? For instance, when faced with many squares that are equally likely to have a bomb wouldn't there be a square that is strategically better? e.g. squares more likely to give more useful information for future turns.
It is a simple program - no AI involved, and ye,s you are absolutely correct - it can be improved as it does not consider what choice leads to a better outcome in the long term: before it would take a single 50% chance to lose it would take a 49% chance hundreds of times in a row considerably lowering its chances in scenarios where it has to rely on chance.
Huh, I didn't consider that. I was just thinking that in situations where you have multiple choices with the same probability, deciding which is strategically the best seems awfully difficult.
But you're right, it also seems plausible that in the long run there may be instances where the best move (The one most likely to lead to a winning game) isn't one with the lowest odds of you losing that turn.
Like if you have a choice between say, a 50% loss square that gives you allot of information for later turns, vs a 49.99% loss square that will give you little information.
There is some technical words that easy to confuse here.
AI : Artificial intelligence - software that show intelligence like people do. So hard code is still count as AI
Self learning AI : Basically and AI that can improve it self. Self learning AI make for something programmer don't have concept to hard code. By leaning to statistics.
Newron network AI : one type of Self learning AI design.
Self learning AI will take more processing power it may better than this logic base AI at finish the game.
But because it will take much more processing power it will not run as fast.
@@put4558350 thanks, it's not easy for a stranger to understand every single word. It helped me 👍
Code bullet i just wanna say im really enjoying watching these A.I videos and keep thinking of when yours will get to the point of playing Mario successfully or wait for it a larger title like halo, battlefield, Call of duty, etc
Please make a 3d mensional mine sweeper
So basicly minesweeper in layers and witv higher numbers and look if your ai can still do it
Yey, when I get back I find a 25 min old vid of my fave computer youtuber! :3
I think your definition is a good one
Also, for the people who say that learning is necessary... one could argue that this system is learning more about the mines over the course of a game. As it clicks, it obtains new information, and based on that information, it updates the probabilities it assigns to different things. This could be said to be learning?
Dude your videos are so cool. Please keep making these :)
"SKYE, Become a Patreon"
I believe what's slowing it down is not the AI but the drawing and where the AI gets its information from.
Without any of the restrictions of drawing and a smooth feed to the AI (I.E, not having to iterate the whole board) the board could be cleared in a few milliseconds. Even your 128x72 tile board.
You counted. ++Respect
5:59 128 x 70
Hahahaha dude the music is amazing!! Mmmmm love it. Might I ask what the songs were?
Where did you get the music for your videos? And btw, nice work! :D
NeedyZ thanks!
The song used during the large grid demo is Aakash Gandhi - Viking, for those who keep asking.
The snack that smiles back
Children
just found this channel and it is AMAZING keep making videos my dude
(and get a mic filter will make the videos seem a higher quality and make you more of that sweet sweet youtube money)
Who else is here because he hasn't uploaded in two months?
Three*
😐
Your videos are great !!
It's really fun. Keep on going.
"yea so i won" XD
5:25 looks kinda like a Timelapse of something growing
Oh dear... There goes my beloved intro.
--Zuikaku
sorry i forgot
(Sees notification)
YAY!!! Code Bullet is doing TH-cam full time now!
(Watches video to 0:12)
You have got to be kidding me. That guy should have made over $250.
"Skye" damn... You mean syke or psyche?
i.etsystatic.com/11242699/r/il/d0d829/1892086115/il_570xN.1892086115_c5v6.jpg
My heart nearly stopped at the end when I thought you actually ended the video. . .
I have a question.
Why do you have to literally remake every damn game you make your AIs play? Or do you _not_ have to do that, and you just do that because you want to?
Don't get me wrong, it's cool that you go that extra mile at all, but I've seen people who work with AI (both of the hard-coded and the machine learning variety) that usually _don't_ seem to do that, so it struck me as unnecessary. lol
Because it's easier and faster for him to build in the AI into the game, that can read the data directly from the game, and do inputs directly into it. Still, the AI is not cheating, because it can't read data it isn't given. - Having the AI play games that he hasn't built requires screen reading, and/or memory scanning, which is a much slower process. This is not good if he's going to run 500 entities playing the game, or games requiring more direct and exact input. It also requires analyzing the data, and there can be errors in that too. - The best videos he done on this topic are the ones about Pong and Storm The House, where he actually use screen reading.
Your an amazing to be able to do this. Love your shows.
I disgree with what you think i AI is
I think its something I use to make myself feel good on super smash bros
Hey, had an idea to make it better. It looks like the AI never starts in the middle of an unclicked patch. Maybe add a line of code for when the probability of clicking a random square in there (bombs remaining/squares left) is less than the probability of clicking one of the known probabilities? This would increase chances of success for high density minefields :)
Anyway, love your videos as always, love the art and narration man
if he gets nor revenue this time i will be so confused.
Thank you for increasing the size, I wanted it but didn't think to ask
This algorithm has many faults here is a list of moments your algorithm gives up a guessing when there are still moves.
Here is a screenshot with my clearance from 3:38 i.imgur.com/IQeIL6g.png It has already guessed.
Here is another screenshot. It has guessed more than 4 times already. i.imgur.com/J3sGOeh.png from 3:42
3:38 bottom right looks like this, reduce the speed of the video if you are looking for the mistakes.
? ? ? ?
?3 1 1
? 1 00
? 1 00
You fail and restart
3:40 bottom right again.
?MM
? 3 2
? 1 0 You die before you solve it.
3:40 bottom right again
? ? ?
? 2 1
? 1 0 Another solvable you ignore.
Please stop calling this algorithm Perfect. Once I called you out in the comment section from not starting in the corner last video. You changed to starting in the corner this video, without even mentioning the change.
Exactly - these kind of links must be done to be able to beat best human players. 20y ago on fairly low level C-programming course we had task to write algorithm-based minesweep solver (communicated via stdin to mineserver and if you guessed and opened a mine you got rejected) where I did this kind of chains like dual-1's are stating there is one mine, so another 1 is telling it's adjacent square does not have mine. And -20y of Moore's law our algorithm were solving large minesweeper fields sub-second timeframe (we were competing with speed and how much you can solve). So video poster's current AI evolution is really not that impressive.
Also where to start board? By minesweeper definition your first guess is always guaranteed not to contain mine. So you get coordinates of first guess, initialize board so that there is no mine and tell result. Problem is that if square reveals "1" and you have 9 unknowns around it you must guess. But on above programming course it was forbitten to guess so that "1" was the solution.
This comment deserves more recognition. Great catch! It seemed suspicious that this supposed brute-force program is so fast.
In almost all real boards, you can count the number of combinations without iterating through all of them; but you have to do it in a clever way.
Consider unrevealed tiles "constrained" if there is a revealed number in their neighbourhood, and "unconstrained" otherwise; let n be the number of unconstrained tiles, and m be the number of mines whose positions are not known. Then if there are k mines in the constrained tiles, there are (n choose (m-k)) combinations of where the remaining m-k mines can be.
To count how many combinations have a mine at each constrained tile:
- let constrained be a dictionary mapping constrained tiles to 0 (initially)
- let unconstrained be a dictionary mapping integers from 0..m to 0 (initially)
- let total = 0 # total valid combinations
- for each k:
- - for each valid combination of k mines in the constrained tiles:
- - - let c = (n choose (m-k))
- - - update unconstrained[k] += c
- - - update total += c
- - - for each tile p where a mine exists in this combination:
- - - - update constrained[p] += c
Then, the probability that constrained tile p contains a mine is constrained[p] / total. The probability that an unconstrained tile contains a mine is (1/(n*total)) * sum from k = 0 to m of (m-k)*unconstrained[k].
Even iterating through all combinations of k mines in the constrained tiles is unnecessary, since we only need to generate valid ones, this can be done with a backtracking search rather than by generating all and rejecting invalid ones. If you're even cleverer, you can split the constrained tiles into independent sets which share no local constraints.
So, I have no doubt that an algorithm can follow the strategy outlined in the previous video efficiently enough for these board sizes, although given the errors Timothy noted, I suspect CodeBullet's algorithm doesn't really follow this strategy exactly - perhaps it estimates the probabilities by a Monte Carlo method instead, or perhaps it is just buggy.
And the algorithm does not look forward. That is needed because of this situation. Imagine that it has to take a risk, you can choose between a small and a big risk. If it takes the small one, it still has to take the bigger one, but if it takes the bigger one first it will get enough information not to have to take the bigger one. The AI will go for the smallest risk, but that is not going to help it. This situation is a bit hypothetical but it does illustrate how anticipating possible outcomes is an essential part of a perfect AI. The only way I could think of to solve this is make the AI calculate literally every possible game of minesweeper (you could eliminate some possibilities, but the number of games the AI would have to consider would still be astronomically high). It is probably infeasible to do this with nowadays' computers, the same way the perfect chess AI does not exist.
But most of the time there is a definitely-safe move requiring no look-ahead, so on reasonable difficulty settings a complete game doesn't require very many guesses in total - the search tree is not very deep. Also, you don't need to play out games all the way to the end if you know they already took more risk than another variation did; and deeper branches mean more guesses, usually meaning more total risk, so you're more likely to be able to prune the parts of the search tree that are deep. I think a branch-and-bound algorithm, combined with an optimised probability-measurement algorithm (like I described above), would be feasible.
I love the text in the background that just says "DEAD" and resets the program every time the AI dies XP But for real this amazing
6:58 theres a error
Lol
6:59
That would make a kickass programmed screen saver. :D
A process heavy screensaver, but sure
where did u get the minesweeper
He most likely made it, just like with all his other games.
Thing is there is no real way to apply the ai to another running program cause the capabilities of Processing don't support that and if there is a way it is still simpler just to reprogram these simple games
Lord of Pixels incorrect, you can use a language like c++ to read memory
processing has the robot class that can take a screenshot and click, and you can determine which number of bombs there is by the color of the number, So it's pretty easy to implement a function to take a screenshot and spit back an array with the number of bombs.
Though, when doing an AI you are often remaking most of the engine anyway, so it's not a lot more work to put a gui on it.
my comment started a conversation
Yo I stumbled across your channel last night and I have already binged watched every single video. I'm a highschool senior who's going to study cs and NEAT is exactly the type of field I want learn about. Love your content and please never stop making these vids
Song at 6:20?
Aakash Gandhi - Viking
Great mix of voice and your iconic "text speech" on this one!
To tu są polacy?!
Hejka
Kamil to mistrz sapera kozaq
The large grid games are actually kind of fun to watch.
you guys are all wrong A.I. is an acronym
Dewgang_47
Nope. An acronym is an abbreviation which can be pronounced as if it were a word, like NASA and AIDS.
I recommend having your AI read #2's better, that is almost a requirement in getting consistent at harder maps
on minesweeper the frist click should always unlock a open space and in you ai simulation it dosen't do that so that is causing it to fail a lot of the times
Uh....
False. Personally speaking I've lost on turn 1 several times.
Umm if all the tiles are blank and you don’t know where the bombs are... how are you supposed to know the best place to click to open a space?
Most Minesweeper games guarantee, that you don't loose turn one, however depending on the difficulty it is all but granted, that you'll get an open square at your first click, I usually play with so many mines, that I have like a 25-50% chance to hit a mine, if I just click randomly xD
Awesome content, keep going
5:18 Looks like my monitor.
One of my assignments in University was to play Minesweeper on the smallest board and try to get the fastest score you can - by hook or by crook. I was able to get the score down to 3 seconds. Strategy: click randomly as fast as you can across the board 3-5 times and then click and hold the smiley face - holding the smiley face pauses the game, but then letting go resets the game right? Not if you let go outside the bounds of the smiley face! Then it resumes the game. So, after holding the smiley and planing your next 2-3 click, move away from the smiley, click the planned clicks really fast and then click and hold the smiley again. At this point, you should only have a couple click remaining and repeat the above to win! Typical speeds using this strategy were 7 seconds or under... :)
Song name at 5:40?
I wasn't able to find the song, but the song did remind me/sound similar to:
John Dreamer - Becoming a Legend
John Dreamer - Brotherhood
Aakash Gandhi - Viking
I'm more impressed by the fact that you made this in Processing.
How would only neural networks be considered AI? Pathfinding in video games isn't done with a neural network.
Some Weeb you're right that neural networks aren't the only kind of AI. However, pathfinding in video games is not AI because they operate based on an algorithm that devises the perfect path to take, such as A*. It would be AI if it were able to continuously adjust the algorithm it used to get a more optimal outcome each time.
My eyes tend to be wird but I'm amazed that he got every detain. Even down to the suddle color difference where the bombs are placed.
if (bomb)
{
bool click = false;
}
else
{
bool click = true;
}
LoTML
but that music though, sweet sweet jazz-hop chill
Aahhhhhh
Edit: 6:00 I believe that is 72 by 128
Fastest I’ve clicked on a video.
Mr.Whale so 1 every 10 pixels on 720 p
Great video, any plan on doing some processing tutorials or shit like that?
Basically this is on par with saying a program that's designed to respond to user inputted responses like "hello", "hey there", is AI. Maybe 20 years ago that's what a loose term for AI was. AI has grown to mean learning from mistakes because that's the best representation of how an actual human brain works in programming (I'm sure this will change to something even more complex than NN in the next 10 years).
The current status of creating AI isn't about "How do I make it do x?", it's about "How do I make the program learn to do x?". Both are very different even though it may seem similar.
This type of sentimentality is exactly the reason why AI is always viewed with such ignorance as believing that as soon as we have true AI, it's Terminator Judgment day for us all.
We've been developing AI for over 60 years but each time a breakthrough is made in it, that thing is named something else and is no longer called AI. General public has been reaping the benefits of Search Engines, GPS Navigators, Recommendation Services (used by Facebook, Amazon, Netflix, etc), Autopilots, Translators, Roombas, Video Game Opponents, hell even a blasted Thermostat are all offspring from AI development.
AI is a relatively simple thing to define.
All AI are autonomous entities, capable of taking in input and performing a desirable action, that are based on conditions that it has been given.
In this case, we have a Minesweeper bot, that has been given the goal of clearing a level of bombs. It does so admirably and is clearly an aspect of AI.
If you call this an AI every single program on your computer would be an AI, you can certainly argue for that. But it would make the term AI useless.
The bot did not simply get the goal to clear a level of bombs. What it got is an exact set of instructions: loop through all tiles and calculate a probability. Although the algorithm is fast and intelligently put together, it was created by a programmer. So the intelligence of the system was introduced by a programmer, the program here is pretty much a fancy calculator. Which is more within the domain of CS than AI.
I'd say for AI the program itself has to do more than simply execute the complex algorithm thought up by a human programmer. An example would be learning to complete complex tasks.
The intelligence of the system _is_ usually introduced by the programmer(s).
When I said "given a goal" I do not mean that the program has been specifically told to win minesweeper but rather that it is the designer's goal.
I'll admit that brute forcing your way through the entire board, to spending every action recalculating every tile and pick the least likely one to have a bomb isn't the most efficient method, but it still satisfies the definition.
Like it or not, AI is that broad of a term. AI are not free thinking or self learning machines. They're usually search algorithms of various sorts.
Neural Networks are a very abstract search algorithms, where the designer "trains" the algorithm until it starts spitting out correct answers. By "training", I mean that they run the search over and over again, telling it when it's correct and when it is wrong. This is also automated, simply by having the algorithm go through data with known answers and then comparing its results with the correct answers. This is the most layman I can explain it, without this turning into a bigger wall of a text than it already is.
Trust me on this. AIs are not that special.
Nothing demystifies AI more than taking a course in it.
v0ldelord There is a difference between an AI and a tool... Most programs are tools, and while they satisfy the conditions for AI in the input and output department, they are not actually AI. They are tools which take the input of the user and create a output after the user puts in a set of inputs. Nothing more, nothing less. AI is a logic program which creates inputs without the user, hence having intelligence. It doesn’t matter if it is simply given a line of code to follow or if it naturally learns the code, if it is capable of operating by itself with no input from the user besides coding it(if applicable) and pressing the run button, it is an AI. Minecraft has AI for everything that isn’t the player character. The AI for zombies is essentially point towards the player and walk forward. It is a bit more complex than that, but still, it did not learn any of that, it was *programmed* to do those set of actions. But it is still AI because it is able to move and do actions without input from the user.
It's not a problem of "mystifying" the basic idea is AI should be able to tackle problem without the programmer having to break down the problem itself. You should be able to program a Go playing AI without even having to learn the rules yourself (instead you need a lot of examples or a sparing partner). Of course that is still not really true at the moment because there is still a lot of smoke and mirrors in the form of fine tuning but it is the general idea.
You should make some screensavers out of the big ones. Just make a multiple hour video of your AI clearing huge _Minesweeper_ fields. That would be gorgeous :3