Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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?

share|improve this question
2  
My approch would be to start with the end game condition and undo random valid moves (i.e. add a block of 3, swap 2 tiles to make a block of 3 not a block of three etc.) –  George Duckett Apr 25 '12 at 9:39
    
@GeorgeDuckett is on to something, but puzzle modes in these kinds of games (where the object is to remove all the tiles) are normally better and more fun if the puzzle is generated by hand. (And to look like something) –  DampeS8N Apr 25 '12 at 13:10
    
Can you clarify on the rules you use in your match-3 game? I'm slightly confused if by "given number of moves" you mean that with your ruleset the board is cleared entirely in some tetris-like manner, or if you want to ensure there's a maximum/minimum number of moves to execute on board in case it's bejewelled-like where new items are introduced from side of the screen to replace the void left by cleared pieces. Is your match-3 about switching two nearby items around or rotating many pieces in some more complicated manner like a square? –  Toni Apr 25 '12 at 13:26
    
@GeorgeDuckett, I used such algorithm, but encounter with problem in answer of Darkwings. –  johnN Apr 25 '12 at 14:48
    
@Toni, It's about switching two nearby items around. There is maximum number of moves/switches. No new items introduce from sides. –  johnN Apr 25 '12 at 15:01

2 Answers 2

up vote 2 down vote accepted

I'm assuming Match-3 is like Bejewelled, right?

I have no experience with this, but I would try the following:

  1. Generate random board
  2. Override some cells to create some 3 matches and maybe a 4 match
  3. Randomly move one of the cells in a valid way
  4. Make a few other random moves if necessary
  5. Validate by removing matches (if any) and replacing them

This doesn't give you any hard guarantees though. Experiment, I'd say :-)

share|improve this answer
    
Thanks. I currently using same algorithm, but without step 2. –  johnN Apr 25 '12 at 14:42
    
Let me know (here) if it works; I'm curious. –  Wouter Lievens Apr 26 '12 at 9:23

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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.