I'm making a minesweeper game in minecraft (never mind).
I created a code that randomly places mines, displays the number of bombs around each block, detects clear and fail of the game.
Even if the same number of mines were placed on a map of the same size, the difficulty was very different for each game, so I felt that it requires a lot of luck to clear the game quickly.
So I'm looking for an algorithm to generate numerically the overall difficulty of a randomly generated map.
I tried a method of calculating the difficulty level by scoring and summing each number (colour) of each tile (block). However, we couldn't find a score for each tile that would be able to score a reasonable difficulty score.
Since it's a command operation in Minecraft, I don't want too complex expressions or perfect results. If there is an algorithm that can be divided into about 3~5 levels by obtaining the difficulty of a randomly generated map, I would appreciate it if you could explain it to me
(redestone block is mine, and each colour represents number tile 1 2 3)
First of all, the Minesweeper difficulty in the actual game is handled by increasing the size of the board and the number of mines. Since it is easier to restart and faster to replay the Minesweeper game on a screen, this is considered sufficient. (Whether it's a good design is a different question.) You, however, want to handle the difficulty across one set of board and mines for the purpose of you minigame.
Since you want something reasonably simple, I would recommend one of these approaches:
Cheat a little:
Minecraft programming is not exactly a pleasant place to handle such analysis. Since you already have a random generator in place, use it to load one of several dozens of pre-prepared and pre analyzed boards. Player won't notice anything unless he is dedicated and spends days playing your minigame - only that your game seems fair and nice to play. You have your difficulty with minimal hassle.
Cheat a lot:
Implement a fair minesweeper: In a case where the player can't be sure about the next step, always place a non-mine and if there was a mine put it somewhere where it won't change the already revealed layout. This removes the places from the actual game where the player has to guess which can be considered unfair. The feeling of having a 30% chance to ruin a game near the end when you have no control over the situation is not fun.
This would be a little more difficult to implement. On the upside it would require no pre-loading and pre-computing.
As for an actual answer, there has been an extensive study into a Minesweeper - for example this thesis. The portion there I found that mentions the board generation says something like this:
- Generate a board.
- Run an algorithm to find the "unsolvable" sections (where player would have to guess)
- Run a different algorithm to try to convert this section into a solvable one.
Which most likely isn't the easy solution you are looking for.