Grid based game question.

Hi. I’m developing a grid based game similar to 3 stone-matching games as I might have mentioned before. Everything is fine so far except I can’t think of a way to prevent spawning same 3 stones in a row at the start.

I tried to check grid cells one by one right after generating stones and replace the matching stones in a row with random type of stones then repeat the process untill my grid was clear of matching stones. But then Unity crashed, expectedly. That was the worst and only idea I had.

So, what would be the best way to accomplish such a hard task? (Well, Hard for me at least.)

Thanks.

Hi,
What you want is: when I put a stone on the grid I have to be sure that it’s not of the same color of the two previous one on the x axis and the two previous ones on y.

I can’t write any code here as I don’t know exactly what your grid looks like internaly. But you just have to check the two previous on both axis and swap color if there is a chance of 3 color alignment.