antimine-android icon indicating copy to clipboard operation
antimine-android copied to clipboard

Implement game generator without guessing

Open lucasnlm opened this issue 4 years ago • 13 comments

Currently the generated games may have guessing situations. The game generator should be updated to avoid guessing situations.

lucasnlm avatar Apr 25 '20 13:04 lucasnlm

This feature is now available on 7.3.0 release.

I've implemented a brute force algorithm and a interface to easily add new implementations. They are both here.

lucasnlm avatar Jul 17 '20 03:07 lucasnlm

I have 8.3.0 and the game generated this which required guessing.

Note this is at the edge of the board.

Screenshot_20201020-142915_1

luke-clifton avatar Oct 20 '20 09:10 luke-clifton

@luke-clifton The current implementation was changed to try find games without guessing. If it takes too long to find a 100% no-guess game it will stop searching. I did it to have a better UX (it usually happens when a game has too many mines).

lucasnlm avatar Nov 03 '20 12:11 lucasnlm

What's the maximum expected mine density that's safe? Here is a screenshot of a guessing scenario on a 30 mine standard field.

2020-11-08 21 27 51

petersohn avatar Nov 08 '20 21:11 petersohn

@petersohn Depending on how my mines it must place and the area available it's impossible (or it take too much time) to find a 100% solvable level. So it fails in some cases. I think that is what happened to you. 😞

lucasnlm avatar Nov 11 '20 19:11 lucasnlm

I looked at the code, and the current no-guessing algorithm is actually not what I want. It only accepts a map if it can be solved by brute-force, i.e. by long-clicking on the numbers. This will get boring pretty fast. I like maps where I have to make some more advanced deductions, but I don't have to guess randomly. This is actually pretty rare.

So I threw together a more sophisticated algorithm. I'm not fluent in either Kotlin or Android development, so instead of creating a PR, I made a simple Python emulator / implementation, here: https://github.com/petersohn/mine-solver . Using this or something similar for the no-guessing algorithm would result in a higher chance of accepting a map, and also in possibly more challenging, but still solvable, maps. There is also a description of the algorithm in the readme.

Note that I threw this together in one afternoon, so there might be errors. They work fine for some tests that I tried it on. There are also possibilities for performance improvements, which might be important when running it multiple times in a row on an Android.

petersohn avatar Nov 22 '20 21:11 petersohn

Another far simpler solution would be to just allow players to win if all mines are marked correctly, but not all squares are revealed. Since it could be seen as cheating (but it would require far more time to solve this way then the normal way, hence not being a time-competetive method), it could be a toggle-able option in the settings.

BloodRaven0 avatar Mar 10 '21 11:03 BloodRaven0

@petersohn Sorry for take so much time to implement your suggestion. 😓 I got your code, but I'm still working on fix some render issues and adding support to opengl.

I hope to improve the generator soon.

lucasnlm avatar Mar 11 '21 23:03 lucasnlm

@BloodRaven0 It's valid as a toggle-able option. As default It may confuse some users that aren't used to this.

lucasnlm avatar Mar 12 '21 00:03 lucasnlm

@lucasnlm Yeah, I wouldn't have it as the default option either, even though I've seen some minesweeper apps leave it on as the default, and even have no option to turn it off. Still, it's not a perfect solution, because sometimes you might have a guessing scenario which is preventing you from revealing a larger part of the field, and this method can't help you with that.

BloodRaven0 avatar Mar 16 '21 11:03 BloodRaven0

I just experienced an end game guessing condition with guess free on. Though I don't know how to put some details here.

yw662 avatar Jun 12 '21 07:06 yw662

Screenshot_20210708-005147 Version 12.4.2 Still have guessing situation even though 'No guessing' mode is on. Thanks for the overall awesome game implementation!

Ledarium avatar Jul 07 '21 21:07 Ledarium

@Ledarium Have you check the current version? It uses a new algorithm.

lucasnlm avatar Sep 30 '21 22:09 lucasnlm