Jump to content

View more

Image of the Day

WIP title screen for #DeathOfAPartisan #screenshotsaturday #gamedev https://t.co/qJNhfZCvd4
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

The Algorithm Design of Candy Crush

4: Adsense

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.


  • You cannot reply to this topic
11 replies to this topic

#1 finanshow   Members   

157
Like
0Likes
Like

Posted 30 May 2013 - 09:34 PM

Hi guys,

 

I would like to know how would you will design the core algorithm of CANDY CRUSH? Any one got idea?

 

com.supergames.candycrushsaga_94396700_0



#2 warnexus   Prime Members   

1535
Like
0Likes
Like

Posted 30 May 2013 - 11:22 PM

You need to be more specific. 

 

In terms of representation, they can be stored in an array or a list.



#3 finanshow   Members   

157
Like
0Likes
Like

Posted 31 May 2013 - 12:14 AM

You need to be more specific. 

 

In terms of representation, they can be stored in an array or a list.

Here what I mean is that algorithm to traverse the board to find out which candy need to be remove.



#4 BloodyEpi   Members   

1152
Like
0Likes
Like

Posted 31 May 2013 - 01:21 AM

Is this one of these "Match 3 in a row" games?

 

Just check if the two flipped objects are connected to 2 more equal objects, if yes remove all of them, if not flip back.



#5 Olof Hedman   Members   

5951
Like
2Likes
Like

Posted 31 May 2013 - 01:39 AM

You could use a flood fill to find and count the objects http://en.wikipedia.org/wiki/Flood_fill



#6 finanshow   Members   

157
Like
0Likes
Like

Posted 31 May 2013 - 02:18 AM

Is this one of these "Match 3 in a row" games?

 

Just check if the two flipped objects are connected to 2 more equal objects, if yes remove all of them, if not flip back.

Yes, It's kind of "Match 3 in a row" game.

How you got to implement this rule? Use recursion or backtracing? How to organized those objects, the board should be traverse each time.

Thanks,



#7 MatrixTan   Members   

121
Like
0Likes
Like

Posted 31 May 2013 - 03:05 AM

you can use a bit map to store the types of candy. the player can change only two of them each time. so you just scan and check the ranks of them.



#8 finanshow   Members   

157
Like
0Likes
Like

Posted 31 May 2013 - 03:09 AM

You could use a flood fill to find and count the objects http://en.wikipedia.org/wiki/Flood_fill

Hi @Hedman, Great answer! It's helpful... biggrin.png



#9 MatrixTan   Members   

121
Like
0Likes
Like

Posted 31 May 2013 - 03:54 AM

You could use a flood fill to find and count the objects http://en.wikipedia.org/wiki/Flood_fill

Hi @Hedman, Great answer! It's helpful... biggrin.png

learning...



#10 CJ_COIMBRA   Members   

980
Like
1Likes
Like

Posted 03 June 2013 - 05:16 AM

I am working on a match 3 game, but it also matches irregular pieces connected to the original match. For that I am using the flood fill already mentioned on the thread.



#11 finanshow   Members   

157
Like
0Likes
Like

Posted 03 June 2013 - 09:28 PM

I am working on a match 3 game, but it also matches irregular pieces connected to the original match. For that I am using the flood fill already mentioned on the thread.

Thanks CJ. laugh.png



#12 Dragonsoulj   Members   

3180
Like
0Likes
Like

Posted 03 June 2013 - 10:25 PM

I believe I answered this kind of question before. You could search your space for 2 criteria: 2 of the same "candy" adjacent horizontally or vertically, and then see if at least a third is switchable from whichever direction the "candies" are in (horizontal or vertical). This covers the first portion. The second is looking for 2 "candies" that are in a line, horizontally or vertically, with only 1 piece that separates them. Then with that one piece, see if a piece in the opposite direction (if you are finding horizontal lines, look vertically, or vice versa) can be switched to make 3. If so, this is a match.






Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.