views:

84

answers:

2

I have been playing Bejeweled Blitz for a while now. Yes, it is an addiction. In thinking about the game, I have observed that on some boards, the bottom runs dry (no moves) leaving only the top part of the board playable. Frequently that part of the board drys up, and one is left with moves in area cleared by the last move.

The board never runs completely dry, so clearly the program is doing some sorts of calculation that allows it to choose what to drop to prevent it from running dry.

I have noticed in this 'mode' that it is very common for the algorithm to drop jewels which causes more non-dry area to appear in the horizontal area. Perhaps less frequent is a drop which seems designed to open up the bottom part of the board again.

So my question is "How would one go about designing an algorithm guarantee that there is always a move available.?"

+1  A: 

This is solvable by exploring the space of possible "jewel drops" and then you apply a rating based on your rules you have asked for. Higher rating could mean follows rule and low ratings mean not following then you choose one slot with the highest rating.

This is not easy to explain, but a rule based approach should do the trick.

Patrick Cornelissen
+1  A: 

I wrote three-in-a-row game a while ago and the way I dealt with that problem is by selecting gems to drop at random and counting all valid moves. If selected gems did not provide at least 1 valid move I would select another set of gems and so on.

Denis
Interesting.Did you end up with any infinite loops?
EvilTeach
Nope. You allways have several good gem combinations to choose from.
Denis
this seems to work.thanks.
EvilTeach