I'm trying to use restrictions programming through Prolog CLP FD to solve a puzzle that was proposed. This puzzle consists in the next simple rules:
Now, in my code, I already cover the restrictions for the 2x2 grid AND that one piece MUST be connected to AT LEAST one of the same color.
The problem is that I cannot find a way to build the restriction that says that one piece MUST have a PATH (be connected) to all the other pieces of the same color, without passing through pieces of the opposite color, so I'm getting this kind of outputs:
0 0 0 0
0 1 0 1
0 1 0 1
0 1 0 0
0 0 0 0
0 1 0 1
0 1 0 1
0 1 0 1
where the 1s are not all connected to each other.
How can I write this kind of graph restrictions in CLP FD?
EDIT: I am using SICStus Prolog.