Reputation: 33
I am making a game, somewhat similar to connect 4, in that the aim is to connect same values in a grid. However, differently from connect 4, the connected values do not have to be in one straight line. For example:
0000
0100
0111
Where "1" is an item dropped by the player, I need to make an algorithm to tell me how many connections were made (4), and where on the grid. Whether you can point me in the right direction for where to look, give advice or even code, I appreciate all and any help! :) Btw I'm making this program in C#, so any language specific stuff has gotta be for that
THANKS "The Javatar" :) seems to work
Upvotes: 0
Views: 226
Reputation: 719
This is a classic Fill algorithm. There are two ways you can implement it. Either with a recursive method or using queue (being equivalent to DFS / BFS traversal of a graph).
Here are all the information you would need for implementing it :) https://en.wikipedia.org/wiki/Flood_fill
Upvotes: 1