PDA

View Full Version : help on comb gem of Super Puzzle Fighter


black
05-29-2006, 10:49 PM
hi all~

there's a game named "Super Puzzle Fighter 2" presented by Capcom, who had ever played it be4 will know its rules:

1. gems have colors(blue, green, yellow and so on);
2. if several gems with same color consists a rectangle those gems will be changed into a huge one, which is called a combo gem;

my question is, when 2 gems get down, how to search and decide which gems could be considered to be a combo one ? i thought recursion as a solution for a few seconds, but soon i realized that recursion has less efficiency caz' we dont know how far we must search, and it is hard to debug once there's a problem within, so any good idea for it(searching) ?

ps: this is my first post, cheers~ :D

Jason Chong
05-30-2006, 04:40 AM
hi all~

there's a game named "Super Puzzle Fighter 2" presented by Capcom, who had ever played it be4 will know its rules:

1. gems have colors(blue, green, yellow and so on);
2. if several gems with same color consists a rectangle those gems will be changed into a huge one, which is called a combo gem;

my question is, when 2 gems get down, how to search and decide which gems could be considered to be a combo one ? i thought recursion as a solution for a few seconds, but soon i realized that recursion has less efficiency caz' we dont know how far we must search, and it is hard to debug once there's a problem within, so any good idea for it(searching) ?

ps: this is my first post, cheers~ :D


I played that game before, still have it, very addictive though. If you're talking about gems that are linked in vertical/horizontal for more than 3 counts, the obvious solution is recursion.

I don't think running out of stack is a problem since the puzzle array is never large enough anyway to suck up the stack memory. The other way is to use an externally allocated stack, unrolled recursion.

As for the combo gems, why not just use a fixed dimension to test for the furthest vertical and horizontally linked gem starting from that gem you're testing itself, traversing each gem in the array one by one? (No need recursion) There should be a flag for each gem to set whether they've turned into part of a combo gem or not, so that you can ignore that particular gem index in the array on the next array tests.

black
06-02-2006, 04:40 AM
i hope that will not be the prob, let me try it out first lol, anyway tks !