Explore Courses Blog Tutorials Interview Questions
0 votes
1 view
in AI and Deep Learning by (50.2k points)

I was wondering, which are the most commonly used algorithms applied to find patterns in puzzle games conformed by grids of cells.

I know that depends on many factors, like the kind of patterns you want to detect, or the rules of the game...but I wanted to know which are the most commonly used algorithms in that kind of problem...

For example, games like columns, bejeweled, even Tetris.

I also want to know if detecting patterns by "brute force" (like, scanning all the grid trying to find three adjacent cells of the same color ) is significantly worse than using particular algorithms in very small grids, like 4 X 4 for example ( and again, I know that depends on the kind of game and rules ...)

Which structures are commonly used in this kind of game?

1 Answer

0 votes
by (108k points)

Given the ordinary computer speed these days, if it's real-time as the user is playing the game, it probably won't matter for very small game boards only. It will depend on the complexity of the game logic, but also how fast the code is going to run on the target machine means that this is a JavaScript web page game, or it is a Windows app written in C++).

If this is for something similar to the simulation gameplay strategies, then you can use a more efficient algorithm.

A more efficient strategy could involve keeping track of incremental changes to the game board, instead of re-scanning the whole board every time.

Now regarding the algorithms: It surely depends on the game. For example for Tetris, you only have to scan each row if it has the same color. But for most casual games brute force should be perfectly fine. Pattern recognition should be negligible concerning graphics and sound processing.

Regarding structures: A simple 2D-Array should serve for representing the board.

If you wish to learn about two-dimensional array in c then visit this C Programming Course and C++ Programming Course.

Browse Categories