There’s not a whole lot to this step, so I’m going to skim over it quickly.Īt the beginning of the run, while we have a completely empty grid, we invoke a calibration routine – which takes a screenshot and looks for something that looks like a Minesweeper grid. In Java, we can use the Robot class in the standard library to send mouse clicks to the screen. Run the calculations, figure out where the mines are. Luckily for us, the numbers tend to have different colors: 1 is blue, 2 is green, 3 is red, and so on. We just need to ‘read’ the numbers on the screen. If we use a screenshot function, we can get a bitmap of all the pixels on the board. In this case, it turns out that these two simple strategies are enough to solve the Beginner’s grid:Īll this seems easy enough. So let’s go ahead and click on the squares that we know are not mines: Now the next strategy: if a 1 has a mine around it, then we know that all the other squares around the 1 cannot be mines. When the number 1 has exactly one empty square around it, then we know there’s a mine there. We can quickly identify some of the mines. We start with a 10×10 Beginner’s grid, and click on a square in the middle: Otherwise, I’ll just give a quick overview of some basic strategies that we can use to solve an easy minesweeper game. If you’re an experienced minesweeper player, you can probably skip this section.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |