GUI for matching game

I am writing a matching game using C++ GUI but I can't think a way of doing so.
It is kind of games similar to Noah's Ark to match animals.

The basic rule of game:
All pictures are shown up and needed to be paired up.
They can be paired if they are next to each other(vertical or horizontal)or can be drawn a clear path between them(no obstacle).

It may be okay to test if they are next together.But,I really cannot think a way to test whether there is a clear path linked the pictures together. I need some idea because I haven't done this type of game before.

Should I use for loop to check?

Thank you very much!!
Topic archived. No new replies allowed.