4 ms·
Has anyone won a game of this?
by johncoatesdev 6y ago
Has anyone won a game of this?
- nallerooth 6y agoFirst cell I clicked on was a mine. So far it behaves exactly as the original. ;-)
- lifthrasiir 6y agoAFAIK the original ensures that the first cell clicked is not a mine.
- eyalitki 6y agoOnly on Ubuntu, in which the first click must be "0". On Windows it could for example be "2" and then you have to guess which of the adjacent 8 cells are the 2 mines...
- Sniffnoy 6y agoThat's not what's being discussed here; the above comments talk about whether it's guaranteed that the first click is not a mine, not that it's not adjacent to a mine. As far as I'm aware, just about every version guarantees that the first click is not a mine, but many (such as the Windows original) allow the first click to be adjacent to a mine.
- 8note 6y agoWhat's really being discussed is whether the game works well though/you'd want to play it Whether you lose on move 1 or move 2 due to bad luck is not a big difference
- elcomet 6y agoThere is some luck involved in minesweeper anyway.
- CodesInChaos 6y agoThere are some variants without luck. For example there was one which guaranteed that you never get a mine when you have to guess, but always get one when you guess in a situation where you can still open another field safely.
- Thin_icE 6y agoThis is true, I've played and won many minesweeper games and always wondered how this was done.
- est31 6y agoYou generate the game map once it's known where the player clicked. During generation you take into account that the first clicked cell has to be mine-free. In general, when distributing mines, the algorithm has to take into account already that there must be N mines in the field, so avoid instances where it assigns two mines to the same field twice. You treat the starting field as just another "mine" whose position is hardcoded. A simple algorithm would be to re-do the map generation until there is no mine collision, but with larger numbers of mines, the collision chance increases, so your runtime will go up superlinearly. A simple but very effective improvement is to keep the positions of the mines up until the collision and then only change the seed for subsequent mines. Then your algorithm should in fact scale much better. You can also use different methods, like assigning indices in a certain way so that invalid states are avoided completely. A bit more complicated but way "cleaner".
- lifthrasiir 6y agoThere is an even simpler approach: for maps with K total cells there would be always K-1 unclicked cells and a single clicked cell after the first click, so you can generate K-1 cells and insert a "gap" corresponding to the first clicked cell. This works because every unclicked cell has an equal probability to become a mine.
- mkl 6y agoEven simpler still is to just move any mine clicked on in the first move into an empty square before processing the clicked square as normal.
- lifthrasiir 6y agoThat needs a list of empty cells, otherwise you need to retry and get the same issue as the map-wide regeneration.
- airstrike 6y agoSeems like it would take too long. Probably faster to write a bot to beat it, which is still technically winning
- eyalitki 6y agoI have written one for that years ago in Java. It generates a map according to my first "click" and solves it deterministically. If it reaches a state in which it has to guess, it regenerates the map, and tries again. It happens so fast behind the scenes that the user isn't aware of it, and it makes sure I won't have to guess anything when I play. Purely skill, no random.
- jldugger 6y ago> Seems like it would take too long. I feel like you've forgotten the purpose of a hobby.
- airstrike 6y agoOn the contrary, I simply suggested a different one