By the way, how do you generate the mines in the begining of the game?
Yes, but not in a very optimal way, so it becomes slow.
Practically the algorithm is the following:
Put a mine on the field.
Check for the field solvability ("the best algorithm" is based on a few guesses, e.g. I demand that the field should be at least 50% solvable)
If field is solvable (and total amount of guesses does not exceed a predefined value) - place another mine if not - remove this mine and place it elsewhere
repeat until no mines left in the pool, or N mines failed to be placed.
I've already made up an algorithm how to make this process quicker (place mines only in adjacent areas and solve only changes from the previous time), but I'm still afraid it would reduce the generation difficulty.