   Generate Bejeweled-style random level
  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).   
  Well one way would be to randomly fill in the map, then...for N number of times:1) pick a point randomly on the map2) change some of it's neighbors to be the same color as that pointfor 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.   ;  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)rgrorrgrThen 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.   ;  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.   ;  Wouldn't it be easier to randomly create X combos in the level and then fill in the rest with extras?   ;  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 iswhile(!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.   