Generate Bejeweled-style random level

This topic is 3313 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

Hi, I am working on a colour-mathcing game based on hexagons but I would like to know what techniques/algorithims are used to generate the random level's in Bejeweled type games that always seem to helpfully group lots of the same colour together (mostly on the easy levels).

Share on other sites
Well one way would be to randomly fill in the map, then...

for N number of times:

1) pick a point randomly on the map
2) change some of it's neighbors to be the same color as that point

for varying level of difficulties you can just make it for harder difficulties, N is a lower number, and for easier difficulties, N is a higher number. You'll probably have to tune the numbers to your liking (:

that's really simple but should be a good start. If your game does something like "if there are 4 of the same color touching, explode" you'll have to do something to make sure there aren't 4 of the same color touching maybe by detecting all those cases before game start and setting one jewel in the chain to a different color.

Share on other sites
similar to what astrix 256 said I generate the board completely random based on colors. Then I run through these steps, how many times you repeat these steps depends on the difficulty.

1: Scan for possible combonations. ie make sure there is atleast one chance the player can make a combo.

2: If not scan for a spot that one can be made ie. find a spot like this (letters represent colors)

rgr

or

r
g
r

Then add a second red next to one of the others.

3: Repeat step two depending on the difficulty.

I'd also repeat step one before choosing the block to replace the empty spots, that way the player is never screwed unless that's how you want the level to end.

Share on other sites
Actually, more important I'd like to see that you create a level where there is at least ONE possible match. It's pretty unfair to the player to enter a new level and it's Game Over.

Happened to me on the original Bejewelled.

Share on other sites
Wouldn't it be easier to randomly create X combos in the level and then fill in the rest with extras?

Share on other sites
I wouldn't even bother trying to solve the problem "which cell should be recolored and how so that there is at least one move that creates a combo, but so that after recoloring it is not an immediate combo?" Instead, what I would do is
while(!done){   Generate random board;   while(immediate combos left on board) // Don't want to start with a three-in-a-row ready on the board.      Swap a single tile around the combo or recolor a random tile of the combo; // Hope we broke the combo.   if (num. moves that create a combo > 0)      done = true;}

I wouldn't mind even if that outer loop ran for a 1000 iterations, even then I'd expect the total running time to be less than a second. Given that the probability of combos is quite high, I'd assume you'd typically loop only 1-5 times.

The inner loop is probably best limited to some 100-1000 iterations, and if it doesn't finish by then, just generate a totally new board.

This whole thing is very similar in spirit to uniformly generating random numbers inside a sphere - you only have a probabilistic guarantee that the loop ever terminates, but nobody cares :p.

1. 1
2. 2
Rutin
22
3. 3
JoeJ
18
4. 4
5. 5

• 17
• 40
• 23
• 13
• 13
• Forum Statistics

• Total Topics
631726
• Total Posts
3001910
×