C# - Find Adjacent Number Groups Of 3 Or More In 2d Matrix
Trying to write some code to search a 2d matrix/array.
It will look for groupings of adjacent numbers of 3 or more.
So for example
Here there is a group of 1's adjacent in the top left.
Its for a beginners game in .NET c# XNA.
for (int x=0;x<maxx;x++)
for (int y=0;x<maxy;y++)
// Match found
// then match the found item
That is where I got stuck I couldnt see how to continue searching once a match was found..
Appreciate any help.
What do you want to happen?
Be careful with copy/paste:
- In you second if, you forgot to change a x to y.
- You forgot to change the index of last matrix comparison, it should be x+2.
You should also check for "out of bound" issues: x , x+1 and x+2 should never be higher than maxx.