I made match-3 game and now i trying to add level generator. Now I generate level by filling random cells with random blocks, but I want to create generator which for given number of moves and number of block kinds generate level. What algorithms I can use if they exists?
I'm assuming Match-3 is like Bejewelled, right?
I have no experience with this, but I would try the following:
- Generate random board
- Override some cells to create some 3 matches and maybe a 4 match
- Randomly move one of the cells in a valid way
- Make a few other random moves if necessary
- Validate by removing matches (if any) and replacing them
This doesn't give you any hard guarantees though. Experiment, I'd say :-)
Generating the blocks while the game is running, providing a good neighbors checking algorithm (depending on the difficulty level) would provide a less repetitive result.
Without a flexible algorithm a player will eventually memorize the pattern in a few tries. That's a possibility for any type of game depending of fixed patterns (even more complex games, like chess), and once it happens the trick gets old really fast.
This question is exactly about that concept: Connect-three game: Increasing level-of-difficulty as play progresses