5 ms·
I did some work on a minesweeper solver [1], I'm surprised my work is not mentioned. The best version of their algorithm wins on expert 32.9% of the time, where
by luckyt 9y ago
I did some work on a minesweeper solver [1], I'm surprised my work is not mentioned. The best version of their algorithm wins on expert 32.9% of the time, whereas my AI achieves about 50% win rate. My AI uses the connected components decomposition that they did, but also some endgame tactics that significantly improved win rate (that they didn't consider).
[1]: https://luckytoilet.wordpress.com/2012/12/23/2125/ https://luckytoilet.wordpress.com/2012/12/23/2125/
- taneq 9y agoThanks for the interesting write-up! You say here yours wins around 50% of the time on expert, whereas your linked article says 50% of the time on advanced - is this a typo, and/or what's your success rate on expert?
- luckyt 9y agoSame thing -- 16x30 with 99 mines.
- ballenf 9y agoThanks! One question: does your algorithm account for the possibility that a non-border square could have a lower odds of being a mine when you reach the last-resort safest guess approach? It looks like you only consider the odds of mines in the borders, but not that a complete unknown square could have lower odds. You do mention the situation where you know that particular square has no mines, but not where you know the odds are lower than in any of the border squares. It's pretty rare, but in my minesweeper obsession days I would occasionally see it happen. Edit: upon further reflection, it's actually pretty common in the early stages, esp. in lower difficulty games. You will occasionally on the first click get a high-ish number and are much better off clicking a non-neighbor as the next guess. You must be doing this or couldn't achieve 50%, I'd guess.
- luckyt 9y agoYes, I do this as an endgame tactic. In some situations, knowledge of the mine counter can help you deduce that a non-border square is empty. (Details in the last part of the article)
- svalorzen 9y agoHey, another question. In your write-up you mention enumerating the possibilities when no deduction is possible, and picking one of the lower ranked cells found like this. However, a couple of improvements come to mind. First you could weight each possible configuration by the number of mines it contains per square vs the average remaining over the whole board (so a very mine heavy configuration is less likely if not many mines remain). Another thing you mention is that once you find the counts per square, picking any one of the lower counted ones is the same. This doesn't look true for me. One would also want a click to reveal as much information as possible, so clicking in an area with low density of mines is better. In your example clicking into the middle right 2 next to the three ones would likely reveal more info than clicking on the top right 2. Did you consider these as possible improvements?
- luckyt 9y agoIndeed, those are good ideas for improvements! It's hard to say whether they will improve the AI, as in both cases you're replacing one heuristic with another heuristic. You'd need to implement it and experiment with it -- and I haven't done so for my AI.
- leni536 9y ago> Each of these 11 configurations should be equally likely to be the actual position. This is not true. For calculating the odds of a configuration you need to take into account the non-border squares and the number of the remaining mines too. Example (3 remaining mines): 1111 *22* xxxx xxxx The * represents the marked mines, 'x' represents the unmarked squares. There are three border configurations: 1. mine, empty, empty, mine 2. empty, mine, empty, empty 3. empty, empty, mine, empty But actually the first one is actually is 4 global configurations, as the remaining one mine can be anywhere on the remaining squares. The second and third are 6 and 6 global configurations respectively as the remaining two mines can be anywhere on the remaining 4 squares (4 choose 2). The probabilities of a border squares to be empty are 3/4, 5/8, 5/8 and 3/4 respectively as opposed to 2/3, 2/3, 2/3 and 2/3 that your rule gives. The probability for a non-border square to be empty is 9/16, slightly more than 1/2. One can argue that when the number of the remaining unmarked squares is large compared to the border squares this gives little difference. But it's not true, this gives significant differences even when this is the case. [1] http://nothings.org/games/minesweeper/ http://nothings.org/games/minesweeper/ "Counting unencountered mines"
- luckyt 9y agoThat's a fair objection. You can view my rule as a heuristic that's easy to compute and gives good guesses in most situations, rather than calculating the mathematically correct probability. My AI does actually account for this, but only in the endgame when there are a small number of squares left -- then it considers the global configuration instead of just local. This works out because the endgame is where this problem is the most significant, it's computationally expensive unless there's a small number of squares remaining.
- leni536 9y agoThen I suggest an improved heuristics for mid-game. You can actually calculate the number of global configurations for each border configuration, they are just (n choose k) type calculations. It's somewhat more sophisticated when there are multiple disjoint border regions. Alternatively for a mid-game heuristic you can approximate the initial uniform distribution of the fixed amount of mines on the playing field with another distribution: Each square having an independent probability of having a mine or not. This could potentially simplify the calculation but it wouldn't be accurate when there are not so many mines left.