wcoots / vue-minesweeper

💣 Personal project to build minesweeper in Vue
https://minesweeper-app.netlify.app/
GNU General Public License v3.0
3 stars 0 forks source link

First click always lands on an empty cell #43

Open loicadolphe opened 4 years ago

loicadolphe commented 4 years ago

In the original game, it was impossible to land on a mine on the first click.

To go even further, I'm pretty sure the first click always lands on an empty cell :

Group 1

In this case, clicking on the lone 1s should be impossible on the first click.

wcoots commented 4 years ago

Axel mentioned this a few months ago, it's an interesting problem.

As the game is completely client side, the browser is used to generate the mine positions (from a random seed), and then the corresponding number tiles. For small grids this is quick, but for larger grids such as expert mode there is a noticeable delay. Therefore a good solution would ideally not have to be the creation of a new grid upon the initial click. However, it is also important that the mines are in the correct places for that game's seed, otherwise the seed can't correlate to the mine pattern.

Therefore at present the only way I can see to solve this problem while keeping correspondence between the seed and the mine distribution is to greatly boost the speed of the grid generation. If we can get it quick enough then upon the initial click grids could be generated until one has a free space where the first click landed.

Does that make sense?