• Create Account

### #Actualthescholar

Posted 30 October 2012 - 04:02 PM

I'm trying to figure out how it's possible to match a 2D pattern inside a 2D array as shown below;

2D array
1, 0, 0, 1, 0, 1
1, 0, 1, 1, 1, 1
0, 1, 0, 0, 1, 0
1, 0, 1, 1, 0, 1
0, 0, 0, 0, 1, 0
1, 1, 1, 1, 0, 1

2D pattern to be matched
1, 0, 1
0, 1, 0
1, 0, 1

Let's mention that the 2D array can be larger in other contexts. I'm also using 0 and 1 as values, but it could be any other IDs. I just tried to keep my example simple. Anyone know what would be the most efficient and fastest way to match all patterns in the 2d array in a C++ or C# program (or whatever)?

It's for a game I'm trying to make. When clicking with the mouse the player set tiles on the grid, so in real-time I need to check if the pattern condition is met each time the player click to change a tile.

URLs or tutorials with similar topics would be greatly appreciated. Thank you for your insights!

### #1thescholar

Posted 30 October 2012 - 04:01 PM

I'm trying to figure out how it's possible to match a 2D pattern inside a 2D array as show below;

2D array
1, 0, 0, 1, 0, 1
1, 0, 1, 1, 1, 1
0, 1, 0, 0, 1, 0
1, 0, 1, 1, 0, 1
0, 0, 0, 0, 1, 0
1, 1, 1, 1, 0, 1

2D pattern to be matched
1, 0, 1
0, 1, 0
1, 0, 1

Let's mention that the 2D array can be larger in other contexts. I'm also using 0 and 1 as values, but it could be any other IDs. I just tried to keep my example simple. Anyone know what would be the most efficient and fastest way to match all patterns in the 2d array in a C++ or C# program (or whatever)?

It's for a game I'm trying to make. When clicking with the mouse the player set tiles on the grid, so in real-time I need to check if the pattern condition is met each time the player click to change a tile.

URLs or tutorials with similar topics would be greatly appreciated. Thank you for your insights!

PARTNERS