Sunday, October 27, 2013

Match 3 Game algorithm Part 1 - Game elements terminology and analogy

Generally, a Match 3 Game consists of a matrix of nodes with the dimension M x N. Here i prefer a square one (M x M), specifically 8 x 8.

Terminology:
a) Tile: The location at which the 'node' resides. In a matrix of M x M, each tile is representable by a number from 0 to (M x M - 1), at ith row and jth column.
b) Node: The item of the matching. In the Candy Crush Saga, it is analogous to the candy.
c) Matches: The matching of 3 to 5 nodes, could be horizontal or vertical, but not diagonal.

* To conveniently setup the Match 3 Game, I use colors as the type to differentiate the nodes. Similar to the tile number, i will start counting my row and column from 0 to (M-1).

For example, the picture shows a matrix of 8 x 8 - consisting of 64 tiles.
 The crossed tile:
a) resides at 1st row, 1st column. OR
b) belongs to the 9th tile.

Apart from that, there are a number of matches observed. For example, a matches of 5 blue squares at 33th, 34th, 35th, 36th, 37th tiles.

Coming up next: How to detect a match?

1 comment:

  1. This comment has been removed by a blog administrator.

    ReplyDelete