On Sep 26, 4:44*pm, Alexander <(EMail Removed)> wrote:
> Hello everyone!
>
> I need a way to perform an action in adjacent positions in a matrix (grid) container.
>
> Example 1:
> In a Minesweeper game, if a square is empty and there are no mines aroundit, all the empty squares around it should be opened, and all the empty squares around them, and ... well, you get the point.
>
> Example 2:
> In a painting program, when a 'fill' tool is used, when a pixel is clicked, all the adjacent squares, and their, adjacent squares, and... with the same color get colored in another way.
>
> Could you tell me about a possibly simple, possibly efficient (emphasis on simplicity though) for implementing stuff like that?
>
> If I haven't made myself clear enough, or you have any questions, please ask!
>
> Thank you!
>
> P.S. 1:
> Sorry for posting to this group, this is not a c++ specific question, butI did not find a more suitable group, and I usually program in C++ (thoughrecently I'm falling in love with Python for the quickanddirty jobs)
>
> P.S. 2:
> In case you think I'm a student asking help for his homework, I would be perfectly happy with general answers, like just the name of an algorithm. Anyway that's not the case. (I am a student, but in highschool, programmingis a hobby for me).
Try a stack. Or, if you really favor bits of simplicity over
efficiency, try recursion.
