Match 3 or Match Game random game seeding?

BlitzMax Forums/BlitzMax Beginners Area/Match 3 or Match Game random game seeding?

Amon(Posted 2008) [#1]
I've been trying to figure out how I would go about creating a random game map for lets say a Match 3 game.

Basically I want a random set of numbers in a grid array when a game loads but it must be solvable. There's no point in setting up a random level of a match 3 game if the grid isn't solvable.

I had some ideas about checking what number is in the grid then adding the same number next to it with a gap then the same number again but it all goes wrong when it tries to do the same for the other number in that it overwites the other solution.

How do you guys do it?

Forgive me if this is not explained properly but I think you'll understand what I want and am trying to do. :)


GfK(Posted 2008) [#2]
I have a series of tile layouts stored in a list, eg:
1. **-    2. *-*    3. *-
   --*       -*-       *-
                       -*

That's just an example but I have about 30 or so. Think of them as a bunch of rubber stamps. I bombard an empty grid with these 'stamps' and after I place each one, I check that no lines of 3 have been made - if they have I remove them as I don't want any matches to already be made at the start.

Building the grid this way ensures that there are plenty of moves available to the player at the start of the game.

After so many attempts at stamping down my lil pre-defined patterns, I stop doing it, and fill in any blank squares with random tiles - again, making sure they don't make any lines of three or more.


Amon(Posted 2008) [#3]
Thanks, I'll give that a try. It deffinately looks easier than the way I was trying to do it.


Grey Alien(Posted 2008) [#4]
I fill the with random pieces (starting top left) and as I place each gem, I make sure that it isn't a 3rd one of 3 in a row or column (taking into account any non-grid squares due to different level layouts), and if it is I simply change it to another gem Once the whole grid is filled like this I then call my "Check for possible matches" function, and if this fails (i..e there are no possible moves), then I simply refill until it doesn't fail. If you design your levels sensibly most won't fail, or will only fail a couple of times.