Hello all again, (THIS post is related:)

I am here with my next question to my remake of the SEGA game columns.

What algorithm do I use to find matching tiles of 3 OR more tiles that are of the same color in a 2D array, AND that are on the SAME line in any of the 8 directions. (horz,vert,diag.)

I was also hoping to discuss some presuedo code. Each grid is 6 tile wide, and 16 tiles tall. I have three 2d arrays. one for my Visual grid of game objects, one for the main 2D grid to handle the core logic of the game made of up my special class Type âGemâ where each tile basically keeps track of its color, x and y coords, and a few other things at the moment and finally just a temp storage area where i COPY the main grid to for manipulation of match making of tiles of same color, resettling the board, etc. I have been reading about DFS and BFS algorithms, I am not sure which one that I have already written, but currently I have it so that when my CheckForNeighbor routine finds a matching gem that is adjecent to my ârootâ gem its doesnt return, but rather keeps on looking in its current direction one tile further from the ârootâ gem and so on until we hit the edge of the board, and empty tile, or a NON-matching gemâŚ Which one I should use because it is best suited for my situation? with the above method that I have already written it will not âfindâ all of the correct matches, it does almost all of the time, but in situations where is starts to check âUPâ and finds 3 matching gems in a row one after the other, the check WONT go left or right, as its trying to find âthe furthestâ gem away that is connected to the 1st gem, but never goes back to revisit the child nodes it found along the way to âcheck its neighbors of neighborsâ. and I wrote it that way trying to avoid the âflood fillâ effect when trying to make matches that follow the 3 in a row ON the same line rule (which the flood fill does not follow, it just finds all the connecting neighbors of neighbors until it exhausts all options, which i need all neighbors of neighbors, BUT IN A STRAIGHT LINE of 3 or MOREâŚ).

So In a nutshell how would I use this BFS algorithm in my said situation with the Rules of matching as the COLUMNS game has them laid out? or should i be using something else?

Again, I use C#, and Iâm not a unity pro, but I would like to attempt to understand how to implement the best algorithm into this game Iâm coding.

Thanks

King

"In graph theory, **breadth-first search** (**BFS**) is a strategy for searching in a graph when search is limited to essentially two operations: (a) visit and inspect a node of a graph; (b) gain access to visit the nodes that neighbor the currently visited node. The BFS begins at a root node and inspects all the neighboring nodes. Then for each of those neighbor nodes in turn, it inspects their neighbor nodes which were unvisited, and so on. "