AI and Game Mechanics Research On
AI and Game Mechanics Research On
AI and Game Mechanics Research On
Candy Crush Saga is a free to play game developed by King released in 2012. It is
available on iOS, Android, and Facebook.
The game wants player to swap two adjacent candies on a game board to make a line
of three or more of the same type of candy. When three or more candies are matched,
they disappear from the game board and new candies fall into place from the top of
the board to fill the gaps.
Game has several levels; player can clear these levels by completing required
objective or clearing certain number of candies. The game constantly increases its
difficulty as level increases.
The main reason behind its growth was its colorful UI/UX combined with good
background music and addictive gameplay.
The main catch of the game is that you have 3 lives initially and on losing a level the
life decreases by one, restoration of one life takes about 30 minutes. So basically
players need to play each move carefully and if they loose all their lives they have to
wait for a considerable amount of time, this creates excitement to play the game next
time.
1) Levels
a. Time-limited levels: player need to clear the level before the time
limit provided.
2) Matching: player need to match three or more candies of the same color
to clear them from the board.
4) Lives system: players have a limited number of lives (3), and they lose a
life each time they fail a level.
Valid Match:
Condition: We need to check whether the element after the swap with
adjacent element forms a row or column of three or more elements that have
similar identity.
For example:
Here we can see that the purple candy when swapped we the blue candy forms a
row of purple candy that has length more than 3, which is a valid move.
Left and increase left count variable until the traversed element is
not same as swapped element.
Down and increase down count variable until the traversed element
is not same as swapped element.
Sum of right and left will give total length of row with same candies.
Sum of up and down will give length of column with same candies.
This is very basic algo to determine the valid match as game proceeds it allows
different combinations of match like match combining both row and column
etc. but these all combinations can be validate using the row_count and
col_count variable.
Lives System:
Condition: We need to check if the player lost the game or not. If yes
than fetch the current life and decrease by one
For example:
We need two variable to store the current life, and current timer
If(game_lost() == true){
//we check that if the game is lost
If(curr_life > 0){
//we need to check whether current life if greater than zero or
//not
Curr_life = curr_life – 1;
Set_life(curr_life);
Set_timer(curr_timer);
Return ERROR;
}
}
This is very basic algo to update the life system and life regeneration timer.
Player can also purchase additional lives and decrease timer time, this requires
additional code implementation.
Level Up System:
Condition: We need to check whether the player won the current level
and unlock new level
For example:
We can have a custom class from each level having a Boolean value for
unlocked.
If(game_win()==true){
Curr_level->next_level.unlocked = true;
//move the pointer to next level and set its unlocked value to true;
This is very basic algo to unlock next level, as game also needs to fetch and
sync level already played from the same account. And account for any
purchased unlocked also scoring system needs to be bind with the level.
4) Commutative: If the order in which the rules are applied does not
affect the outcome. The order in which the rules are applied does not
matter.
Conclusion: Candy Crush Saga is a game that has very deep implemented
data structures and algorithm that pairs with AI to deliver a very addicted
game. It truly understands the users responses and make the level and
special abilities accordingly. AI are implemented in small chunks rather
than modeling a big general purpose AI, this reduces the chances of error
and decrease the logic processing time for the game.